Skip to content

Instantly share code, notes, and snippets.

Ryanb58 /
Last active Jul 28, 2021
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
v3.7.0-243-gf26e75a186 []
v3.7.0-229-g087f28e29d []
johntran / wineTax.js
Last active Jul 9, 2021
ES7 async/await with SOAP requests in NodeJS
View wineTax.js
import soap from 'soap';
import moment from 'moment';
const taxServiceUrl = ''
export function generateJsonForTaxRate(json) {
const EffectiveDate = moment().toISOString();
const {
city: City,
state: State,
addressLineOne: Street1,
dmeents / redux-form-tut.js
Created Aug 6, 2016
The source code for the redux form tutorial on
View redux-form-tut.js
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import * as actions from '../../actions';
const form = reduxForm({
form: 'ReduxFormTutorial',
lopezjurip / 00000000000000_enable_uuid.rb
Created Jul 19, 2016
Rails 5 w/ Postgres: Use UUID instead of a numeric ID as primary keys
View 00000000000000_enable_uuid.rb
# db/migrate/00000000000000_enable_uuid.rb
class EnableUuid < ActiveRecord::Migration[5.0]
def change
execute 'create extension "uuid-ossp"'
enable_extension 'uuid-ossp'
spalladino /
Created Dec 22, 2015
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
stephan-nordnes-eriksen /
Last active Mar 8, 2021
Performance testing different Key-Value stores in Ruby

For a project I am on I need to use a key-value store to converts file-paths to fixnum IDs. The dataset will typically be in the range of 100 000 to 1 000 000. These tests use 305 000 file paths to fixnum IDs.

The Different Key-Value stores tested are:

Daybreak: "Daybreak is a simple and very fast key value store for ruby" GDBM: GNU dbm. "a simple database engine for storing key-value pairs on disk." DBM: "The DBM class provides a wrapper to a Unix-style dbm or Database Manager library" PStore: "PStore implements a file based persistence mechanism based on a Hash. "

Out of these, all except Daybreak are in the Ruby standard library.

View var_dump.lua
local function string(o)
return '"' .. tostring(o) .. '"'
local function recurse(o, indent)
if indent == nil then indent = '' end
local indent2 = indent .. ' '
if type(o) == 'table' then
local s = indent .. '{' .. '\n'
local first = true
pithyless / integer.rb
Created Mar 24, 2014
Ruby Integer::MAX and Integer::MIN
View integer.rb
class Integer
N_BYTES = [42].pack('i').size
MAX = 2 ** (N_BITS - 2) - 1
MIN = -MAX - 1
p Integer::MAX #=> 4611686018427387903
p Integer::MAX.class #=> Fixnum
p (Integer::MAX + 1).class #=> Bignum
nathancolgate / mime_types.rb
Last active Nov 18, 2018 — forked from ream88/excel_template_handler.rb
Example demonstrating the use of writeexcel gem in rails 3.2
View mime_types.rb
# config/initializers/mime_types.rb
Mime::Type.register "application/", :xls
pitch-gist / gist:2999707
Created Jun 26, 2012
HTML: Simple Maintenance Page
View gist:2999707
<!doctype html>
<title>Site Maintenance</title>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }