Skip to content

Instantly share code, notes, and snippets.

@mxhold
mxhold / db_migration_strategies.md
Last active January 9, 2019 20:47
Database migration strategies

Web application database migration strategies

Since the database is separate from the application and changes cannot be made to both simultaneously, there are various strategies for keeping them in sync.

Fully-coupled

Many web applications are deployed by:

  1. stopping the application
  2. running any database migrations
@mxhold
mxhold / download_slack_emoji.md
Last active April 1, 2020 03:02
Download Slack Emoji

✨ Download Slack Emoji ✨

Quick way to export your Slack team's emoji (concurrently!)

Prerequisites

  1. Create an API token for your Slack team
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Pastebin
description: A simple pastebin service
version: "1.0.0"
host: localhost:8000
schemes:
@mxhold
mxhold / rust_integers.md
Last active February 17, 2017 20:00
Integers in Rust
Type Length (bits) Minimum value Maximum value
u8 8 0 255
i8 8 -128 127
u16 16 0 65,535
i16 16 -32,768 32,767
u32 32 0 4,294,967,295
i32 32 -2,147,483,648 2,147,483,647
u64 64 0 18,446,744,073,709,551,615
i64 64 -9,223,372,036,854,775,808 9,223,372,036,854,775,807
@mxhold
mxhold / rust_wtf.md
Created October 29, 2016 16:32
Rust WTF moments

This compiles:

extern crate hyper;
use std::{thread, time};

use hyper::server::{Server, Request, Response};
use hyper::uri::RequestUri::*;

fn hello(req: Request, res: Response) {

Elixir list vs tuple benchmark

Lists

Length

  size             i/s             μ/i
   10k        28051.11           35.65
  100k         3251.63          307.54

1m 512.33 1951.87

@mxhold
mxhold / twitter_intersect
Last active August 29, 2015 14:27
Shows the interesting intersections of followers between two Twitter users
#!/usr/bin/env ruby
# Usage:
# ./twitter_intersect username1 username2
# You'll need to `gem install twitter`
require 'twitter'
# see: https://dev.twitter.com/oauth/overview/application-owner-access-tokens
@client = Twitter::REST::Client.new do |config|
@mxhold
mxhold / followers_in_common
Last active August 29, 2015 14:27
Find the followers in common between two Twitter users
#!/usr/bin/env ruby
# Usage:
# ./followers_in_common maxholder sandimetz
# You'll need to `gem install twitter`
require 'twitter'
# see: https://dev.twitter.com/oauth/overview/application-owner-access-tokens
client = Twitter::REST::Client.new do |config|
if(pointsRight === 5){
console.log("<p><p><h1><color="green">Congratulations! You got them all right! You've won the gold crown! Aren't you smart?</p>");
} else if(pointsRight === 4 || pointsRight === 3){
console.log("<p>Congratulations! You got " + pointsRight " right! Here's a silver crown!"</p>);
} else if(pointsRight === 2 || pointsRight === 1){
console.log("<p>Congratulations! You got " + pointsRight " right! Here's a bronze crown!"</p>);
else{
console.log(<p>"Congratulations! You got " + pointsRight " right and " + pointsWrong " wrong here's your nega-crown.</p>");
}
@mxhold
mxhold / no-trailing-slashes-nginx-and-middleman.md
Last active January 21, 2019 00:10
Prevent trailing slashes in URLs with Middleman and Nginx

So you want to have pretty URLs with no trailing slash or .html like:

http://mysite.com/blog/my-new-kitten

not like:

http://mysite.com/blog/my-new-kitten/

or