Skip to content

Instantly share code, notes, and snippets.

View QuanSai's full-sized avatar
💭
code monkeying

Greg Thompson Jr. QuanSai

💭
code monkeying
  • New York City
View GitHub Profile
@QuanSai
QuanSai / facechop.py
Created August 22, 2012 04:25
This is the first part of what I call "DjFaceChop" which will crop faces out of given images. I looked at example code of face tracking all over the net and came up with this. Uses the OpenCV Haar training data to detect faces in the image. The rest is
import cv2
def facechop(image):
facedata = "haarcascade_frontalface_default.xml"
DOWNSCALE = 1
cascade = cv2.CascadeClassifier(facedata)
img = cv2.imread(image)
minisize = (img.shape[1]/DOWNSCALE,img.shape[0]/DOWNSCALE)
@QuanSai
QuanSai / booltest.py
Created September 3, 2012 07:16
Truth Table Tester - Asks the user a truth table-related question; Spits out correct answer if the answer provided is wrong.
'''
Created on Sep 03, 2012
@author: Gregory A. Thompson Jr.
Truth Table Tester
booltest.py
-Asks the user a truth table-related question.
-Spits out correct answer if the answer provided is wrong.
@QuanSai
QuanSai / loic.cpp
Created September 15, 2012 00:27
Helping Loic with his homework.
#include <iostream>
using namespace std;
int is_inside(int a[])
{
int to_compare, flag; //the number to compare
// followed by the "is inside" flag, yes or no (1, NULL)
flag = 0; //first it's assumed that the number to_compare to the array elements is non-existent
cout << "Enter a value to check for: " << endl;
cin >> to_compare; //set to_compare to user input
@QuanSai
QuanSai / encrypt.py
Created October 2, 2012 18:35
BC homework assignment
def encrypt(character, password): #takes one character, one password string
result = (int(character) % len(password)) - ord('a') #encryption operation
return result
def convert(password): #takes one password string
u_list = [ord(x) for x in password] #for each character in the password, get its ordinal version; unicode each character
result = [] #this will hold each character that's converted
for i in u_list: #for each character i in the unicoded character list
conversion = encrypt(i, password) #convert the current character i using the encryption algorithm
@QuanSai
QuanSai / auto.py
Created October 8, 2012 22:01
The of an auto voter for my friend.
import mechanize
import cookielib
browser = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
browser.set_cookiejar(cj)
# Browser options
browser.set_handle_equiv(True)
@QuanSai
QuanSai / Converter.java
Created October 29, 2012 09:33
Converts Fahrenheit to Celsius and vise versa. Wrote it to help my girl.
import java.util.*;
public class Convert
{
public static void main(String[] args)
{
Scanner inChoice = new Scanner(System.in), //input object for choice
inF = new Scanner(System.in), //input object for F
inC = new Scanner(System.in); //input object for C
@QuanSai
QuanSai / Convert2.java
Created October 31, 2012 05:17
Temp conversion again; This time, just asking for the temp
import java.util.*;
public class Convert
{
public static void main(String[] args)
{
Float f, c; //f and c represent the actual float value of the input temperature
Scanner inTemp = new Scanner(System.in); //holds input Scanner object
char type; //holds the type of input temperature F or C
@QuanSai
QuanSai / BankAccount.java
Created November 13, 2012 09:46
A small, simple demonstration of an ATM in Java I wrote. Demonstrates classes, methods, and exceptions. Also demonstrates implementation and testing.
package bankaccounttest;
public class BankAccount
{
private double balance;
//////Constructors//////
public BankAccount() //no-arg constructor
{
this.balance = 0.0;
@QuanSai
QuanSai / Pet.java
Created November 14, 2012 03:43
Class demonstration
public class Pet
{
private String name;
private int age;
private double weight;
public void writeOutput()
{
System.out.println("This is a pet named " + this.name +
"who is " + this.age +
@QuanSai
QuanSai / appending.py
Created November 18, 2012 03:35
How to join strings together using Python.
first = 'pwn'
second = 3
third = 'd'
newstring = ''.join([first, str(second), third])
print newstring