Skip to content

Instantly share code, notes, and snippets.

View filipsalomonsson's full-sized avatar

Filip Salomonsson filipsalomonsson

View GitHub Profile

Twitter abuses all media file uploads, each type in its own way. If we want to upload a good looking animation loop from some low-color, high-detail generative art, we have to game their system's mechanisms.

  • don't upload a video file, they will re-encode it into absolute 💩

  • create a GIF, which they will auto-convert into a video file 😱

  • The frames of the GIF will be resized to an even-sized width using an extremely naive algorithm. Your GIF should be an even size (1000, 2000,

@inoperable
inoperable / defaults-export.zsh
Last active March 11, 2024 11:12
export defaults for all domains in macOS into separate .plist files for editing and importing, files are written into $HOME/defaults
#!/usr/bin/env zsh
function exportDefaults {
local outdir="$HOME/defaults"
local outdirApple="$outdir/apple"
local outdirUser="$outdir/user"
local outdirGlobal="$outdir/global"
local filesdone=0
local filecount=0
local filestotal=0
@sstephenson
sstephenson / Simple Encryption.md
Created April 11, 2013 23:48
Simple file/stream encryption using OpenSSL

Simple file/stream encryption using OpenSSL

Create and store a 512-byte random encryption key named secret:

$ mkkey secret

Encrypt the contents of file with the secret key and write it to file.enc:

$ encrypt secret < file > file.enc
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 5, 2024 13:30
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@simX
simX / hidpi.txt
Created July 28, 2012 04:58
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@mahemoff
mahemoff / names.txt
Created April 5, 2012 22:24
Reserved username list
###
A meta-compilation of:
https://raw.github.com/gist/1453705/d253733a56632a8d2c29321a75c18b627fa4dda8/reserved_usernames.rb
http://blog.postbit.com/reserved-username-list.html
http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features
(Took out some company-specific terms at the top of the first one (e.g. imulus, stacks), added one term so far - 'edits'.)
NOTE: Does not include profanities. You may or may not want to add a list of those.
(See https://www.google.com/search?q=profanity+list, but don't try to apply regexp's here because Scunthorpe - http://en.wikipedia.org/wiki/Scunthorpe_problem)
@sstephenson
sstephenson / back_forward.js
Created December 13, 2010 21:55
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@chrisdickinson
chrisdickinson / WIP_whisper.js
Created July 30, 2010 17:18 — forked from toastdriven/WIP_base.html
FULL ON DOUBLE RAINBOW
// Whisper.js
// A light-weight blog in node.js.
// Requires:
// http://github.com/ry/node_postgres.git
// http://github.com/chrisdickinson/pieshop.git
// http://github.com/chrisdickinson/postpie.git
// ..and JSDTL, but that's not publically available yet (sorry)
// Licensed under the BSD.
/*
@henrik
henrik / .bashrc
Created July 15, 2010 06:15 — forked from filipsalomonsson/.bashrc
grep that doesn't wait forever for STDIN with unspecified filename.
# Call grep, with stdin closed if it is a terminal.
#
# Avoids the "eternal wait" problem when you've forgotten
# to specify a filename.
function grep { (tty -s && exec <&-; $(which grep) $@); }