Skip to content

Instantly share code, notes, and snippets.

View slopeofhope81's full-sized avatar

Steve Lim slopeofhope81

View GitHub Profile
@slopeofhope81
slopeofhope81 / gist:9114994
Last active August 29, 2015 13:56
playing with jQuery for DOM manipulation.
var KEY={
UP: 38,
DOWN: 40,
W: 87,
S: 83,
};
var pingpong = {};
pingpong.ball = {
speed: 5,
x: 150,
@slopeofhope81
slopeofhope81 / gist:9199861
Created February 24, 2014 23:57
todo app using local storage
$(function(){
$("#add").click(function(){
var description=$("#description").val();
if(description === ""){
$("#alert").html("<strong>Warning</strong> You left the todo app!");
$("#alert").fadeIn().delay(1000).fadeOut();
return false;
}
$("#todos").prepend("<li><input type='checkbox' name='checkbox'>"+ description+ "</li>");
$("#form")[0].reset();
@slopeofhope81
slopeofhope81 / gist:9228436
Created February 26, 2014 12:10
validation example using javascript/
<html>
<head>
<title>example javascript</title>
</head>
<body>
<form name="logInForm" method="post" onsubmit="return validate()">
First name:<input type="text" id="firstName" name="firstName" >
Last name:<input type="text" id="lastName" name="lastName" >
<input type="submit" value="LogIn" id="logIn">////<---------this type comes in pair with onsubtmit attribute!!!
<div id="error"></div>
@slopeofhope81
slopeofhope81 / gist:9256983
Created February 27, 2014 19:12
my last project
$(document).ready(function(){
var allQuestions= [];
var questionNumber = 0;
var score = 0;
var name=[];
allQuestions[0]={question:"What is 2 + 2?",
choices:[0,2,3,4],
correct:3 };
allQuestions[1]={question:"What is 2 * 2?",
choices:[0,2,3,4],
@slopeofhope81
slopeofhope81 / gist:9477929
Created March 11, 2014 01:38
my first clock watch app using angular
<script>
var myApp = angular.module('myApp', []);
myApp.controller("myFirst", function($scope){
$scope.clock = new Date();
var updateClock = function(){
$scope.clock = new Date();
}
setInterval(function(){
$scope.$apply(updateClock);}, 1000);
updateClock();
@slopeofhope81
slopeofhope81 / gist:9487504
Created March 11, 2014 14:57
my first intro to Jasmine
describe("calculator",function(){
var calc;
beforeEach(function(){
calc = new Calculator();
})
describe("addition", function(){
it("should be able to add a sum", function(){
var result = calc.addition(5,3);
expect(result).toBe(8);
});
@slopeofhope81
slopeofhope81 / gist:9643973
Created March 19, 2014 15:20
sharing properties using literal object and constructor
var steve = {
name: "Steve",
};
var haeseong = {
name: "haeseong",
};
var protoRun = {
run: function(name){
@slopeofhope81
slopeofhope81 / gist:9667647
Created March 20, 2014 16:19
creating a secret random key using ruby
def secure_token
token_file = Rails.root.join(".secret")
if File.exist?(token_file)
File.read(token_file).chomp
else
token = SecureRandom.hex(64)
File.write(token_file, token)
token
end
end
@slopeofhope81
slopeofhope81 / gist:9695283
Created March 21, 2014 20:09
review python #1
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
new_word = word[1:] + first + pyg
print new_word
else:
@slopeofhope81
slopeofhope81 / gist:9743335
Created March 24, 2014 16:08
brushing up python #2
storage = {}
storage["first"]={}
storage["middle"]={}
storage["last"]={}
me = "steve seung lim"
storage["first"]["steve"] = me
storage["middle"]["seung"] = me