Skip to content

Instantly share code, notes, and snippets.

View codelahoma's full-sized avatar

Rod Knowlton codelahoma

View GitHub Profile
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@gregtatum
gregtatum / functions-state.js
Created January 20, 2015 14:18
Storing state in functions
/*
* Different ways to save state or configure a function
*
*/
//-------------------------------------------------
// Typical prototypical inheritance
var Talker = function( phrase ) {
this.phrase = phrase;
@omz
omz / SSHClient.py
Created January 7, 2015 21:21
SSHClient.py
# Very simple SSH client for Pythonista
import paramiko
import console
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
host = console.input_alert('Connect to')
user, passwd = console.login_alert('Login')
ssh.connect(host, username=user, password=passwd)
print 'Connected to %s. Type `exit` to disconnect.' % host
@ttscoff
ttscoff / sizeup.bash
Created January 5, 2015 16:48
A shell function for viewing file sizes and totals within a nested directory structure
__sizeup_build_query () {
local bool="and"
local query=""
for t in $@; do
query="$query -$bool -iname \"*.$t\""
bool="or"
done
echo -n "$query"
}
@paf31
paf31 / unsession.md
Last active August 29, 2015 14:06
PureScript Unsession
@noahpeters
noahpeters / .gitignore
Last active August 29, 2015 14:04 — forked from rjmunro/.gitignore
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
platforms/android/CordovaLib/ant-build/
platforms/android/CordovaLib/ant-gen/
platforms/android/ant-build/
platforms/android/ant-gen/
@Kartones
Kartones / postgres-cheatsheet.md
Last active March 31, 2026 04:12
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

Install

npm install funcoffee

Require

require('funcoffee').expose global
@buddylindsey
buddylindsey / awsup.py
Created April 8, 2014 19:29
Automated Postgres Backup
import sys
import boto
from boto.s3.connection import S3Connection
from boto.s3.key import Key
file_name = sys.argv[1]
AWSAccessKeyId = ''
AWSSecretKey = ''
@codelahoma
codelahoma / undermore.js
Last active August 29, 2015 13:57
A little utility to extend underscore with a couple of methods I wanted, `isCollection` and `complement`, as well as `isNot*` functions to match the `is*` functions.
module.exports = (function () {
var _ = require('underscore');
var isCollection = function(item) {
return (_.isObject(item) || _.isArray(item) || _.isArguments(item));
};
var complement = function(fn) {
return function() {