Skip to content

Instantly share code, notes, and snippets.

<!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/jsbarcode@3.11.0/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>
@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()
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 / 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
@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 / gist:fc70022928dea8a2a204
Last active August 30, 2015 07:06 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@zillou
zillou / navigating-ruby-files.md
Created July 20, 2014 02:52
Navigating Ruby Files with Vim

Navigating Ruby Files with Vim - The Cheat Sheet

Precision motions for Ruby

Look up Ruby motions by running :help ruby-motion.

command effect
@zillou
zillou / fake_set.rb
Last active August 29, 2015 13:56
Fake set implementation in Ruby
# filename: spec/fake_set_spec.rb
require 'spec_helper'
require 'fake_set'
describe FakeSet, '#union' do
it "unions elements of two set" do
set1 = FakeSet.new([1, 2, 3])
set2 = FakeSet.new([3, 4, 5])
expect(set1.union(set2).data).to eq [1, 2, 3, 4, 5]
@zillou
zillou / gist:9318757
Last active August 29, 2015 13:56
Set operations in Ruby
# filename spec/fake_set_spec.rb
require 'spec_helper'
require 'fake_set'
describe FakeSet, '#union' do
set1 = FakeSet.new(1, 2, 3)
set2 = FakeSet.new(3, 4, 5)
expect(set1.union(set2)).to eq FakeSet.new(1, 2, 3, 4, 5)
def nav_link_to(link_text, link_path)
class_name = current_page?(link_path) ? 'selected' : ''
content_tag(:li, class: class_name) do
link_to link_text, link_path
end
end