Skip to content

Instantly share code, notes, and snippets.

View harmesy's full-sized avatar

Matt Harmes harmesy

View GitHub Profile
@harmesy
harmesy / Vagrantfile
Created February 27, 2016 04:58
Rails Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 3000, host: 3000
# Create a private network, which allows host-only access to the machine
# using a specific IP.
@harmesy
harmesy / gist:6275520
Created August 19, 2013 23:48
Easy appearing top menu. Becomes visible after scrolling below the header.
(function($) {
'use strict';
var $window = $(window);
$.fn.appearingMenu = function() {
var targetElement = $('header');
var menuElement = $(this);
menuElement.hide();
.progress {
border-radius: 0;
}
@harmesy
harmesy / class_structure.js
Created April 16, 2013 20:47
Quasi-class structure in JS. Allows for inheritance.
var Class = function() {
var klass = function() {
this.init.apply(this, arguments);
}
// provide access to parent
//klass.prototype.parent = klass;
// called if the inheriting class doesn't override
klass.prototype.init = function() { };
@harmesy
harmesy / classes.js
Created April 15, 2013 17:38
Just playing around with creating quasi-classical objects in JS. The larger and smaller objects aren't the most readable in the world, just some messing around.
#!/usr/bin/env node
Object.prototype.createClass = function(obj) {
var self = {};
var publicInterface = (obj['inherits'] && obj['inherits']()) || {};
return (function() { return obj.func(self, publicInterface) });
}
var larger = Object.createClass({ func: function(self, publicInterface) {
self.largerVar = "Larger";
@harmesy
harmesy / app.rb
Created April 9, 2012 22:46
Simple mustache support for the cuba microframework (cuba.is)
require 'cuba'
require 'mustache'
require 'mustache_on_cuba'
Cuba.use Rack::Session::Cookie
Cuba.plugin MustacheOnCuba
Cuba.settings[:mustache] = {
views: File.join(File.dirname(__FILE__), "views"),
@harmesy
harmesy / chat.rb
Created April 2, 2012 16:30
Simple EventMachine chat server
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
class Server
attr_accessor :connections
def initialize
@connections = []
@harmesy
harmesy / word_generator.rb
Created April 1, 2012 21:43
Grab a random word. For when you're too lazy to be creative.
#!/usr/bin/env ruby
word_list = []
generate_word = true
File.open("/usr/share/dict/words") do |words|
words.each { |word| word_list << word.strip }
end
puts "Grabbing a random word:"