This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/runhaskell | |
{- | |
DECPRECATED - Currently cabal repl provides a much better solution to this problem. | |
Use this script as a "replacement" for the ghci interpreter to | |
automatically include extensions from your cabal file. | |
Be sure to set the cabalFile and (optionally) ghciInit values in this script. | |
You may also need to update the bang line to the path of runhaskell. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'io/console' | |
require 'mechanize' | |
agent = Mechanize.new | |
# http://curl.haxx.se/ca/cacert.pem | |
agent.ca_file = 'cacert.pem' | |
puts 'Connecting to Wells Fargo...' | |
page = agent.get 'https://wellsfargo.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
def iformat(string): | |
frame = inspect.currentframe() | |
result = string.format(**dict(frame.f_back.f_globals, **frame.f_back.f_locals)) | |
del frame | |
return result | |
class Object(object): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Adds the git pull-each feature to easily pull multiple branches. | |
# Place this in a directory on your path (e.g. ~/bin). | |
set -e | |
ORIG_BRANCH=$(git branch | grep '*' | cut -c3-) | |
if [ -z "$1" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Test Data | |
drop table if exists x, y, z; | |
create temporary table x(id serial primary key, a int); | |
insert into x(a) values (1), (2); | |
create temporary table y(id serial primary key, x_id int, b int); | |
insert into y(x_id, b) values (1, 1), (2, 2), (3, 3); | |
create temporary table z(id serial primary key, x_id int, c int); | |
insert into z(x_id, c) values (1, 3), (1, 4), (2, 5); | |
-- Example - unable to group by primary key from subquery | |
with cte as ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class lazy_method(object): | |
""" Allows you to cache unhashable arguments. """ | |
@classmethod | |
def truncate(cls, obj): | |
""" Removes method cache from obj. """ | |
if hasattr(obj, '_lazy_items'): | |
del obj._lazy_items | |
def __init__(self, f): | |
def wrapped(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
def iindex(iterable, index): | |
""" Indexing for all iterables. Translates to iterable[index]. """ | |
return next(islice(iterable, index, index + 1)) | |
def example(): | |
def fibs(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.db.models.query import EmptyQuerySet, QuerySet | |
class CustomManager(models.Manager): | |
""" | |
Easily override QuerySet by setting the QuerySet and EmptyQuerySet | |
inside of the class using inheritance. | |
""" | |
EmptyQuerySet = EmptyQuerySet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=$1 | |
if [ -z "$HOST" ]; then | |
echo "Enter host IP:" | |
read HOST | |
fi | |
sudo service denyhosts stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Choice(tuple): | |
def __new__(cls, name, description, permissions): | |
return super(Choice, cls).__new__(cls, tuple((name, name))) | |
def __init__(self, name, description, permissions): | |
super(Choice, self).__init__(name, description, permissions) | |
self.description = description | |
self.permissions = permissions | |
self.name = name |
OlderNewer