Skip to content

Instantly share code, notes, and snippets.

View jeremywrowe's full-sized avatar
❤️
Coding

Jeremy W. Rowe jeremywrowe

❤️
Coding
View GitHub Profile
@kylegibson
kylegibson / dynupdate.sh
Created October 9, 2011 18:26
Simple bash script to update a dyndns host entry
#!/bin/bash
HOST=foo.example.com
USER=
PASS=
IPADDR=$(wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
RESULT=$(wget -q -O- "https://$USER:$PASS@members.dyndns.org/nic/update?hostname=$HOST&myip=$IPADDR&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG")
@wildlyinaccurate
wildlyinaccurate / event.js
Last active February 12, 2021 01:05
Really simple Javascript custom event system
var Event = function() {
var self = this;
self.queue = {};
self.fired = [];
return {
fire: function(event) {
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 17, 2024 15:54
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@jeremywrowe
jeremywrowe / routs_rails_console.rb
Created April 5, 2013 14:37
routes in rails console
include ActionDispatch::Routing
include Rails.application.routes.url_helpers
@jeremywrowe
jeremywrowe / cucumber_leaks.rb
Last active December 15, 2015 20:41
Show leaked instance variables in cucumber. A terrible hack but sometimes that is what ya need to do :)
$cucumber_instance_variables = []
Before do
$cucumber_instance_variables = instance_variables
end
After do
test_variables = instance_variables - $cucumber_instance_variables
message = "[WARN] the following test variables could be leaking #{leaked_variables.join(', ')}"
@jeremywrowe
jeremywrowe / too_legit.c
Last active August 11, 2016 17:52
Bringing goto statements in c back into style.
#include <stdlib.h>
#include <stdio.h>
#define too goto
int main( int argc, const char* argv[]) {
int times;
times = 0;
legit:
printf(" too legit,");
@jeremywrowe
jeremywrowe / gist:5373873
Last active December 16, 2015 03:59
Do you want to get onto your recent branchies easy? Here - ya - go. Create a new file named whatever you want, make it executable and put it in your path. From there go to your favorite project that you are working on type in whatever you named the script, and you are off to the races.
#!/usr/bin/env ruby
trap("INT") { puts "\ncatch'ya later"; exit 0 }
output = `git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format='%(refname:short)'`
branches = output.split("\n")
unless option = ARGV[0]
puts <<-MSG
@jeremywrowe
jeremywrowe / status_code.php
Last active December 20, 2015 15:19
This is an example of querying the chargify api and retrieving the status code of the response
<?php
$api_key = "";
$subdomain = "";
$handle = curl_init('https://'.$subdomain.'.chargify.com/customers/100000.json');
curl_setopt($handle, CURLOPT_USERPWD, $api_key . ":x");
curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($handle);