Skip to content

Instantly share code, notes, and snippets.

@vlucas
vlucas / encryption.js
Last active November 15, 2024 01:39
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);
@esquireofoz
esquireofoz / cloudfront_pop_locations.psv
Created September 29, 2016 12:41
AWS CloudFront POPs by City and Region
AMS1 | Amsterdam, The Netherlands | Europe
AMS50 | Amsterdam, The Netherlands | Europe
ARN1 | Stockholm, Sweden | Europe
ATL50 | Atlanta, Georgia | United States
ATL52 | Atlanta, Georgia | United States
BOM2 | Mumbai, India | India
BOM51 | Mumbai, India | India
CDG3 | Paris, France | Europe
CDG50 | Paris, France | Europe
DEL51 | Paris, France | Europe
@davidrichards
davidrichards / caudio
Last active December 7, 2021 02:00
Collecting ffmpeg snippets that work for me and converting them to reusable scripts.
#!/usr/bin/env bash
set -e
gain=${3-"1"}
if [ "$#" -lt 2 ]; then
echo "Usage: $0 input.aifc output.aifc [gain=2]"
exit 1
else
@Nihisil
Nihisil / jail.local
Last active September 5, 2023 06:20
Send notifications to the Slack from fail2ban
...
action_with_slack_notification = %(banaction)s[name=%(__name__)s, port="%(port)$
slack[name=%(__name__)s]
action = %(action_with_slack_notification)s
...
@adunsmoor
adunsmoor / gist:e848356a57980ab9f822
Last active December 17, 2018 08:45
closed convex hull in Swift
import UIKit
// Returns a list of points on the convex hull in counter-clockwise order.
// Note: the last point in the returned list is the same as the first one.
//
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain
//
func closedConvexHull(points_ : [CGPoint]) -> [CGPoint] {
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product.
@kentcdodds
kentcdodds / startsOrEndsWithMixins.js
Created October 17, 2014 18:02
starts and ends with mixins
(function() {
'use strict';
_.mixin({
startsWith: function startsWithMixin(s1, s2) {
return startsOrEndsWith(_.first, s1, s2);
},
endsWith: function endsWithMixin(s1, s2) {
return startsOrEndsWith(_.last, s1, s2);
}
});
@pocketkk
pocketkk / Swift - Sort by date.swift
Created July 27, 2014 17:51
Swift - Sort objects by date field
@objc(Note)
class Note: NSManagedObject {
@NSManaged var content: String
@NSManaged var date: NSDate
@NSManaged var business: Business
@NSManaged var coldcall: ColdCall
@NSManaged var contact: Contact
}