Skip to content

Instantly share code, notes, and snippets.

View seveibar's full-sized avatar
💭
twitter dms or mentions to get my attenion!

Severin Ibarluzea seveibar

💭
twitter dms or mentions to get my attenion!
View GitHub Profile
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@janogarcia
janogarcia / haml_partials.haml
Created May 3, 2012 11:28
HAML Partials wihout Rails (useful for LiveReload)
/ A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails
/ Useful when using tools like LiveReload http://livereload.com/
/ but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials)
/ It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973
/ Check out the Jade version https://gist.github.com/2593727
%html
%body
%header
= Haml::Engine.new(File.read('/path/to/your/partial.haml')).render
@ubermajestix
ubermajestix / inspector.rb
Created September 5, 2012 20:35
Override inspect on ruby objects
# When an RSpec test like this fails,
#
# @my_array.should == [@some_model, @some_model2]
#
# RSpec will call inspect on each of the objects to "help" you figure out
# what went wrong. Well, inspect will usually dump a TON OF SHIT and make trying
# to figure out why `@my_array` is not made up of `@some_model` and `@some_model2`.
#
# This little module and technique helps get around that. It will redefine `inspect`
# if you include it in your model object.

how to into git (and GitHub)

This is a handy reference for setting up and using git to contribute to projects on GitHub. It is by no means a complete guide to using git; use http://gitref.org for that.

Update: This site provides some excellent visualizations of what various git commands do. Highly recommended.

basics

setup

First run the following commands, using your real name and GitHub email address:

@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@andykais
andykais / fire.sh
Last active August 29, 2015 14:17
I use with run on change to auto update a web app in the current directory
#!/bin/bash
xdotool search --name firefox key --window %@ F5
@wldcordeiro
wldcordeiro / h.js
Created April 26, 2016 18:25
React h() Function
/* eslint no-param-reassign:0 */
import React from 'react';
import _ from 'lodash';
const classIdSplit = /([\.#]?[a-zA-Z0-9_:-]+)/;
const notClassId = /^\.|#/;
export function h(tagName, properties, children = []) {
/**
@tomazzaman
tomazzaman / README.md
Last active April 19, 2024 17:01
Kill supervisor on Docker when any of the services fail

Killing supervisor if any of it's child processes fail

The trick is to only register the listener for events that indicate failure, namely

  • PROCESS_STATE_STOPPED
  • PROCESS_STATE_EXITED
  • PROCESS_STATE_FATAL

Once they do, we should send a SIGQUIT to Supervisor.

@zthomas
zthomas / intercom-delete-old-users.js
Last active May 1, 2023 15:28
Script to delete and clear old users from intercom. Useful for lowering the monthly bill
// License: MIT, feel free to use it!
const Intercom = require('intercom-client');
const appId = 'APP_ID'
const apiKey = 'APP_KEY'
const client = new Intercom.Client(appId, apiKey);
const async = require('async-q')
//REF: https://developers.intercom.com/reference#iterating-over-all-users
//WARNING: you can only have one scroll working at once. you need to wait for that scroll to clear to try again
@abtris
abtris / client.js
Created January 9, 2017 19:13
Connect to Postgres/Redshift over Socks proxy.
var pg = require('pg'),
url = require('url'),
SocksConnection = require('socksjs');
var db = url.parse(process.env.REDSHIFT_CONN_STRING),
dbAuth = db.auth,
dbUsername = dbAuth.split(':')[0],
dbPassword = dbAuth.split(':')[1],
dbName = db.pathname.replace('/', '');