Skip to content

Instantly share code, notes, and snippets.

🙌
🙌

Loisaida Sam loisaidasam

View GitHub Profile
@loisaidasam
loisaidasam / README.md
Last active Sep 28, 2015
Automatically set the latest AsciiArtFarts.com art to your MOTD!
View README.md

So you want that super clever and funny AsciiArtFarts.com humor on your terminal's Message of the Day? Here's how!

STEP 1.

First put asciiartfarts-motd.php somewhere where you know where it is:

mv asciiartfarts-motd.php /Users/sam/bin/

STEP 2.

Modify your crontab ("crontab -e" on command line) to include something like this:

@loisaidasam
loisaidasam / gist:2774350
Created May 23, 2012
One liner for counting unique IP addresses from nginx logs
View gist:2774350
# One liner for counting unique IP addresses from nginx logs
# Feel free to comment with better ideas - I'm sure it's not the best way of doing this (I'm no awk ninja!)
#
# Sample output:
#
# $ cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
# 66.65.145.220 49
# 92.63.28.68 126
cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
@loisaidasam
loisaidasam / gist:2947753
Created Jun 18, 2012
Remove all *.pyc files from a python project
View gist:2947753
# http://stackoverflow.com/questions/785519/remove-all-pyc-files-from-a-project
$ find . -name '*.pyc' -exec rm -f {} \;
@loisaidasam
loisaidasam / rest_utils.py
Last active Oct 6, 2015
Django API Request Decorator
View rest_utils.py
import json
import logging
from django.http import HttpResponse
logger = logging.getLogger(__name__)
ALLOWED_REQUEST_TYPES = ('GET', 'POST', 'PUT', 'DELETE')
@loisaidasam
loisaidasam / rename_images.py
Created Aug 7, 2012
Rename images for use by ImageMagick convert or ffmpeg convert
View rename_images.py
# Goes a little something like this:
import os
files = [ f for f in os.listdir('.') if os.path.isfile(os.path.join('.',f)) and f.endswith('.jpg') ]
for i, file in enumerate(sorted(files)):
os.rename(file, 'image%03d.jpg' % i)
# Now with them renamed you can do something like:
@loisaidasam
loisaidasam / gist:4175768
Created Nov 30, 2012
Hacked Select All in Javscript
View gist:4175768
// Run this from the console:
tags = document.getElementsByTagName('input');
for (i in tags) { if (tags[i]['type'] == 'checkbox') { tags[i]['checked'] = 'checked'; } }
// And voila!
// Apparently these are some other variations:
View jumble_solver.py
'''Script for solving those pesky newspaper jumbles
Sample usage:
$ python jumble_solver.py SWARLP
sprawl
'''
import random
View description.md
@loisaidasam
loisaidasam / herenow.py
Created Feb 19, 2013
Foursquare miner for "here now" - you used to be able to do this, but apparently can't anymore... : \
View herenow.py
import urllib
import simplejson as json
import random
import time
client_id = 'FOURSQUARE_CLIENT_ID (yours, not mine)'
client_secret = 'FOURSQUARE_CLIENT_SECRET (yours, not mine)'
'''Ljubljana'''
min_lat = 46.0424722222
@loisaidasam
loisaidasam / miner.py
Last active Apr 16, 2018
Foursquare Miner! Mine the venues tips database for some specific keywords and save them to a csv file. You can then use OpenRefine (https://github.com/OpenRefine/OpenRefine) to clean up the data (if you want).
View miner.py
'''Mine foursquare for tips and save the results to a csv
Uses this (deprecated) API endpoint:
https://developer.foursquare.com/docs/tips/search
'''
import csv
import datetime
import json
import random
You can’t perform that action at this time.