Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
@rubysolo
rubysolo / file_size_hist.sh
Created December 12, 2016 17:56
File size histogram
find . -type f -print0 | xargs -0 ls -l | awk '{ n=int(log($5)/log(2)); if (n<10) { n=10; } size[n]++ } END { for (i in size) printf("%d %d\n", 2^i, size[i]) }' | sort -n | awk 'function human(x) { x[1]/=1024; if (x[1]>=1024) { x[2]++; human(x) } } { a[1]=$1; a[2]=0; human(a); printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2) }'
@rubysolo
rubysolo / meme.rb
Created December 14, 2015 21:18 — forked from marcinbunsch/meme.rb
Meme generator using local images
#!/usr/bin/env ruby
#
# OMG THIS CODE IS SO UGLY
# but...
# IT WORKS!!
#
# Hacked together by http://github.com/marcinbunsch
#
# This assumes the following:
# - That you're on a Mac
@rubysolo
rubysolo / page.html
Created October 23, 2015 14:59
delegated binding
<div>
<button id="the-button">Hey</button>
</div>
<script>
$(document).on('click', '#the-button', function(e) {
// handler is bound to document, but only fires if event originated from #the-button
})
</script>
@rubysolo
rubysolo / config.exs
Created October 11, 2015 19:35 — forked from limhoff-r7/config.exs
nginx + phoenix configuration to server phoenix behind nginx at path 'phoenix'. nginx rewrites incoming URLs to strip the /phoenix, while the config.exs for phoenix ensures URLs are prefixed with /phoenix using the config.url.path
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# Configures the namespace used by Phoenix generators
config :my_app,
app_namespace: MyApp
@rubysolo
rubysolo / up-and-running-with-edeliver-on-do.md
Created October 7, 2015 22:45 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys
module HideDeleted
def hide_deleted
scope :existing, -> { where(deleted_at: nil) }
scope :deleted, -> { where('deleted_at IS NOT NULL') }
define_method :deleted? do
deleted_at.present?
end
define_method :destroy do
@rubysolo
rubysolo / unsafe_chrome.sh
Created June 1, 2015 20:37
create unsafe chrome app
#!/bin/bash
set -x
# usage:
# ./unsafe_chrome.sh Developer #=> creates a "Google Chrome Developer" app
PROFILE_NAME=$1
mkdir -p "/Applications/Google Chrome $1.app/Contents/MacOS"
F="/Applications/Google Chrome $1.app/Contents/MacOS/Google Chrome $1"
@rubysolo
rubysolo / a.rb
Last active August 29, 2015 14:20 — forked from ahoward/a.rb
segment = Segment::TwitterFollowers.create(
name: "Demo Twitter Followers Segment #{ timestamp }",
account: account,
client: client,
definition_data: "@nike\n"
)
VS
# $Id: vim-keys.conf,v 1.1 2010/01/17 16:24:09 nicm Exp $
#
# vim-keys.conf, v1.0 2010/01/15
#
# By Daniel Thau. Public domain.
#
# This configuration file binds many vi- and vim-like bindings to the
# appropriate tmux key bindings. Note that for many key bindings there is no
# tmux analogue.
set -g prefix C-a
@rubysolo
rubysolo / assets.rake
Created March 19, 2015 17:23
create non-digested assets
namespace :assets do
task nondigest: :"assets:environment" do
logger = Logger.new($stderr)
asset_path = Rails.root.join('public', MyRailsApp::Application.config.assets.prefix.gsub(%r{^/}, ''))
manifest_path = Dir.glob(asset_path.join('manifest-*.json')).first
manifest_data = JSON.load(File.new(manifest_path))
manifest_data["assets"].each do |logical_path, digested_path|
full_digested_path = asset_path.join(digested_path)