Skip to content

Instantly share code, notes, and snippets.

@desmondrawls
desmondrawls / setupusers.php
Last active December 15, 2015 11:59
User registration using salted hashed passwords
<?php //setupusers
require_once 'login.php'; //login.php defines $db_hostname, $db_username, $db_password, $db_database
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());
$salt1 = "qm&h*";
$salt2 = "pg!@";
@desmondrawls
desmondrawls / arrayShuffle.js
Created March 27, 2013 20:08
Array shuffling method
Array.prototype.shuffle = function shuffle(){
var tempSlot;
var randomNumber;
for (var i = 0; i != this.length; i++){
randomNumber = Math.floor(Math.random() * this.length);
tempSlot = this[i];
this[i] = this[randomNumber];
this[randomNumber] = tempSlot;
}
return this;
import acm.program.*;
public class Caesar extends ConsoleProgram {
private char encryptChar (char ch, int key){
if (Character.isUpperCase(ch)) {
return((char)('A' + ((ch - 'A' + key)%26)));
}
return ch;
}
@desmondrawls
desmondrawls / catsinhats.java
Created April 8, 2013 23:23
## Cats in Hats You have 100 cats (You are quite lucky to own so many cats!). You have arranged all your cats in a line. Initially, none of your cats have any hats. You take 100 rounds walking around the cats, always starting with the first cat. Every time you stop at a cat, you put a hat on it if it doesn't have one, and you take its hat off if…
import acm.program.*;
public class CatsInHats extends ConsoleProgram {
private boolean changeHat(boolean b){ //reverses the hat-having state of any cat that changeHat gets called on
if (b==true) {
return false};
else return true;
}
@desmondrawls
desmondrawls / profile.txt
Last active December 18, 2015 01:19
My flatiron profile
Name: Desmond Rawls
Github: www.github.com/desmondrawls
Website: www.mycodinghoneymoon.dreamhosters.com
Blog: desmondrawls.github.io
Tagline: teaching rocketships to think like astronauts
photo: https://www.facebook.com/photo.php?fbid=10100196742148965&l=085e78340c
treehouse: https://teamtreehouse.com/desmondrawls
coderwall:https://coderwall.com/desmondrawls
codeschool: http://codeschool.com/users/desmondrawls
codecademy: http://www.codecademy.com/desmondrawls
here, eat this (handing the alien a delicious pb & j)
ok now you figure it out
"If you want to build a ship, don't drum up the men to gather wood, divide the work, and give orders. Instead, teach them to yearn for the vast and endless sea" - Antoine de Saint-Exupery
@desmondrawls
desmondrawls / amazon.sql
Last active December 18, 2015 03:39
amazon sql model DD up -- Dolly Parton
--I chose to make DVD a format instead
--of the primary noun
CREATE TABLE movies_and_tv (
id INTEGER PRIMARY KEY,
name TEXT,
year INTEGER,
rating TEXT
);
CREATE TABLE user (
id INTEGER PRIMARY KEY,
address TEXT,
email TEXT,
phone INTEGER
);
CREATE TABLE listing (
id INTEGER PRIMARY KEY,
property_type TEXT,
@desmondrawls
desmondrawls / joins.sql
Created June 7, 2013 00:02
sql joins homework some marvin gaye, luther van drosse, a little anitaaaa will surely get this party off riiight
CREATE TABLE projects (
id INTEGER PRIMARY KEY,
title TEXT,
category TEXT,
goal INTEGER,
start INTEGER,
end INTEGER
);
CREATE TABLE users (
# jukebox.rb
class Jukebox
@@jukeboxes = {}
def initialize (name)
@@on = true
@name = name
@user_tracks = []
@@jukeboxes[:name] = @user_tracks