by alexander white ©
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
| function encrypt(text){ | |
| var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq') | |
| var crypted = cipher.update(text,'utf8','hex') | |
| crypted += cipher.final('hex'); | |
| return crypted; | |
| } | |
| function decrypt(text){ | |
| var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq') | |
| var dec = decipher.update(text,'hex','utf8') |
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
| server { | |
| listen 0.0.0.0:80; | |
| listen [::]:80 default_server ipv6only=on; | |
| server_name localhost; | |
| access_log /var/log/nginx/app.log; | |
| root /usr/share/nginx/html/app-static; | |
| index index.html; | |
| location /v1 { | |
| proxy_set_header X-Real-IP $remote_addr; |
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 settings = {payToAddress: 'YOUR_BITCOIN_ADDRESS'}; | |
| var ac = require('accept-bitcoin')(settings); | |
| //generate new key for transaction | |
| key = ac.generateAddress({alertWhenHasBalance: true}); | |
| console.log("Hello buyer! please pay to: " + key.address()); | |
| key.on('hasBalance', function(amount){ | |
| console.log "thanks for paying me " + amount; //do stuff | |
| //transfer the amount recived to your account | |
| key.transferBalanceToMyAccount(function(err, d){ | |
| if (d.status === 'success') console.log("Cool, the bitcoins are in my private account!"); |
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 settings = {network: 'live'}; | |
| var acceptBitcoin = require('accept-bitcoin'); | |
| ac = new acceptBitcoin('YOUR_BITCOIN_ADDRESS', settings); | |
| //generate new key for transaction | |
| key = ac.generateAddress({alertWhenHasBalance: true}); | |
| console.log("Hello buyer! please pay to: " + key.address()); | |
| key.on('hasBalance', function(amount){ | |
| console.log("thanks for paying me " + amount); //do stuff | |
| //transfer the amount recived to your account | |
| key.transferBalanceToMyAccount(function(err, d){ |
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
| def perm arr, i=0 | |
| return p arr if i == arr.size | |
| (i..arr.size-1).each do |j| | |
| arr[i], arr[j] = arr[j], arr[i] | |
| perm arr, i+1 | |
| arr[i], arr[j] = arr[j], arr[i] | |
| end | |
| end | |
| perm 'ABC' |
by alexander white ©
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 "sort" | |
| func main() { | |
| arr := []int{2,4,3,1} | |
| sort.Ints(arr) | |
| fmt.Println(arr) // => [1,2,3,4] | |
| } |
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 merge_sort(l []int) []int { | |
| if len(l) < 2 { | |
| return l | |
| } | |
| mid := len(l) / 2 | |
| a := merge_sort(l[:mid]) | |
| b := merge_sort(l[mid:]) | |
| return merge(a, b) | |
| } |
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
| $ go test -bench=. -cpu 4 -benchtime 10s mergesort_test.go | |
| testing: warning: no tests to run | |
| PASS | |
| BenchmarkMSAsync-4 10 1450210929 ns/op | |
| ok command-line-arguments 20.887s | |
| $ go test -bench=. -cpu 4 -benchtime 10s quicksort_test.go | |
| testing: warning: no tests to run | |
| PASS | |
| BenchmarkQS-4 5 2101334470 ns/op |
OlderNewer