Skip to content

Instantly share code, notes, and snippets.

View michaelachrisco's full-sized avatar
🛰️
Learning new things!

Michael Chrisco michaelachrisco

🛰️
Learning new things!
View GitHub Profile
@seanh
seanh / ConcreteObservable.java
Created March 13, 2009 19:26
Observer design pattern in java
package observer;
import java.util.Set;
import java.util.HashSet;
public class ConcreteObservable<T> implements Observable<T> {
private Set<Observer<T>> observers = new HashSet<Observer<T>>();
public void addObserver(Observer o) {
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rpavlik
rpavlik / fix_homebrew.rb
Created January 6, 2011 20:32 — forked from mxcl/install_homebrew.markdown
Fix permissions on /usr/local for Homebrew
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@hiltmon
hiltmon / development_profiler.rb
Created February 28, 2012 03:55
Simple class to wrap a profile run around some code
class DevelopmentProfiler
def self.prof(file_name)
RubyProf.start
yield
results = RubyProf.stop
# Print a flat profile to text
File.open "#{Rails.root}/tmp/performance/#{file_name}-graph.html", 'w' do |file|
@Gen2ly
Gen2ly / vim2html
Created May 31, 2012 17:10
Create HTML code from Vim syntax highlighting (for use in coloring scripts)
#!/bin/bash
# Create HTML-colored code from Vim syntax highlighting
filename=$@
background=light
colorscheme=beauty256
#colorscheme=simple256
#colorscheme=peaksea
# Display usage if no parameters given
@uriHeart
uriHeart / gist:3031323
Created July 2, 2012 05:50
List<Map<String,string>> create excel
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@jrmoran
jrmoran / app.js
Created October 23, 2012 12:50
AngularJS - basic async request
var App = angular.module('App', []);
App.controller('TodoCtrl', function($scope, $http) {
$http.get('todos.json')
.then(function(res){
$scope.todos = res.data;
});
});
@JohnEmhoff
JohnEmhoff / demo.py
Last active December 15, 2015 16:09
Quick demo of some new NLP features in the Embedly API
import sys
import json
import urllib
import requests
def reddit(sub):
"""
Retrieve the json representation of the given subreddit
@mikeatlas
mikeatlas / new_invitation.html.erb
Last active April 17, 2022 19:36
How to invite users in active admin with devise_invitable
<!-- /app/views/admin/users/new_invitiations.html.erb -->
<h2>Send invitation</h2>
<%= form_for @user, :url => send_invitation_admin_users_path do |f| %>
<table style='width: 50%'>
<tr>
<td><%= f.label :first_name %></td>
<td><%= f.text_field :first_name %></td>
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active May 28, 2024 17:41
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: