Skip to content

Instantly share code, notes, and snippets.

@vlucas
vlucas / encryption.js
Last active July 26, 2024 20:12
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@evan-goode
evan-goode / weather-emoji.sh
Created February 10, 2016 03:30
returns an emoji representing the current weather conditions in a specified location
#!/bin/bash
woeid="2390183"
weather=`curl --silent "http://xml.weather.yahoo.com/forecastrss?w=${woeid}&u=f" | xmllint --xpath "string(//*[local-name()='condition']//@code)" -`
# codes from https://developer.yahoo.com/weather/documentation.html#codes
case "$weather" in
0) # tornado
emoji="🌪" # cloud with tornado
;;
@erichurst
erichurst / US Zip Codes from 2013 Government Data
Created December 9, 2013 23:00
All US zip codes with their corresponding latitude and longitude coordinates. Comma delimited for your database goodness. Source: http://www.census.gov/geo/maps-data/data/gazetteer.html
This file has been truncated, but you can view the full file.
ZIP,LAT,LNG
00601,18.180555, -66.749961
00602,18.361945, -67.175597
00603,18.455183, -67.119887
00606,18.158345, -66.932911
00610,18.295366, -67.125135
00612,18.402253, -66.711397
00616,18.420412, -66.671979
00617,18.445147, -66.559696