Skip to content

Instantly share code, notes, and snippets.

View atleastimtrying's full-sized avatar

Anders Fisher atleastimtrying

View GitHub Profile
@atleastimtrying
atleastimtrying / accellerometer.js
Created January 25, 2013 12:02
an example of using accelerometers on the ipad in js
(function() {
var acceleration = {
x:0,
y:0
};
var div;
var init = function(){
div = document.getElementById("anObject");
@atleastimtrying
atleastimtrying / clock.html
Created January 31, 2013 22:27
html clock with colour changing background
<!doctype html>
<html>
<head>
<title>Clock</title>
</head>
<style>
*{
margin:0;
padding:0;
}
@atleastimtrying
atleastimtrying / app.coffee
Created February 3, 2013 11:34
Some thoughts on a timestamp to countdown. depends on moment.js and jquery
class App
constructor: ->
$('.fullscreen').click @fullscreen
$('#display').click -> $(@).hide()
@started = true
@loop()
fullscreen: ->
$('#display').html $(@).parent().html()
$('#display').show()
@atleastimtrying
atleastimtrying / gist:4952530
Created February 14, 2013 12:46
preloading an image in Coffeescript
src = 'whatever.png'
img = document.createElement 'img'
img.src = whatever
img.onload = ->
console.log 'img loaded'
document.body.appendChild img
.news{
background:white;
border-radius:4px;
padding:16px;
}
.news section{
border:1px solid #ccc;
padding:7px;
}
@atleastimtrying
atleastimtrying / before.css
Last active December 14, 2015 03:19
Before CSS Refactoring
*{
margin:0;
padding:0;
}
div.container{
color:white;
font-weight:normal;display:block;
width:auto;
}
#button1 {font-weight: bold;background-color: red;
*{
margin:0;
padding:0;
}
.race-conditions{
color:white;
font-weight:bold;
}
.race-conditions button{
padding:8px;
@atleastimtrying
atleastimtrying / for_kerry.coffee
Created March 14, 2013 11:26
event driven tests
describe 'player movement', ->
it 'moves up when clicked', ->
playerStartPosition = $('.player').offset().top
$('button.up').trigger('click')
playerEndPosition = $('.player').offset().top
expect(playerStartPosition).not.toBe playerEndPosition
@atleastimtrying
atleastimtrying / gist:5163497
Created March 14, 2013 17:49
how on delegates
var clicky = function(event){
$(event.currentTarget).addClass('stupid');
};
$('.container').on({
click: clicky,
mouseover: clicky
}, '.child');
@atleastimtrying
atleastimtrying / alex.coffee
Created March 27, 2013 10:25
Notes from a chat about js and coffeescript
window.alex = {}
class window.alex.Wheel
constructor: (id)->
console.log id
rotate: ->
console.log 'turning'
class window.alex.Car
constructor: ->