Skip to content

Instantly share code, notes, and snippets.

@chrisveness
chrisveness / crypto-pbkdf2.js
Last active December 21, 2023 19:20
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*
@MihaiTabara
MihaiTabara / tweepy_runner.py
Last active September 8, 2021 16:03
Script to download Twitter timeline for a user and store it to MongoDB
# script to download up to <= 3200 (the official API limit) of most recent tweets from a user's timeline
from pymongo import MongoClient
import tweepy
import json
#Twitter API credentials
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
@baoilleach
baoilleach / zlib_mingw.txt
Created July 11, 2013 13:47
Compile zlib statically with mingw
> set PATH=C:\MinGW\bin;%PATH%
C:\Tools\zlib\zlib-1.2.8> C:\MinGW\bin\mingw32-make.exe -fwin32/Makefile.gcc
gcc -O3 -Wall -c -o adler32.o adler32.c
gcc -O3 -Wall -c -o compress.o compress.c
gcc -O3 -Wall -c -o crc32.o crc32.c
gcc -O3 -Wall -c -o deflate.o deflate.c
gcc -O3 -Wall -c -o gzclose.o gzclose.c
gcc -O3 -Wall -c -o gzlib.o gzlib.c
gcc -O3 -Wall -c -o gzread.o gzread.c
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation