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
| collatz = Hash.new do |h, k| | |
| if k == 1 | |
| 1 | |
| elsif k.even? | |
| h[k] = h[k/2]+1 | |
| else | |
| h[k] = h[3*k+1] + 1 | |
| end | |
| end |
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
| from Crypto.Cipher import AES | |
| import os | |
| BLOCK_SIZE = AES.block_size | |
| key = os.urandom(BLOCK_SIZE) | |
| cipher = AES.new(key) | |
| def pad(data): |
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 zlib | |
| import base64 | |
| filename = '1.jpg' | |
| with open(filename, 'rb') as f: | |
| data = f.read() | |
| print len(data) | |
| bdata = base64.encodestring(data) | |
| print len(bdata) | |
| zdata = zlib.compress(bdata) |
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
| var obj1 = { | |
| name: 'alsotang', | |
| method: function() { | |
| console.log(this.name); | |
| } | |
| }; | |
| var obj2 = { | |
| name: 'freewind' | |
| }; |
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
| package main | |
| import "fmt" | |
| func main() { | |
| v := []int{1,2,3,4,5,6,7,8} | |
| mv := new(MeanValue) | |
| /*mvFunc := mv.exec()*/ | |
| nmv := new(MeanValue) | |
| nmvFunc := nmv.exec() |
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
| #In Ruby: | |
| class Foo | |
| attr_accessor :bar | |
| end | |
| f = Foo.new | |
| f.bar = 'baz' | |
| f.bar # => 'baz' |
NewerOlder