Skip to content

Instantly share code, notes, and snippets.

View canadaduane's full-sized avatar

Duane Johnson canadaduane

View GitHub Profile
@canadaduane
canadaduane / gist:9b37b43078ce28c53814
Created March 16, 2015 18:14
webpack node-sass error
$ fig up webpack
Recreating firesize_webpack_1...
Attaching to firesize_webpack_1
webpack_1 | nodejs v0.10.33
webpack_1 | npm WARN package.json firesize@0.2.0 No repository field.
webpack_1 |
webpack_1 | > node-sass@2.0.1 install /app/node_modules/sass-loader/node_modules/node-sass
webpack_1 | > node scripts/install.js
webpack_1 |
webpack_1 |
CmdUtils.CreateCommand({
name: "search-domain-name",
icon: "http://instantdomainsearch.com/favicon.ico",
author: {name: "Pratham Kumar", email: "pratham@pratham.name"},
description: "Checks availabilty of the domain name with com/net/org TLDs.",
homepage: "http://pratham.name/",
takes: {"example.com": noun_arb_text},
preview: function (html, q) {
var params = {name: q.text};
CmdUtils.CreateCommand({
names: ["eyes like lightning"],
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'input'} ],
author: {name: "Duane Johnson", email: "duane.johnson@gmail.com"},
license: "GPL",
description: "Opens a speed-reading window above the currently selected text.",
help: "Select some text, and then use the eyes like lightning command to start reading it.",
preview: function(pblock, args) {
require 'json'
$log_filename ||= File.expand_path(File.join("..", "ruby.log.json"), File.dirname(__FILE__))
begin
if !File.exist?($log_filename)
File.open($log_filename, "w") do |f|
f.write "["
end
end
@canadaduane
canadaduane / gist:660747
Created November 3, 2010 02:53
Feature Guessing Game
class FeatureSet
include Enumerable
def initialize(*features)
@features = features
end
def randomly_choose_one
@features[rand(@features.size)]
end
@canadaduane
canadaduane / app_path.rb
Created October 26, 2011 21:50
Sinatra app_path, similar to uri/url/to but with optional params
def app_path(path, params={})
if params.size == 0
uri(path)
else
query_string = ""
params.each_pair do |key, value|
query_string += key.to_s + '=' + escape(value.to_s)
end
uri(path) + '?' + query_string
end
@canadaduane
canadaduane / gist:3173840
Created July 25, 2012 01:27
Trouble with netrap on a Mac
$ make
gcc -c -std=gnu99 -O2 -fdata-sections -ffunction-sections -Wall -o netrap-controller.o netrap-controller.c
netrap-controller.c: In function ‘sockport’:
netrap-controller.c:151: warning: unused variable ‘port’
netrap-controller.c: In function ‘new_listen_socket’:
netrap-controller.c:410: error: ‘buf’ undeclared (first use in this function)
netrap-controller.c:410: error: (Each undeclared identifier is reported only once
netrap-controller.c:410: error: for each function it appears in.)
netrap-controller.c:414: error: ‘listen_socket’ has no member named ‘protocol’
netrap-controller.c: In function ‘new_http_socket’:
@canadaduane
canadaduane / gist:4219039
Created December 5, 2012 20:08
Make an Iterator
# Here's my method that loops over a collection and yields a block
def tardies_for_student(student_id, now=Time.zone.now)
submissions_by_student_id[student_id].each do |submission|
assignment = @assignments_by_id[submission.assignment_id]
yield build_tardy(assignment, submission, now)
end
end
# now I know I can do this...
@canadaduane
canadaduane / mount_ext3_volume.sh
Created January 4, 2013 03:24
Mounts an external drive via SSHFS+OSXFuse, using a Linux Virtual Machine to read/write to an Ext3 filesystem.
UBUNTU_IP=172.16.232.100
GUEST_DIR=/media/duane
MOUNTPOINT=/tmp/archive
if [ ! -d "$MOUNTPOINT" ]; then
echo "Mount point $MOUNTPOINT does not exist, creating..."
mkdir -p $MOUNTPOINT
fi
FIRSTDIR=`ls -1 $MOUNTPOINT`
@canadaduane
canadaduane / gist:5086019
Last active December 14, 2015 12:28
Response to Vlad's post on Patents
A succinct explanation of the history, problem, and potential solution.
Here is a chart I made from the USPTO data to see if the story you tell
matches the data. I think it clearly does:
http://db.tt/CNanl3IY
Also, note how patent volume is essentially "pre-internet" and "post-
internet" (circa 1990).