Skip to content

Instantly share code, notes, and snippets.

View napcs's full-sized avatar

Brian P. Hogan napcs

View GitHub Profile
@napcs
napcs / tmux.sh
Created August 20, 2013 23:18
.tmux.conf
curl -k https://raw.github.com/napcs/dotfiles/master/.tmux.conf > .tmux.conf
#!/bin/bash
PREFIX=$1
COUNT=$2
PASS=$3
# validation
if [ $# -ne 3 ]; then
echo "Usage: $0 <prefix> <count> <password>"
exit
@napcs
napcs / messageArea.js
Created June 2, 2013 19:12
Sometimes I need a way to view messages easily on devices where the console doesn't work. So I use this. It's a little crude but it works really well on tablets and phones when I need to watch events.
/**
@method __message
@param text {string} The text you want to display
@param [append=null] {boolean} Whether the message should append to the box or not.
@example
$("a").on("click", function(event){
window.__message("You clicked a thing!");
});
*/
window.__message = function(text, append){
@napcs
napcs / server.js
Created February 20, 2013 19:22
Simple web server with MIME type support and directory listing support for use in HTML5 and CSS3 Second Edition.
// Simple static server with MIME based on https://gist.github.com/906395
// Definitely not for production use.
var path = require('path');
var http = require("http");
var fs = require('fs');
var url = require("url");
try{
var mime = require('mime');
} catch(error) {
@napcs
napcs / video.md
Created September 8, 2012 16:25
Video project

Intro to Programming video

I want to make a video to show my class of would-be IT people. If you write code, would you send me a video clip (webcam, less than 30s) with the following?

  • Introduce yourself (name, where you work)
  • Why you love what you do
  • Why you love open-source software (optional, but would be super helpful)

Email the clip (or a link I can download the clip) to bphogan at gmail and be sure to include your Twitter username so I can add that on your clip.

@napcs
napcs / stashit
Created August 19, 2012 22:30
Stashit - wrapper for WGET to snag files to my Dropbox folder
#!/bin/bash
# StashIt wraps the 'wget' command and puts files
# in my ~/Dropbox/stashit folder. It's just something
# simple but it makes my life easier because I can name
# the file myself.
#
# Example:
#
# stashit cat_hates_you http://i.imgur.com/ZCd5N.png
@napcs
napcs / Original_form.html.erb
Created August 2, 2012 19:38
fields_for counter?
<fieldset>
<% counter = 1 %> <!-- FOR SHAME! -->
<%= f.fields_for :answers do |builder| %>
<div>
<%= builder.label :text, "Answer #{counter}" %>
<%= builder.text_field :text %>
<%= builder.label :correct, "Correct" %>
<%= builder.check_box :correct %>
@napcs
napcs / gist:3191482
Created July 28, 2012 02:34
Mountain Lion installation stuff
#
brew tap homebrew/dupes
brew install apple-gcc42
export CPPFLAGS=-I/opt/X11/include
rvm install 1.8.7
rvm install 1.8.6
rvm install 1.9.3
$ gem install nokogiri | pbcopy
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/brianhogan/.rvm/rubies/ruby-1.8.7-p174/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
@napcs
napcs / screenshot.js
Created June 19, 2012 21:59 — forked from javan/screenshot.js
Create a screenshot of any URL using phantomjs (headless webkit)
//
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png
//
var system = require('system');
var url = system.args[1];
var filename = system.args[2];
var page = new WebPage();
page.open(url, function (status) {