Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@loisaidasam
loisaidasam / README.md
Last active April 7, 2022 19:26
Automatically set the latest AsciiArtFarts.com art to your MOTD!

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 09:59
One liner for counting unique IP addresses from nginx logs
# 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 June 18, 2012 10:17
Remove all *.pyc files from a python project
# 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 October 6, 2015 11:37
Django API Request Decorator
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 August 7, 2012 22:06
Rename images for use by ImageMagick convert or ffmpeg convert
# 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 November 30, 2012 13:34
Hacked Select All in Javscript
// 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:
@loisaidasam
loisaidasam / jumble_solver.py
Created December 3, 2012 19:47
JUMBLE solver
'''Script for solving those pesky newspaper jumbles
Sample usage:
$ python jumble_solver.py SWARLP
sprawl
'''
import random
@loisaidasam
loisaidasam / herenow.py
Created February 19, 2013 05:45
Foursquare miner for "here now" - you used to be able to do this, but apparently can't anymore... : \
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 April 16, 2018 10:00
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).
'''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