This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class SplitVC: UISplitViewController { | |
@IBInspectable var minCol1Width: CGFloat { | |
get { return self.minimumPrimaryColumnWidth } | |
set(newValue) { self.minimumPrimaryColumnWidth = newValue } | |
} | |
@IBInspectable var maxCol1Width: CGFloat { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let query = CKQuery(recordType: .Category) | |
query.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)] | |
CKContainer.defaultContainer().publicCloudDatabase.performQuery(query) { (records) -> Void in | |
completionHandler(records ?? []) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
disabled_rules: | |
- block_based_kvo | |
- closing_brace | |
- colon | |
- comma | |
- conditional_binding_cascade | |
- control_statement | |
- empty_count | |
- file_length | |
- for_where |