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
@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
@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/
@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/
@kristianmandrup
kristianmandrup / Converting libraries to Ember CLI addons.md
Last active April 21, 2023 17:14
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.

@jpadilla
jpadilla / components.my-component.js
Last active April 21, 2023 17:14
Component Lifecycle Hooks
import Ember from 'ember';
export default Ember.Component.extend({
didInitAttrs(options) {
console.log('didInitAttrs', options);
},
didUpdateAttrs(options) {
console.log('didUpdateAttrs', options);
},
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@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
@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