Skip to content

Instantly share code, notes, and snippets.

View axolx's full-sized avatar
🐝

Martin Rio axolx

🐝
View GitHub Profile
@axolx
axolx / psdtojpeg.sh
Created March 23, 2011 19:24
Convert all PSD files in a directory to JPG
#! /bin/sh
#############################################
# Convert all PSD files in a directory to JPG
#
# Author: Martin Rio
# Version: 0.1 (3/23/2011)
# Dependencies:
# - ImageMagick's convert utility
#############################################
@axolx
axolx / gist:986265
Created May 23, 2011 05:29
Pull & update all git or mercurial repos in a directory (e.g. vim pathogen bundles)
for d in `ls -1`; do
if [ -d $d/.git ]; then
cd $d
git pull
cd ..
elif [ -d $d/.hg ]; then
cd $d
hg pull -u
cd ..
else
@axolx
axolx / gist:3068001
Created July 7, 2012 20:29
Python multiprocessing example: run a function 7 times on a 5 process pool
import multiprocessing
import time
from random import randint
PROCESSES = 5
WORKER_CALLS = 7
def worker(num):
"""worker function"""
print 'Starting worker', num
@axolx
axolx / ombu-ports
Created October 29, 2012 17:53
Macports for OMBU team member
file
php5 +fastcgi +pear +apache2
php5-mysql
php5-solr
php5-soap
php5-openssl
php5-gd
php5-curl
git-core
mercurial
@axolx
axolx / instagram_unfollow.py
Created November 10, 2013 02:07
My Instagram account got hacked and next time I logged in I was following >500 spammers. Instead of using the UI to unfollow them (painfully slow) I put together this little script.
from instagram.client import InstagramAPI
from instagram.bind import InstagramAPIError, InstagramClientError
from time import sleep
access_token = "SETMET"
api = InstagramAPI(access_token=access_token)
follows = api.user_follows(MY_USERID)
for user in follows[0]:
print "Unfollowing: " + user.username
@axolx
axolx / gist:7829436
Created December 6, 2013 18:06
A handy Memcached memoization decorator for Python
"""memorised module - container for the memorise python-memcache decorator"""
__author__ = 'Wes Mason <wes [at] 1stvamp [dot] org>'
__docformat__ = 'restructuredtext en'
__version__ = '1.0.1'
import memcache
import itertools
from hashlib import md5
from functools import wraps
import inspect
@axolx
axolx / ses_mail.py
Last active December 31, 2015 23:59
Sendmail `mail` with AWS SES
#! /usr/bin/env python
"""
A very basic script that emulates Sendmail's `mail` command, sending emails
with [aws-cli](https://github.com/aws/aws-cli). It replicates the minimum
amount of functionality for delivery [Munin notifications](
http://munin-monitoring.org/wiki/HowToContact) (e.g. `contact.email.command
ses_mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email
.address.here`
).
<?php
if (class_exists('Memcache')) {
$server = 'SETME'; # Memcached server hostname
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
if ($isMemcacheAvailable) {
$aData = $memcache->get('data');
echo '<pre>';
@axolx
axolx / nav-reveal.js
Created June 30, 2014 22:02
Implements nav reveal for Bootstrap 3 fixed navbar
/**
* Hide navbar on on scroll down, reveal on scroll up
* @see https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c
*/
(function ($) {
'use strict';
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('.navbar').outerHeight();
@axolx
axolx / 0_reuse_code.js
Last active August 29, 2015 14:26
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