Skip to content

Instantly share code, notes, and snippets.

View powerc9000's full-sized avatar
🧺

Clay Murray powerc9000

🧺
View GitHub Profile
@powerc9000
powerc9000 / maths
Created July 16, 2012 21:59
some vector stuff for peter
degrees = angle * (180/Math.PI);
slope = tangent(degrees);
length = Math.sqrt(1*1,m*m);
vector = [1/length,m/length];
next_point = function(distance,start,magnatude){
var end = []
magnatude[0] = magnatude[0]*distance;
magnatude[1] = magnatude[1]*distance;
end[0] = start[0] + magnatude[0];
end[1] = start[1] + magnatude[1];
(function(){
var canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d"),
ship = {
x: 250,
y: 250,
speed: 10,
angle: 0,
vx: 0,
vy: 0,
@powerc9000
powerc9000 / html
Created July 20, 2012 04:48
some html
<html>
<head>
<title>Clay Murray's Web Adventures</title>
<link rel="stylesheet" type="text/css" href="http://current.bootstrapcdn.com/bootstrap-v204/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="navbar ">
<div class="navbar-inner">
<div class="container">
@powerc9000
powerc9000 / The first.js
Last active December 17, 2015 09:29
Some Gists for My Clay's code corner
setTimeout(function(){
//timeout code goes here
//will run this code after 1000 miliseconds
//1000 miliseconds = 1 second
}, 1000);
//Just proving it is async
setTimeout(function(){
console.log("hello world");
},1000);
for(var i=0; i<10; i++){
console.log(i);
}
//Will print
@powerc9000
powerc9000 / interval.js
Created May 16, 2013 15:09
Showing off setInterval
setInterval(function(){
console.log("hello world");
}, 1000)
//Will print
//hello world
//*1000 MS later*
//hello world
//Will run until stopped
@powerc9000
powerc9000 / stop interval.js
Created May 16, 2013 15:11
stopping and interval
var interval = setInterval(function(){
console.log("hello world")
}, 1000);
clearInterval(interval);
function foo(){
var num = 20;
return function(){
console.log(num);
}
}
foobar = foo();
foobar();
@powerc9000
powerc9000 / dom.md
Last active December 17, 2015 12:09
What we want to do for the DOM manipulation library

Some DOM library

The goal here is to make a DOM manipulation library like unto jQuery for practice and to learn javascript more fully and completely

Select things

  • By tag
  • By class
  • By Id
var rooms = {};
io.sockets.on("connection", function(socket){
socket.on("create room", function(roomName){
if(!rooms[roomName]){
rooms[roomName] = [];
}
rooms[roomName].push(socket);
});
socket.on("message", function(data){
rooms[data.roomName].forEach(function(s){