Skip to content

Instantly share code, notes, and snippets.

View daGrevis's full-sized avatar
⌨️
Keyboard operator

Raitis Stengrevics daGrevis

⌨️
Keyboard operator
View GitHub Profile
@daGrevis
daGrevis / ascii_letters.py
Created August 14, 2012 08:23
from string import ascii_letters # deprecated
>>> ''.join([chr(letter) for letter in range(97, 123) + range(65, 91)])
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
@daGrevis
daGrevis / gist:3684388
Created September 9, 2012 13:43
Because having less than 245 dependencies is too mainstream
dagrevis@itsmintitsmintwoot ~ # aptitude install skype
The following NEW packages will be installed:
bluez-alsa:i386{a} gcc-4.6-base:i386{a} glib-networking:i386{a} gstreamer0.10-plugins-base:i386{a} gstreamer0.10-plugins-good:i386{a} gstreamer0.10-x:i386{a} gtk2-engines:i386{a} gtk2-engines-murrine:i386{a}
gtk2-engines-oxygen:i386{a} gtk2-engines-pixbuf:i386{a} gvfs:i386{a} gvfs-libs:i386{a} ia32-libs{a} ia32-libs-multiarch:i386{a} ibus-gtk:i386{a} lib32asound2{a} lib32gcc1{a} lib32stdc++6{a} libaa1:i386{a} libacl1:i386{a}
libaio1:i386{a} libao-common{a} libao4:i386{a} libasn1-8-heimdal:i386{a} libasound2:i386{a} libasound2-plugins:i386{a} libasyncns0:i386{a} libatk1.0-0:i386{a} libattr1:i386{a} libaudio2:i386{a} libaudiofile1:i386{a}
libavahi-client3:i386{a} libavahi-common-data:i386{a} libavahi-common3:i386{a} libavc1394-0:i386{a} libbz2-1.0:i386{a} libc6:i386{a} libc6-i386{a} libcaca0:i386{a} libcairo-gobject2:i386{a} libcairo2:i386{a}
libcanberra-gtk-module:i386{a} libcanberra-gtk0:i386{a}
@daGrevis
daGrevis / gist:3755493
Created September 20, 2012 11:59
Django, WTF? :D
[dagrevis@localhost myproject]$ bin/python myproject/manage.py test legacy
Creating test database for alias 'default'...
Creating test database for alias 'report_db'...
Got an error creating the test database: (1007, "Can't create database 'test_myapp'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_myapp', or 'no' to cancel: yes
Destroying old test database 'report_db'...
Got an error recreating the test database: (1008, "Can't drop database 'test_myapp'; database doesn't exist")
@daGrevis
daGrevis / pretty_html.py
Created October 24, 2012 08:15
Pretty HTML
def pretty_html(html):
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(html)
return soup.prettify()
@daGrevis
daGrevis / calculate_depth.py
Created November 1, 2012 21:18
Calculates depth of comments w/ recursion.
@staticmethod
def calculate_depth(comments, comment=None, depth_level=1):
"""
@brief Calculates depth of comments w/ recursion.
@param comments: Comments
@param comment: Comment (for recursion, isn't used from outside)
@param depth_level: Depth level (for recursion, isn't used from outside)
@return Comments /w depth level
"""
for the_comment in comments:
@daGrevis
daGrevis / prettify_html.py
Created November 14, 2012 14:00
Prettify HTML
#!/usr/bin/env python2
import sys
import argparse
import BeautifulSoup
def pretty_html(html):
soup = BeautifulSoup.BeautifulSoup(html)
return soup.prettify()
@daGrevis
daGrevis / progressive.py
Created November 30, 2012 08:47
List of progressive numbers (just to warm head)
def is_progressive(number):
digits = map(int, list(str(number)))
for i, digit in enumerate(digits):
if i != 0:
if digit <= digits[i - 1]:
return False
return True
def next_progressive(number):
@daGrevis
daGrevis / wait_or_kill.py
Created December 11, 2012 09:57
wait_or_kill.py
import sh
import signal
class TooLongToWait(Exception):
pass
def alarm_handler(signum, frame):
raise TooLongToWait
@daGrevis
daGrevis / tuple.py
Created December 13, 2012 16:11
Small thing that is very annoying
foo = (
"lorem",
"ipsum"
"sit",
"dolor",
)
print foo[2] == "sit" # False
foo = (
;(function($) {
$(function() {
"use strict"
var bookmarks = [
{url: "http://google.com/", title: "Google.com"},
{url: "http://dagrevis.lv/", title: "daGrevis.lv"}
]
var Bookmark = Backbone.Model.extend({
defaults: {
"times_visited": 0