Skip to content

Instantly share code, notes, and snippets.

View adamloving's full-sized avatar
💭
10x Ninja Rockstar

Adam Loving adamloving

💭
10x Ninja Rockstar
View GitHub Profile
@clarkdave
clarkdave / pg_enum.rb
Last active July 18, 2019 15:37
basic support for PostgreSQL Enums in ActiveRecord - to be placed in an initializer
##
# This provides `create_enum` and `drop_enum` methods for migrations, which creates
# a Postgres ENUM type with the provided values.
#
# It'll also dump these into the schema.rb to be loaded into another DB (e.g. rake db:test:load)
#
# In order to reference the new enums as actual types, ActiveRecord needs to know about them, so
# make sure they are all represented in the `types` array below
#
# Then you can reference them in your migrations, e.g.

Auto Synchronized Backups with Bittorrent sync & a vps

1. Cloud syncing on the cheap

Two awsome things were released yesterday :

Compare this to the pricing of : dropbox pro

@adamloving
adamloving / tweet-this.js
Created November 25, 2012 00:48
Add "tweet this" links to text in a blog post
function onMouseenter(e) {
el = $(e.target);
url = 'https://twitter.com/intent/tweet?text='
url += encodeURIComponent(el.text());
url += ' ' + window.location.href;
// el.css('position', 'relative');
el.append('<a href="' + url + '" target="_blank" class="tweet-this" style="position: relative; left: 5px;">Tweet this</a>');
};
function onMouseleave(e) {
@paxan
paxan / gist:3901864
Last active October 11, 2015 18:37
A Common Crawl Experiment (moved to https://github.com/paxan/ccooo)
@yocontra
yocontra / stuff.coffee
Created April 24, 2012 07:59
Tiny window.location parser javascript/coffee-script
parseLocation = ->
out = {}
for key in window.location.search.substring(1).split "&"
pair = key.split "="
out[pair[0]] = pair[1]
return out
"""This is main.py, where the main stuff happens.
"""
import sys
import os
# lets assume your file is in /home/oli/nuke_files/main.py
#
# __file__ is a magic variable which python automatically populates, and is the
# full path to the file which is currently being executed (i.e. this one),
# so __file__ == '/home/oli/nuke_files/main.py'
@snatchev
snatchev / gist:1316470
Created October 26, 2011 14:08
resque worker devise not eager loading
❷ > QUEUE=* rake resque:work --trace
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Execute resque:setup
** Execute resque:preload
rake aborted!
No such file to load -- devise/confirmations_controller
/Users/stefan/.rvm/gems/ruby-1.9.2-p290@my-rails-project/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:306:in `rescue in depend_on'
/Users/stefan/.rvm/gems/ruby-1.9.2-p290@my-rails-project/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:301:in `depend_on'
@harleyholt
harleyholt / example-if-template.html
Created October 20, 2011 22:24
Example of Knockout Conditionally Rendered Template
<!-- Example one shows the most verbose way of specifying a template that is only rendered if someObject is defined in the current view model
This information was culled from https://github.com/SteveSanderson/knockout/blob/1.3/src/binding/defaultBindings.js#L445
-->
<script type="text/html" id="sub-example-one">
<h2 data-bind="text: title"></h2>
<p data-bine="text: description"></p>
</script>
<script type="text/html" id="example-one">
@exogen
exogen / watch
Created September 15, 2011 23:22
Generic file watcher script.
#!/bin/bash
#
# Author: Brian Beck <exogen@gmail.com>
# Usage: watch PATH COMMAND...
#
# This script watches PATH and runs COMMAND whenever PATH or a descendent
# of PATH is modified. COMMAND is everything after the first argument.
#
# If PATH is "-", then the list of paths comes from standard input.
#
@rweald
rweald / jammit.rake
Created June 1, 2011 19:58
Using Barista with Jammit to package and compile CoffeeScript
# simply run rake jammit:package to compile your coffeescript and then package up all your assets
# including the newly compiled javascripts
namespace :jammit do
task :package do
Rake::Task["barista:brew"].invoke
Jammit.package!
end
end