Skip to content

Instantly share code, notes, and snippets.

View emadshaaban92's full-sized avatar

Emad Shaaban emadshaaban92

  • Alexandria, Egypt
View GitHub Profile

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
package main
import (
"fmt"
"math/big"
"time"
)
func makeNCRS(ncrs chan *big.Int, maxn int64) {
var n, r int64
MAXN = 100
MAXNCR = 1000000
import time
before = time.time()
def nCrs(maxn):
n = r = ncr = 1
while n <= maxn :
if n == r :
#! /usr/bin/env python3
from math import factorial
#from functools import lru_cache
MAXN = 100
MAXNCR = 1000000
import time
before = time.time()
#! /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
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){
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()){
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()){
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)
#! /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) :