Skip to content

Instantly share code, notes, and snippets.

@zillou
zillou / bijective.rb
Created September 20, 2016 07:45 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@zillou
zillou / newrelic_instrumenter.rb
Created July 5, 2017 08:03 — forked from nettofarah/newrelic_instrumenter.rb
sample newrelic instrumenter for graphql-ruby
# NewRelic instrumenter for GraphQL-ruby
#
# In your controller:
# ::NewRelic::Agent.add_custom_attributes({
# user_id: @user.try(:id),
# query_string: @query_string,
# query_arguments: @query_variables
# })
#
# @document = self.class.trace_execution_scoped(["GraphQL#parse"]) do
unbind C-b
set -g prefix C-s
bind-key -r C-s send-prefix
set -sg escape-time 0
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
bind-key -n C-h select-pane -L
bind-key -n C-j select-pane -D
@zillou
zillou / tasks.ex
Last active November 9, 2018 07:55
Distillery migrate command for ecto 3.0
defmodule MyApp.Release.Tasks do
@app :my_app
@start_apps [:logger, :ssl, :postgrex, :ecto_sql, :telemetry]
@repos Application.get_env(@app, :ecto_repos, [])
def migrate do
start_services()
run_migrations()
stop_services()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Barcode Printer Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/barcodes/JsBarcode.code128.min.js"></script>
<script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>