Skip to content

Instantly share code, notes, and snippets.

View jvanakker's full-sized avatar

jvanakker

View GitHub Profile
@anildigital
anildigital / cleanup_swap.md
Last active June 1, 2024 18:17
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@vankesteren
vankesteren / lantaarnpaal_utrecht.R
Last active June 29, 2019 05:24
Creating a map with all the lampposts in Utrecht
library(tidyverse)
lights_dat <- read_csv("https://ckan.dataplatform.nl/dataset/83402c68-1c05-4aa5-ab28-2e99d2bc2261/resource/dc10e0ac-351a-49b6-b3db-d0152c29dc02/download/paal-20180906.csv")
pp <-
lights_dat %>%
filter(latitude > 50) %>%
ggplot(aes(x = longitude, y = latitude)) +
geom_point(alpha = 0.03, fill = "#FAFAAB", stroke = 0, pch = 21, size = 1.6) +
geom_point(alpha = 0.8, fill = "#FAFAAB", stroke = 0, pch = 21, size = 0.2) +

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@asarode
asarode / generateRandomColor.swift
Last active May 4, 2024 14:10
Generating random UIColor in Swift
func generateRandomColor() -> UIColor {
let hue : CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0
let saturation : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white
let brightness : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1)
}
@rduplain
rduplain / MainActivity.java
Created May 8, 2012 20:08
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
package com.willowtreeapps.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@jk
jk / objc_api_visibility.pl
Created December 26, 2011 17:26
iOS AppStore private API usage checker
#!/usr/bin/env perl
# objc_api_visibility.pl
# by Ryan Petrich, inspired by Dustin Howett's Logos
# Reads all Objective-C method names from an installed SDK, determines their visibility and optionally compares against an iOS app binary
sub read_methods {
my $cmd = shift;
my $when_found = shift;
my $current_class;
open(LS_CMD, "$cmd |") or die "Can't run '$cmd'\n$!\n";