Skip to content

Instantly share code, notes, and snippets.

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

Eleni Lixourioti Geekfish

🐝
... 🐝 ... 🐝 ... 🐝 ... 🐝
View GitHub Profile
@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 / oscar-apps-customer-forms.py
Created March 1, 2012 18:00
Customer form suggestion
def clean(self):
if not self.cleaned_data['date_from'] and not self.cleaned_data['date_to']:
raise forms.ValidationError(_("At least one date field is required."))
return super(SearchByDateRangeForm, self).clean()
@Geekfish
Geekfish / euler-20.cj
Created March 30, 2012 01:04
Project Euler 20
(reduce + (map #(Character/getNumericValue %) (seq (str (reduce * (range (bigint 1) (bigint 100)))))))
@Geekfish
Geekfish / fibo.cj
Created March 30, 2012 01:05
Clojure nth Fibonacci
(nth (map first (iterate (fn [[a b]] [b (+ a b)]) (double-array [1 1]))) 1475)
@Geekfish
Geekfish / split.py
Created May 15, 2012 16:12
Split a string every x characters
def split_per_x_chars(m, step):
return [m[x:x+step] for x in range(0, len(m), step)]
split_per_x_chars('abcdefghijklmnop', 3)
# ['abc', 'def', 'ghi', 'jkl', 'mno', 'p']
@Geekfish
Geekfish / counters.py
Last active October 13, 2015 23:57
Create a dictionary of counters that defaults to 0 with defaultdict
from collections import defaultdict
counters = defaultdict(int)
counters['foo'] += 1
counters['foo']
# Out: 1
counters['bar']
# Out: 0
def most_common_problems():
problems = (
"People that come from PHP",
"Coming up with variable names",
"Off-by-one index calculations",
)
print "The three most common problems in programming are:"
for x in range(1, len(problems)):
print "* %s" % problems[x]
@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 / 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 / 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: