Skip to content

Instantly share code, notes, and snippets.

View Geekfish's full-sized avatar
🐝
... 🐝 ... 🐝 ... 🐝 ... 🐝

Eleni Lixourioti Geekfish

🐝
... 🐝 ... 🐝 ... 🐝 ... 🐝
View GitHub Profile
@Geekfish
Geekfish / keybase.md
Created November 18, 2015 23:19
keybase.md

Keybase proof

I hereby claim:

  • I am geekfish on github.
  • I am eleni (https://keybase.io/eleni) on keybase.
  • I have a public key is ASAWPKZENy4gxWlP7B4wwYiqdWNfI6lSZ92flOx2Yk9Niwo

To claim this, I am signing this object:

@Geekfish
Geekfish / twig-commit.sh
Last active November 2, 2015 16:54
Twig extensions
#!/bin/sh
# Usage: `twig commit "<your message>"`
git commit -m "$*
Fixes: [`twig jira`](https://tictrac.atlassian.net/browse/`twig jira`)"
@Geekfish
Geekfish / 0_reuse_code.js
Created October 14, 2015 16:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Geekfish
Geekfish / json_to_python.py
Last active August 29, 2015 14:03
JSON to Python
import json, pyperclip, pprint
json_content = json.loads(pyperclip.paste())
pprint.pprint(json_content)
pyperclip.copy(pprint.pformat(json_content))
@Geekfish
Geekfish / order_by_random.py
Last active March 5, 2019 10:41
Postgres order by rand
"""
This is to allow grabing a random set of rows,
in a repeatable way (for example, if you need to ensure that
a user always sees the same "random" set of results).
Method one sets the seed in Postgres.
It's using order by RANDOM(), so it can be extremely slow
for large querysets.
Method two is significantly faster, as we are generating
@Geekfish
Geekfish / template_variables.py
Created December 18, 2013 17:37
Extract variable names from template
from django.template import VariableNode
from django.template.loader_tags import ExtendsNode
def _get_template_variables(template):
"""
Extracts all the variable node tokens of the given template.
This gets worked out recursively by extracting nodes from possible
parent templates via the extension nodes.
"""
@Geekfish
Geekfish / url_monkey_patch.py
Created December 5, 2013 21:28
The only way I found to make urls monkey patching work in a TestCase
class MyTestCase(TestCase):
urls = 'my_app.urls' # This is the default urls module
def setUp(self):
the_monkey_patching()
def tearDown(self):
the_cleanup()
@Geekfish
Geekfish / comma_comma_or.py
Created November 15, 2013 14:18
"a, b, c ... y or z"
import string
' or '.join((', '.join(string.lowercase[:-1]), string.lowercase[-1]))
#!/bin/bash
echo "This script will rebuild a Debian style package (deb) of latest stable"
echo "Nginx. The original deb is from nginx.org apt repository."
echo
echo "This will prompt you yes or no on a few changes to the build as well as"
echo "it will compile and package the latest Google NGX Pagespeed module."
echo
echo "This is built and tested on Ubuntu 12.04 LTS, fresh OS install."
echo "There are no guarantees, and I take no liability if it breaks, but it"
@Geekfish
Geekfish / postgresql-tunnel.pl
Last active December 25, 2015 21:29
Create an ssh tunnel to a postgres db server
#!/usr/bin/perl
# PostgreSQL Tunnel Tool for Mac OS X and Linux
# Copyright (c) 2010 Linode, LLC
# Author: Philip C. Paradis <pparadis@linode.com>
# Usage: postgresql-tunnel.pl [start|stop]
# Access a PostgreSQL database server via an SSH tunnel.
$local_ip = "127.0.0.1";
$local_port = "5433";