Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@loisaidasam
loisaidasam / prettyfractions.py
Created March 6, 2013 19:42
Make pretty fractions in python
from fractions import Fraction
import sys
def make_pretty_fraction(input, max_denominator=16, can_overshoot=True):
'''Convert a float into a pretty fraction
Inputs:
input <float>
max_denominator [int] maximum denominator of the result
@loisaidasam
loisaidasam / reversed_binary.py
Last active December 15, 2015 02:49
Reversed Binary Numbers
def decimal_to_reversed_binary_decimal(d):
b = bin(d)
return int(b[2:][::-1], 2)
@loisaidasam
loisaidasam / test.py
Last active December 15, 2015 05:39
Simple python Redis client implementing sadd, srem, and sismember
"""Some unit tests to prove that bad boy works!"""
import unittest
from testclient import HOST, PORT, RedisClient, RedisClientException, sadd, srem, sismember
class TestReplyHandlers(unittest.TestCase):
def setUp(self):
self.client = RedisClient(HOST, PORT)
@loisaidasam
loisaidasam / basicauth.py
Created April 25, 2013 19:11
Basic HTTP Authentication Decorator for App Engine
"""Basic HTTP Authentication Decorator for App Engine
Tired of the other lame authentication decorators out there? Try this!
GETTING STARTED:
# Define an authentication verification function
def auth_verifier(username, password):
return username in CREDENTIALS and CREDENTIALS[username] == password
@loisaidasam
loisaidasam / 2013-05-02-Victoria.txt
Created May 2, 2013 19:06
Online conversation with T-Mobile online support person re: getting a micro sim for my new phone...
Thank you for choosing T-Mobile. A representative will be with you shortly.
Welcome to T-Mobile online sales support, how may I help you with your purchase today?
You: Hi how's it going
Victoria: I'm more than happy to assist you. Can I ask for your name please?
You: Sam
Victoria: Hello Sam, how are you?
You: I'm doing pretty well, how are you today?
Victoria: I'm also good and thank you for asking.
You: great
You: Onto business, I'm a T-Mobile customer on a month-to-month plan, and I just bought a new phone, the Nexus 4, straight from Google
@loisaidasam
loisaidasam / find_and_subl.md
Created May 2, 2013 19:37
Shortcut for finding files and opening them ALL in Sublime

A shortcut for finding files and opening them ALL in Sublime:

$ find . -name [filename] | xargs subl

so for instance, if you wanted to open all urls.py files in a Django project, you could do something like this:

$ find . -name urls.py | xargs subl
@loisaidasam
loisaidasam / README.md
Created May 8, 2013 16:38
A little javascript bookmarklet to remove that annoying RueLaLa popup that you always see when your girlfriend sends you pictures of dresses and you don't want to deal with logging into her account...
@loisaidasam
loisaidasam / gist:5750631
Created June 10, 2013 17:27
Github checkout branch fix

Sometimes, in some repos, my computer doesn't like checking out new branches properly (even after git fetch), so instead of:

$ git checkout feature/foo

I end up having to do this:

$ git checkout -t -b feature/foo origin/feature/foo

Solition via: http://stackoverflow.com/a/6181545/1406873

@loisaidasam
loisaidasam / tabs_to_spaces.sh
Last active December 18, 2015 11:08
Tabs to Spaces!
#!/bin/bash
LOC=${1:-"."}
change_file () {
filename=$1
if [ ! -f "$filename" ]
then
echo "$filename is not a file"
/* Raw IR decoder sketch!
This sketch/program uses the Arduno and a PNA4602 to
decode IR received. This can be used to make a IR receiver
(by looking for a particular code)
or transmitter (by pulsing an IR LED at ~38KHz for the
durations detected
Code is public domain, check out www.ladyada.net and adafruit.com
for more tutorials!