- Don't run as root.
- For sessions, set
httpOnly(andsecuretotrueif running over SSL) when setting cookies. - Use the Helmet for secure headers: https://github.com/evilpacket/helmet
- Enable
csrffor preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf - Don't use the deprecated
bodyParser()and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use thedeferproperty andpipe()the multipart upload stream to the intended destination.
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" | |
| "math/big" | |
| "time" | |
| ) | |
| func makeNCRS(ncrs chan *big.Int, maxn int64) { | |
| var n, r int64 |
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
| MAXN = 100 | |
| MAXNCR = 1000000 | |
| import time | |
| before = time.time() | |
| def nCrs(maxn): | |
| n = r = ncr = 1 | |
| while n <= maxn : | |
| if n == r : |
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
| #! /usr/bin/env python3 | |
| from math import factorial | |
| #from functools import lru_cache | |
| MAXN = 100 | |
| MAXNCR = 1000000 | |
| import time | |
| before = time.time() |
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
| #! /usr/bin/env python | |
| import heapq | |
| from itertools import imap, ifilter | |
| import time | |
| before = time.time() | |
| class Pair(object): | |
| def __init__(self, f1, f2): | |
| self.f1, self.f2 = f1, f2 | |
| self.total = f1 + f2 |
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 is_palindrome(int number){ | |
| word = Int.to_string(number) | |
| word == String.reverse(word) | |
| } | |
| function pair_with(int elem, it){ | |
| Iter.map(function(el){ (elem, el) }, it) | |
| } | |
| function pairs(seq){ |
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
| NUMBER = 600851475143 | |
| iter numbers = Iter.init(2, function(int elm){ elm + 1 }, function(int elm){ elm > 0 }) | |
| function iter remove_multiples(int a, iter seq){ | |
| Iter.filter(function(int elm){ mod(elm, a) != 0 }, seq) | |
| } | |
| function primes_init(iter seq){ | |
| match(seq.next()){ |
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
| INDEX = 10001 | |
| iter numbers = Iter.init(2, function(int elm){ elm + 1 }, function(int elm){ elm > 0 }) | |
| function iter remove_multiples(int a, iter seq){ | |
| Iter.filter(function(int elm){ mod(elm, a) != 0 }, seq) | |
| } | |
| function primes_init(iter seq){ | |
| match(seq.next()){ |
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
| type fib = iter(int) | |
| MAX = 4000000 | |
| function fib fibs_init(a,b) { | |
| { next : function () { some((a, fibs_init(b, a+b))) } } | |
| } | |
| fib fibs = fibs_init(1,2) | |
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
| #! /usr/bin/env python3 | |
| from functools import lru_cache | |
| from itertools import count, takewhile | |
| numbers = count(1) | |
| MAX = 4000000 | |
| @lru_cache(maxsize=None) | |
| def fib(n) : |