Skip to content

Instantly share code, notes, and snippets.

View Eunoia's full-sized avatar
🍍
bring the hustle

Evan R Eunoia

🍍
bring the hustle
View GitHub Profile
@Eunoia
Eunoia / itemprops.js
Last active August 29, 2015 14:22
Get the itemprop after javascript blasts away fetched html, and og:tags
jQuery.get(document.location.href, function(html) {
itemprops = Array.prototype.slice.call(jQuery(html).find("[itemprop]"))
properties = itemprops.reduce(function(memo, curr) {
if (curr.tagName == "META") {
memo[curr.attributes.getNamedItem('itemprop').value] = curr.attributes.getNamedItem('content').value
} else {
memo[curr.attributes.getNamedItem('itemprop').value] = curr.innerText.trim();
}
return memo;
}, {})
@Eunoia
Eunoia / static_site.rake
Created March 12, 2015 16:52
Turn rails into a static site.
namespace :static do
desc 'Generate static site in ./out/ directory'
task :generate do
Dir.mkdir 'out' unless File.exist? 'out'
Dir.chdir 'out' do
`wget -mnH http://localhost:3000/`
end
`rsync -ruv --exclude=.svn/ public/ out/`
end
@Eunoia
Eunoia / Gulpfile.js
Created November 19, 2014 17:43
Deploy your wintersmith generated static site to amazon S3
var fs = require('fs');
var gulp = require('gulp');
var runWintersmith = require('run-wintersmith');
var s3 = require("gulp-s3");
var options = { headers: {'Cache-Control': 'public'} }
gulp.task('default', function() {
console.log('`gulp deploy` to deploy')
});
@Eunoia
Eunoia / unclaimed.rb
Created October 5, 2013 21:06
Just a little class to programmatically look up unclaimed property for californians.
require 'nokogiri'
require 'open-uri'
require 'pry'
require 'net/http'
require 'net/https'
class UnclaimedProperty
attr_accessor :lname, :fname, :middle, :city
attr_reader :results, :more_results_than_shown
def initialize(options)
@Eunoia
Eunoia / pre-commit
Last active December 24, 2015 05:09 — forked from lsaffie/pre-commit
#!/bin/bash
# echo $
#This is good j
git diff --cached | grep -i "^\+[^#]*debugger" &&
# git diff --cached --name-only --diff-filter=ACM
exit 1
# Pre commit hook that prevents FORBIDDEN code from being commited.
# Add unwanted code to the FORBIDDEN array as necessary
@Eunoia
Eunoia / word_hash.rb
Created January 3, 2013 01:19
My version of word_hash.rb I use for the classifier(https://github.com/cardmagic/classifier). It does not remove stop words, nor does it stem words. It also adds bi-grams to the bag of words(lines 21-28). This file lets the classifier look at the corpus more holistically, acknowledging that a corpus is not necessarily a bag of words, but that wo…
# Author:: Lucas Carlson (mailto:lucas@rufy.com)
# Copyright:: Copyright (c) 2005 Lucas Carlson
# License:: LGPL
# These are extensions to the String class to provide convenience
# methods for the Classifier package.
class String
# Removes common punctuation symbols, returning a new string.
# E.g.,
@Eunoia
Eunoia / colors.rb
Last active December 10, 2015 11:08
class String
{
:reset => 0,
:bold => 1,
:dark => 2,
:underline => 4,
:blink => 5,
:negative => 7,
:black => 30,
:red => 31,
@Eunoia
Eunoia / LocationHistory.coffee
Created November 5, 2012 17:57
A class that logs locations using HTML5 geolocation
window.randomly = () -> (Math.round(Math.random())-0.5)
Number::toRadians = () -> @*2*Math.PI/360
class LocationHistory
constructor: (name = "Name", load = false, onUpdate) ->
if not navigator.geolocation
return "not supported"
@name = name
@times = []
@locations = []