Skip to content

Instantly share code, notes, and snippets.

View atleastimtrying's full-sized avatar

Anders Fisher atleastimtrying

View GitHub Profile
@atleastimtrying
atleastimtrying / ball.pde
Created August 26, 2011 10:01
A basic processing sketch for nick
int x,y, xVelocity; // our three variables that we need to keep track of
void setup(){
size(320,240); //size of the app
smooth(); // makes circles anti aliased
noStroke(); // means there is no outer line on our circle
fill(100,100,150); // the colour of the ball
background(240); // the background
xVelocity = 1;
x = width/2; // width is the width of the sketch its always available
y = height/2; // same with height
@atleastimtrying
atleastimtrying / gist:1357730
Created November 11, 2011 10:53
noddling about with twitter for wilson
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
window.sketch = (p5)->
p5.setup = ->
p5.size $(window).width(),$(window).height()
p5.background 0x000033
p5.smooth()
p5.rectMode p5.CENTER
@atleastimtrying
atleastimtrying / swipey.js
Created February 2, 2012 14:34
swipey js
window.onload = function(){
var display = document.getElementsByTagName("body"); //could be any element
var touched = false; // a useful flag for restructing otehr actions
var increment = 0; // the amount we increment
var addRotateTouches = function(){
display.addEventListener("touchstart", rotateStart ,false);
display.addEventListener("touchmove", rotateMove ,false);
display.addEventListener("touchend", rotateEnd ,false);
}
<!DOCTYPE>
<html>
<head>
<title>Link sorter</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<style>
a, input{
margin:5px;
padding:10px;
font-family:sans-serif;
function store_in_msg_table($message){
$message = mysql_real_escape_string($message);
openconn();
$sql = '';
if(!mysql_num_rows( mysql_query("SHOW TABLES LIKE 'email_store'"))){
$sql = "CREATE TABLE 'email_store' ('id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY , 'message' TEXT NOT NULL , 'date_sent' TIMESTAMP NOT NULL);";
mysql_query($sql) or die(mysql_error());
}
$sql = 'INSERT INTO email_store (message) values ("'.$message.'");';
mysql_query($sql) or die(mysql_error());
@atleastimtrying
atleastimtrying / simplesearch.coffee
Created October 12, 2012 12:23
Alternative search input functionality
$ ->
allLinks = $ '.links li a'
linksContaing = (searchString)->
$(".links li a:contains('#{searchString}'), .links li a.#{searchString}")
displayLinks = ->
searchString = $(@).val()
if searchString is ''
allLinks.show()
@atleastimtrying
atleastimtrying / app.coffee
Created October 14, 2012 22:13
coffeescript canvas animation
class Blob
constructor: (@x, @y, @app)->
@xAcceleration = Math.random() - 0.5
@yAcceleration = Math.random() - 0.5
draw: =>
@x += @xAcceleration
@y += @yAcceleration
@x = -5 if @x > @app.width + 5
@x = @app.width + 5 if @x < -5
@atleastimtrying
atleastimtrying / input.txt
Created November 10, 2012 09:00
Input book
So it's going to be a book cataloging inputs to computers and touch devices.
- how to find a new kind of input
examine the real world
what do we already use/do
what could be expressed better
the introduction of analogue
the introduction of the mouse
kinect
new things are rubbish discomfort
@atleastimtrying
atleastimtrying / gist:4408738
Created December 29, 2012 19:09
A nice easing equation
value = 10
targetValue = 20
speed = 0.1
loop = ->
value += (value - targetValue)* speed
requestAnimationFrame loop unless Math.abs(targetValue - value) < 1
@atleastimtrying
atleastimtrying / gist:4504130
Last active December 10, 2015 22:39
a basic scroll position detector
class ScrollTracker
constructor: ->
$(window).scroll @scroll
@targets = $ '.targets'
@sensitivity = 20
showNavFor: (target)=>
name = $(target).attr 'name'
$('.active').removeClass 'active'
$("a[href=##{name}]").addClass('active');