Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
A ghost

Nathan myobie

👻
A ghost
View GitHub Profile
@myobie
myobie / now.yml
Last active Jan 7, 2020
Zeit's now preview and prod deploy Actions Workflow – emulates how Zeit's Now GitHub integration works, but is even better because it forces a rebuild even if the source code hasn't changed
View now.yml
name: now
on:
push:
jobs:
deploy-prod:
name: Deploy prod
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
@myobie
myobie / slugify.sql
Created Jun 1, 2019 — forked from kez/slugify.sql
Generating Slugs in Postgres
View slugify.sql
CREATE EXTENSION IF NOT EXISTS "unaccent"
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
@kez
kez / slugify.sql
Created May 13, 2019 — forked from ianks/slugify.sql
Generating Slugs in Postgres
View slugify.sql
CREATE EXTENSION IF NOT EXISTS "unaccent"
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
-- removes accents (diacritic signs) from a given string --
WITH "unaccented" AS (
SELECT unaccent("value") AS "value"
),
-- lowercases the string
"lowercase" AS (
@danielberkompas
danielberkompas / scheduler.ex
Created Oct 26, 2016
A simple mix task scheduler for Elixir apps
View scheduler.ex
defmodule MyApp.Scheduler do
@moduledoc """
Schedules a Mix task to be run at a given interval in milliseconds.
## Options
- `:task`: The name of the Mix task to run.
- `:args`: A list of arguments to pass to the Mix task's `run/1` function.
- `:interval`: The time interval in millisconds to rerun the task.
@jonathan-beebe
jonathan-beebe / vundle_swift_vim_instructions.md
Last active Mar 28, 2017
Using Apple’s Swift vim plugin with Vundle
View vundle_swift_vim_instructions.md

Source of original vim config: https://github.com/apple/swift/tree/master/utils/vim

# use `svn checkout…` to grab just the subfolder from github
svn checkout https://github.com/apple/swift/trunk/utils/vim
# rename to something a bit more specific
mv vim vim-swift
cd vim-swift
rm -rf .svn
# init git
View Type Scale
$nonpareille: 8px!default;
$minion: 9px!default;
$petit: 11px!default;
$bourgeois: 12px!default;
$long-primer: 13px!default;
$small-pica: 15px!default;
$pica: 16px!default;
$english: 19px!default;
$columbian: 21px!default;
$great-primer: 24px!default;
@mislav
mislav / fat-logfiles.sh
Last active Dec 22, 2018
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
View fat-logfiles.sh
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
View gist:3923148
def set_locale
locale = params[:locale].to_s
if !locale.blank?
cookies[:preferred_lang] = { :value => locale, :expires => 10.years.from_now }
session[:update_lang] = locale # remember preferred setting for this session
else
locale = cookies[:preferred_lang]
end
@jboner
jboner / latency.txt
Last active Aug 10, 2020
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@BinaryMuse
BinaryMuse / phantom.coffee
Created Apr 13, 2012
Take screenshots with Phantom.js from Node.js
View phantom.coffee
#!/usr/bin/env coffee
# Call the program with: coffee phantom.coffee http://url.to/screengrab
phantom = require 'phantom' # npm install phantom
child_process = require 'child_process'
url = process.argv[2]
createScreenshot = (page, filename) ->
You can’t perform that action at this time.