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
list_a = ['foo', 'bar'] | |
list_b = ['hoge', 'fuga'] | |
list_c = [123, 456] | |
for tuple in zip(list_a, list_b, list_c): | |
print '%s - %s / %s'% tuple | |
>> foo - hoge / 123 | |
bar - fuga / 456 |
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 current_time() { | |
var d = new Date(); | |
var month = d.getMonth() + 1; | |
var day = d.getDate(); | |
var hour = d.getHours(); | |
var minute = d.getMinutes(); | |
var second = d.getSeconds(); | |
var w = ["日","月","火","水","木","金","土"]; | |
//convert to a two-digits number |
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 arrayDiff(older, newer) { // filter only addition | |
function callback_filter(element, index, array) { | |
return (this.indexOf(element) == -1); // element not included is true | |
} | |
return newer.filter(callback_filter, older); | |
} |
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
[1,2,3].toString(); | |
>> "1,2,3" | |
JSON.stringify([1,2,3]); | |
>> "[1,2,3]" |
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 os | |
import time | |
os.utime(filename, None) # set current time | |
access_time = fix_time = time.mktime((2009, 1, 2, 3, 4, 5, 0, 0, -1)) # 2009/01/02 03:04:05 | |
os.utime(filename, (access_time, fix_time)) |
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 hoge(width, height) { | |
var w = width || 100; //if width is undefined, width = 100 | |
var h = height || 200; //if height is undefined, height = 200 | |
return width*height; | |
} |
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
var png = mainCanvas.toDataURL() |
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
f = open(path, "rb") | |
hex_data = f.read().encode("hex") | |
hex_data_replaced = re.sub('(..)', r'\1 ', hex_data) | |
print hex_data_replaced | |
f.close() |
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(F, 16) | |
>> 15 |
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
list1 = ["a", "b", "c"] | |
text = "".join(list1) | |
>> "abc" | |
list2 = [1, 2, 3] | |
text = "".join(map(str, list2)) | |
>> "123" | |
list3 = list(map(int, text)) | |
print list3 |
OlderNewer