This file contains 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 <Foundation/Foundation.h> | |
// clang -o main -framework Foundation main.m | |
int main(int argc, const char*argv[]) { | |
@autoreleasepool { | |
NSLog(@"%@", (@42).class); // __NSCFNumber | |
NSLog(@"%@", (@YES).class); // __NSCFBoolean | |
NSLog(@"%@", @"Hello".class); // __NSCFConstantString | |
NSLog(@"%@", [NSString stringWithFormat:@"%d", 42].class); // NSTaggedPointerString |
This file contains 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
<!DOCTYPE html> | |
<html class="client-nojs" lang="zh" dir="ltr"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>信达雅 - 维基百科,自由的百科全书</title> | |
<script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames":!1,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRequestId":"Xq2FtgpAIEIAALZYaGUAAACK","wgCSPNonce":!1,"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":!1,"wgNamespaceNumber":0,"wgPageName":"信达雅","wgTitle":"信达雅","wgCurRevisionId":58390926,"wgRevisionId":58390926,"wgArticleId":6040218,"wgIsArticle":!0,"wgIsRedirect":!1,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["翻譯"],"wgPageContentLanguage":"zh","wgPageContentModel":"wikitext","wgRelevantPageName":"信达雅","wgRelevantArticleId":6040218,"wgUserVariant":"zh","wgIsProbablyEditable":!0,"wgRelevantPageIsProbablyEditable":!0,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgMediaViewerOnClick":!0,"w |
This file contains 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
function moveAllZerosToLeft(input) { | |
let zeros = []; | |
let numbers = []; | |
for (const element of input) { | |
if (element === 0) { | |
zeros.push(element); | |
} else { | |
numbers.push(element); | |
} | |
} |
This file contains 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
const Time = require('Time'); | |
const Diagnostics = require('Diagnostics'); | |
let promise = new Promise((resolve, reject) => { | |
Time.setTimeout(function() { resolve(1); } , 5000); | |
// Time.setTimeout(function() { reject("Failed"); }, 5000); | |
}); | |
promise.then(function(value) { | |
Diagnostics.log("Then: " + value); | |
}).catch(function(reason) { |
This file contains 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
infix operator ?=: AssignmentPrecedence | |
infix operator ??=: AssignmentPrecedence | |
func ?= <T>(lhs: inout T, rhs: T?) { | |
print("-- ?= start") | |
defer { print("-- ?= end") } | |
guard let actualRhs = rhs else { return } | |
lhs = actualRhs | |
} |
This file contains 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
// clang main.cpp -lstdc++ -std=c++14 -o main | |
#include <iostream> | |
#include <string> | |
class A { | |
public: | |
std::string name() { | |
return "A"; | |
} | |
}; |
This file contains 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
called = False | |
class Stoppable: | |
def stop(self): | |
print("Stopped") | |
def sad(): | |
global called |
This file contains 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
#!/bin/sh | |
docker run -ti --rm -v `pwd`:/root/hack -w /root/hack hhvm/hhvm hhvm $1 |
This file contains 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
struct Matrix<Element> { | |
let dimensions: [Int] | |
var content: [Element] | |
init(_ dimensions: [Int], initial value: Element) { | |
self.dimensions = dimensions | |
let elementCount = self.dimensions.reduce(1, *) | |
self.content = [Element](repeatElement(value, count: elementCount)) | |
} |
This file contains 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
extension Collection { | |
var middleIndex: Index? { | |
guard !self.isEmpty else { return nil } | |
return self.index(self.startIndex, offsetBy: self.count/2) | |
} | |
var middle: Iterator.Element? { | |
guard let middleIndex = self.middleIndex else { return nil } | |
return self[middleIndex] | |
} |
NewerOlder