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
// 理想 | |
if let mediaURL = status["extended_entities"]["media"][0]["media_url"].string { | |
} | |
// 現実 | |
if let extendedEntities = status?["extended_entities"] { | |
if let mediaArray = extendedEntities["media"].array as Array<JSONValue>! { | |
if let media = mediaArray[0].object as Dictionary<String, JSONValue>! { | |
if let mediaURL = media["media_url"] as JSONValue! { |
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
func tokenField(tokenField: NSTokenField, shouldAddObjects tokens: [AnyObject], atIndex index: Int) -> [AnyObject] { | |
var acceptedTokens = NSMutableArray() | |
if let currentTokens = tokenField.objectValue as? NSArray { | |
if let tokensArray = tokens as? [NSManagedObject] { | |
for token in tokensArray { | |
if currentTokens.indexOfObject(token) == NSNotFound { | |
acceptedTokens.addObject(token) | |
} | |
} |
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
TASK: [install memcached] ***************************************************** | |
failed: [default] => {"cmd": "apt-get update && apt-get install python-apt -y -q", "failed": true, "rc": 127} | |
stderr: /bin/sh: apt-get: command not found | |
msg: /bin/sh: apt-get: command not found | |
FATAL: all hosts have already failed -- aborting |
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
def build_query_string(params): | |
query_string = '' | |
for param in params: | |
if query_string != '': | |
query_string += '&' | |
query_string += param['key'] + '=' + param['value'] | |
return query_string |
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
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
int a = 1, b = 2, c = 3, d = 4; | |
a = b, c, d; | |
printf("a = %d, b= %d, c = %d, d = %d\n", a, b, c, d); // a = 2, b= 2, c = 3, d = 4 | |
printf("\"a = b, c, d;\" = %d\n", (a = b, c, d)); // "a = b, c, d;" = 4 | |
return 0; |
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
// 初期実装 | |
int get_tax_rate(int year) { | |
if (year <= 2013) { | |
return 5; | |
} | |
else if (year >= 2019) { | |
return 10; | |
} | |
else { | |
return 5 + (year - 2013); |
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
hiyoriTop3({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); #=> {10, 9, 8} | |
hiyoriTop3({ 1, 2, 3, 4, 5, 6, 7, 8, 10, 10}); #=> {10, 10, 8} | |
hiyoriTop3({ 1, 2, 3, 4, 5, 6, 7, 8, 8, 10}); #=> {10, 8, 8} | |
hiyoriTop3({ 1, 2, 3, 4, 5, 6, 7, 10, 10, 10}); #=> {10, 10, 10} | |
hiyoriTop3({10, 10, 10, 10, 10, 10, 10, 10, 10, 10}); #=> {10, 10, 10} |
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
class maxTest { | |
public static void main(String args[]){ | |
test("test 1", 1, 2, 2); | |
test("test 2", 2, 1, 2); | |
test("test 3", 1, 1, 1); | |
} | |
public static void test(String name, int a, int b, int excepted) { | |
int max; |
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
class maxTest { | |
public static void main(String args[]){ | |
int a, b, max; | |
// Test 1 | |
a = 1; | |
b = 2; | |
max = Math.max(a, b); | |
if (max == 2) { | |
System.out.println("test 1 OK"); |
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
public class Baisuu{ | |
public static void main(String[] args){ | |
for(i=2;i=<32;i=i*2){ | |
System.out.println(i); | |
} | |
} | |
} |