Skip to content

Instantly share code, notes, and snippets.

View mfpiccolo's full-sized avatar

Mike Piccolo mfpiccolo

View GitHub Profile
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@jmervine
jmervine / gist:2052468
Created March 16, 2012 20:30
Rails: Dynamic Model from JSON sans DB
require 'net/http'
class Item
#replaced with dynamic initialization below
#attr_reader :id, :user, :state
#
#
# Sample JSON
#
# [{ "id":1, "user":"john", "state":"active" },
# { "id":2, "user":"jane", "state":"inactive" },
@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@steveklabnik
steveklabnik / puts_test.rb
Created May 1, 2013 22:15
testing puts in minitest
require 'minitest/autorun'
class CaptureIoTest < MiniTest::Unit::TestCase
def test_puts
out, err = capture_io do
puts "hey"
end
assert_equal "hey\n", out
end
@facultymatt
facultymatt / roles_invesitgation.md
Last active April 16, 2024 09:31
Roles and permissions system for Nodejs
@andelf
andelf / simple_chat.rs
Last active April 13, 2024 15:09
Simple Socket Chat Server in Rust. (TcpListener, TcpStream, SharedChan, RWArc)
extern mod sync;
// str op trait
use std::str::StrSlice;
// for tcp listen
use std::io::{TcpListener, TcpStream};
use std::io::net::ip::SocketAddr;
// for trait
use std::io::{Listener, Writer, Acceptor, Buffer};
// for spawn
@vjpr
vjpr / README.md
Last active June 27, 2022 10:01
RPC for Chrome Packaged App to allow communication between sandbox and privileged environment

ChromeRPC

I will eventually turn this into a bower module when I have time with tests and the whole shebang.

Usage

background.html

@myitcv
myitcv / time_travel_trigger.sql
Last active March 8, 2022 06:50
Trigger-based equivalent of old PostgreSQL time travel module - see https://blog.myitcv.io/2014/02/25/row-level-version-control-with-postgresql.html for more details
/*
Copyright (c) 2015 Paul Jolly <paul@myitcv.org.uk)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@torgeir
torgeir / method-missing-proxy.js
Last active March 11, 2024 01:59
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
@darky
darky / virtual_class.coffee
Last active January 9, 2023 21:37
Multiple inheritance in Coffeescript. This little helper make proper prototype chain and call `super`. Existing classes in chain not violated, uses theirs "projections". Мультинаследование в Coffeescript. Этот маленький хелпер создаёт корректную цепочку прототипов с правильным вызовом `super`. Существующие классы не портятся, используются их "пр…
virtual_class = (classes...)->
classes.reduceRight (Parent, Child)->
class Child_Projection extends Parent
constructor: ->
# Temporary replace Child.__super__ and call original `constructor`
child_super = Child.__super__
Child.__super__ = Child_Projection.__super__
Child.apply @, arguments
Child.__super__ = child_super