Skip to content

Instantly share code, notes, and snippets.

View stuffmc's full-sized avatar

StuFF mc stuffmc

View GitHub Profile
@stuffmc
stuffmc / .swiftlint.yml
Last active February 5, 2018 12:21
Initial "all disabled" SwiftLint Config File
disabled_rules:
- block_based_kvo
- closing_brace
- colon
- comma
- conditional_binding_cascade
- control_statement
- empty_count
- file_length
- for_where
@stuffmc
stuffmc / gist:507c3fc6d0ccad19c9c60ea81032b465
Last active January 10, 2018 08:44
English Translation "Rückbaupause in Manheim-alt"
Demolition break in Manheim-alt
To: RWE, Bundestag, State of North Rhine-Westphalia, City of Kerpen
Started by: Manuel Carrasco Molina
We call on RWE to hold talks about a possible break in the dismantling of Manheim-alt so that we can discuss the future of this place together.
A working group consisting of politicians, business and administration could be formed for this purpose. Alternatively (or in addition) the Council calls on RWE to explain this break of its own accord.
Reason:
It is generally known that the Hambach open-cast mine may not be as large as originally planned. This is currently supported by many indications, such as the clearance stop in the Hambach forest, the conflict over the BUND property between open-cast mining and Manheim-alt, as well as the current various government formation talks on an early exit from coal production (example 7GW by Angela Merkel or statements of the SPD leaders, e.g. "Climate targets go hand in hand with the end of coal-fired power generation"). (Martin Schul
repeat
tell application "System Events" to tell process "iPhoto Library Manager"
if (count of sheets of window 1) = 1 then
click button "Try Again" of sheet 1 of window 1
beep
beep
else
beep
end if
delay 5
let query = CKQuery(recordType: .Category)
query.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]
CKContainer.defaultContainer().publicCloudDatabase.performQuery(query) { (records) -> Void in
completionHandler(records ?? [])
}
@stuffmc
stuffmc / DonutChartInterfaceController.swift
Last active January 28, 2016 15:40
Dynamic / Moving / Turning / Wheeling version of DonutChartInterfaceController.swift from YOChartImageKit
import WatchKit
import YOChartImageKit
class DonutChartInterfaceController: BaseInterfaceController {
let chart = YODonutChartImage()
var frame: CGRect?
var timer: NSTimer?
var startAngle = -M_PI_2
var images: [UIImage]?
var index = 0
// List from http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 — That first line is a bit long ;)
let countries = ["Aruba":"ABW","Afghanistan":"AFG","Angola":"AGO","Anguilla":"AIA","Åland Islands":"ALA","Albania":"ALB","Andorra":"AND","United Arab Emirates":"ARE","Argentina":"ARG","Armenia":"ARM","American Samoa":"ASM","Antarctica":"ATA","French Southern Territories":"ATF","Antigua and Barbuda":"ATG","Australia":"AUS","Austria":"AUT","Azerbaijan":"AZE","Burundi":"BDI","Belgium":"BEL","Benin":"BEN","Bonaire, Sint Eustatius and Saba":"BES","Burkina Faso":"BFA","Bangladesh":"BGD","Bulgaria":"BGR","Bahrain":"BHR","Bahamas":"BHS","Bosnia and Herzegovina":"BIH","Saint Barthélemy":"BLM","Belarus":"BLR","Belize":"BLZ","Bermuda":"BMU","Bolivia, Plurinational State of":"BOL","Brazil":"BRA","Barbados":"BRB","Brunei Darussalam":"BRN","Bhutan":"BTN","Bouvet Island":"BVT","Botswana":"BWA","Central African Republic":"CAF","Canada":"CAN","Cocos (Keeling) Islands":"CCK","Switzerland":"CHE","Chile":"CHL","China":"CHN","Côte d'Iv
@stuffmc
stuffmc / Inspectable UISplitViewController
Created October 5, 2014 19:27
Not sure why the new #UISplitViewController iOS 8.0 goodness isn't inspectable, but this fixes it.
import UIKit
@IBDesignable
class SplitVC: UISplitViewController {
@IBInspectable var minCol1Width: CGFloat {
get { return self.minimumPrimaryColumnWidth }
set(newValue) { self.minimumPrimaryColumnWidth = newValue }
}
@IBInspectable var maxCol1Width: CGFloat {
let bytes = [84,11]
// Imperative — 6 lines but more readable
var hex = ""
for byte in bytes {
let format = NSString(format: "%02x", byte)
hex = "\(hex)\(format)"
}
hex
func simulate(hexa: Int!) -> NSData! {
let string = NSString.stringWithCharacters([0x01], length: 1) // Totally compiles
func simulate(hexa: Int!) -> NSData! {
let string = NSString.stringWithCharacters([hexa], length: 1)
// Compile error: 'UnsafePointer<unichar>' does not have a member named 'Element'
FIX:
func simulate(hexa: unichar) -> NSData! {
// curl -X POST -H "Content-Type: body=application/json" -d '{"logs":["xyz"]}' https://example.com/v1/log
$cont = file_get_contents('php://input');
echo "cont: $cont\n"; // Outputs cont: {"logs":["xyz"]}
$log = json_decode($cont);
echo "log: $log\n"; // Never outputed. Even not "log:"