Here's a nice way to play with a UIStackView. Copy and paste the following code into a playground, and next to the final line, click the screen icon to permanently show it. Then adjust the parameters of the playground where necessary.
var view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
view.backgroundColor = UIColor.yellow
let label1 = UILabel() label1.text = "label 1"
let label2 = UILabel() label2.text = "label 2"
let spacer1 = UIView() spacer1.backgroundColor = UIColor.green spacer1.translatesAutoresizingMaskIntoConstraints = false spacer1.widthAnchor.constraint(equalToConstant: 3).isActive = true
let spacer2 = UIView() spacer2.backgroundColor = UIColor.gray
let stackView = UIStackView(arrangedSubviews: [label1, spacer1, label2, spacer2]) stackView.distribution = .fill stackView.axis = .horizontal stackView.translatesAutoresizingMaskIntoConstraints = false stackView.spacing = 20
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true stackView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
The result should look something like this:
There's a larger and larger number of websites that auto-play completely unrelated videos when opening a page on their website. In my opinion, a very user unfriendly business.
Thankfully Firefox has an extension for this, FlashStopper: https://addons.mozilla.org/en-US/firefox/addon/flashstopper/
Before and after installing, open for example this page on the Reuters website: http://www.reuters.com/article/us-twitter-lawsuit-idUSKBN1782PH
For my current project, the user needs to select a template from a list. The template contains a number of placeholders where text needs to be filled in, and further editing needs to be done.
I've created an example Xcode project on GitHub which shows how this can be done:
Here are my short notes on creating a Linux VPS (virtual private service) which can be remotely accessed via TeamViewer. I prefer TeamViewer over other ways of remotely accessing a desktop, because it works cross-platform and through NAT and firewalls.
The big problem is often that a Linux VPS doesn't have a virtual graphical card. For remote access to the GUI, most VPS providers advise VNC while I prefer TeamViewer.
I've tried a number of Linux distributions on a number of VPS providers. The instructions below fail on VPSes at Scaleway or DigitalOcean, but the combination of Fedora 25 and Linode or Vultr made this all very easy.
First of all, register or log in at Linode or Vultr, and create a VPS. You'll need at least 1 GB of memory.
After it's started, log in via SSH as root and do the following:
# yum -y groupinstall "Fedora Workstation"
Then get the TeamViewer download URL and install the package:
# wget "https://download.teamviewer.com/download/teamviewer.i686.rpm" # yum -y install ./teamviewer.i686.rpm
Next reboot, make sure the GUI starts:
# systemctl set-default graphical.target
If your VPS runs at Vultr, disable Wayland. Edit the file /etc/gdm/custom.conf and remove the comment for the line WaylandEnable=false so GDM uses X.org. Linode already has this correctly set.
Then, add a user for yourself:
# useradd -m -U mynewusername # passwd mynewusername
Add the new user to the sudoers, and reboot:
# visudo # reboot
If you're on Linode, open remote access via glish, which is Linode's way of giving you graphical access to your VPS, through your browser. Log into the Linode management console, click on the node, then in the tab Remote Access, click the link "Launch Graphical Web Console".
If you're on Vultr, open remote access by navigating to the Instances tab in the management console, then click the three dots at the right of your server and in the menu, click "View Console":
You should see the graphical Linux login screen. In the top left corner, set shell to "Gnome Xorg" (this is important!) and then continue to log into Gnome.
In Gnome, start TeamViewer. Check the three boxes to enable remote access. You'll need to provide TeamViewer username/password, as well as click the link in the email you'll get, to confirm adding this VPS to your TeamViewer device list.
Note: a current disadvantage is that you're constricted to pretty low resolutions. On Linode, you can't set the resolution to something bigger than 1280x768. On Vultr, the maximum is 1280x1024.
Recently I wanted to test how long the battery of my 2013 MacBook Air lasts. The quickest solution I found, is as follows:
Now to test the battery:
So this is my ghetto battery test. It's a bit rough around the edges, but should give you an idea of how many hours the battery lasts. Don't take the results too serious, this is meant to get a ballpark figure.
Articles, chronologically (latest first). This is pretty old stuff.
Not yet finished. Maybe will never be finished. Maybe they'll get deleted. Who knows?