Skip to content

Instantly share code, notes, and snippets.

{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "size": 3938},
@matt-morris
matt-morris / static-rails.rb
Last active September 10, 2015 20:33 — forked from ahoward/static-rails.rb
a script that boils a rails' app into static in a fucking hurry
#! /usr/bin/env ruby
# TODO - use a server other than passenger?
# this script uses wget and passenger to crawl a rails' application in order
# to create a static build from virtually any project.
#
# it has three simple requirements, and one optional one:
#
# 1) you have the wget program installed
@matt-morris
matt-morris / boost_template.rb
Last active September 10, 2015 21:37 — forked from codespore/boost_template.rb
Rails application template
# Rails 4 Application Template
# Usage: rails new [app_name] -m [boost_template.rb] -d postgresql
# Remove normal files we don't want
remove_file "README.rdoc"
remove_file "public/index.html"
remove_file "app/assets/images/rails.png"
# Copy database.yml to sample
inside "config" do
@matt-morris
matt-morris / hashquiz.rb
Last active September 21, 2015 21:32 — forked from potatosalad/hashquiz.rb
Ruby quiz for convert hash "dot paths" into actual hash hierarchy.
#require 'rubygems'
require 'pp'
#require 'ap' # Awesome Print
class Object
# expects [ [ symbol, *args ], ... ]
def recursive_send(*args)
args.inject(self) { |obj, m| obj.send(m.shift, *m) }
end
end
@matt-morris
matt-morris / Static site capfile
Created June 2, 2016 16:00 — forked from bdeterling/Static site capfile
Example of using Capistrano for a static website
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
default_run_options[:pty] = true
# be sure to change these
set :github_user, '<github_user_name>'
set :github_application, "<repository_name>"
set :user, '<user_on_server>'
set :domain, '<server_name>'
set :application, '<domain_name_of_static_site>'
# rebuttal of http://www.try-alf.org/blog/2013-10-21-relations-as-first-class-citizen
require 'arel'
require 'sqlite3'
require 'pry'
def suppliers
@suppliers ||= Arel::Table.new(:suppliers)
end
@matt-morris
matt-morris / method-missing-proxy.js
Created October 20, 2016 13:25 — forked from torgeir/method-missing-proxy.js
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
@matt-morris
matt-morris / pubsub-simple.js
Created October 20, 2016 13:27 — forked from fatihacet/pubsub-simple.js
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@matt-morris
matt-morris / renameToHash.sh
Created November 27, 2016 06:09 — forked from SimplGy/renameToHash.sh
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
#!/bin/bash
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
#
# Constants
#
CHAR_COUNT=12
BLOCK_COUNT=6
SKIP_SIZE=3 # Every new block is sampled by skipping this amount of blocks to the next position
@matt-morris
matt-morris / snowflake2a.pde
Created January 3, 2017 19:10 — forked from anonymous/snowflake2a.pde
Math Mondays: "snowflake" drawing app
/*
Snowflake 2.0a
Open-source "snowflake" drawing app with true vector output.
Click the "save" button to create a PDF document of your snowflake,
suitable for editing in Inkscape, Corel, Illustrator, or so forth.
Written by Windell H. Oskay, www.evilmadscientist.com