Skip to content

Instantly share code, notes, and snippets.

View aruseni's full-sized avatar
🟢
Lead Python Software Engineer

aruseni

🟢
Lead Python Software Engineer
View GitHub Profile
@aruseni
aruseni / gmail-redmine-task-list.js
Created January 10, 2014 13:15
Searches for Redmine messages in the inbox and returns the links to the tasks. Use with the HTML version of GMail: https://mail.google.com/?ui=html‎
// gmail-redmine-task-list.js
//
// Searches for Redmine messages in the inbox
// and returns the links to the tasks
//
// Use with the HTML version of GMail:
// https://mail.google.com/?ui=html‎
var query = "redmine in:inbox";
var redmine_url = "https://redmine.example.com/"
import sys
import ast
from subprocess import Popen, PIPE
from django.template.loader import render_to_string
from django.conf import settings
settings.configure(
TEMPLATE_DIRS=(".",)
@aruseni
aruseni / motd.sh
Created April 14, 2014 01:35
/etc/profile.d/motd.sh — a simple script for displaying dynamic messages shown on login
# No need to redisplay it on sudo su and in screen sessions
if [ "$(id -u)" != "0" ] && [[ ! $TERMCAP =~ screen ]]; then
/etc/motd.tcl
fi
@aruseni
aruseni / fstab
Created April 14, 2014 10:11
Place /tmp and /var/tmp on EC2 instance store
# /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/xvdb /mnt/is0 auto defaults,nobootwait,comment=instancestore0 0 2
/dev/xvdc /mnt/is1 auto defaults,nobootwait,comment=instancestore1 0 2
/mnt/is0/tmp /tmp none bind,noauto 0 0
/mnt/is0/var/tmp /var/tmp none bind,noauto 0 0
@aruseni
aruseni / get_credentials.py
Created April 23, 2014 19:19
Requirements: BeautifulSoup. progressbar
import sys
import httplib2
import urllib
import hashlib
import re
import itertools
from BeautifulSoup import BeautifulSoup
import progressbar
@aruseni
aruseni / nginx.conf
Created April 26, 2014 21:30
Nginx Maintenance Message
location /maintenance/ {
alias /home/web/maintenance/;
}
if ($uri !~ ^/maintenance) {
return 302 http://mywebsite.com/maintenance/;
}
@aruseni
aruseni / move_databases_to_rds.sh
Created April 29, 2014 01:23
Transfer local MySQL databases to Amazon RDS
#!/bin/bash
DATABASES="cooldb nicedb epicdb"
LOCAL_PWD="Tr0ub4dor&3"
RDS_PWD="correcthorsebatterystaple"
RDS_HOST="blahblahblah.rds.amazonaws.com"
for DB in $DATABASES ; do
echo "Moving $DB"
echo "create database $DB;" | mysql --host=$RDS_HOST --user=root --password=$RDS_PWD
@aruseni
aruseni / pnm2tiff.sh
Created September 13, 2014 12:59
Converts every .pnm file in the current working directory to .tiff. The numbers from 01 will be used for naming the .tiff files.
i=1 ; for pnmfile in *.pnm ; do tifffile=$(printf %02d.tiff $i) ; convert -compress lzw $pnmfile $tifffile ; i=$((i+1)) ; done
@aruseni
aruseni / checkboxes.html
Created October 16, 2014 11:58
Chain set checkboxes in group when “Select” all checkbox is changed/“Select all” checkbox when checkboxes in group are changed.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Coffee shop</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="checkboxes.js"></script>
</head>
<body>
<p>What topping would you like?</p>
@aruseni
aruseni / incr_count_mixin.py
Last active April 13, 2016 09:58
This Django model mixin adds an incr_count method that increments the “count” field in one SQL query (very useful if same object can be updated simultaneously and you want the count field to have correct values).
class CountIncrMethodMixin(models.Model):
def incr_count(self):
model = type(self)
model.objects.filter(id=self.id).update(
count=models.F("count")+1
)