Skip to content

Instantly share code, notes, and snippets.

View alexispurslane's full-sized avatar

Alexis Purslane alexispurslane

View GitHub Profile
@alexispurslane
alexispurslane / slide.js
Created May 23, 2013 13:43
A slide function. from my library called Magik it is also on github!
slide: function (all) {
var pos = this.pos;
if (all.direction == 'Down') {
var obj = this.e;
obj.style.zIndex = this.zIndex;
this.zIndex++;
obj.style.position = "relative"
var timer = setInterval(function () {
if (pos >= all.movement) {
clearInterval(timer)
@alexispurslane
alexispurslane / jsbin.cecix.css
Last active August 29, 2015 13:56
A Calculator that i created to see if I could pass the interview questions at Yahoo!.
button { width: 30px; }
#zero { margin-left: 33px; }
span {
display: block;
width: 92px;
border: 1px solid black;
height: 15px;
margin-bottom: 3px;
padding: 2px;
color: green;

Keybase proof

I hereby claim:

  • I am christopherdumas on github.
  • I am christopherdumas (https://keybase.io/christopherdumas) on keybase.
  • I have a public key whose fingerprint is FAE6 C745 4B53 D39F C05A 0653 2EB0 58FE 5EEF 41BD

To claim this, I am signing this object:

@alexispurslane
alexispurslane / gist:c97935d73c3f8f6928cd
Last active August 29, 2015 14:01
A setTimeout type function for Racket. It uses seconds, has a function to call while waiting for the callback.
(define (wait time callback [t (current-seconds)] [while-wait (lambda () null)])
(cond
[(<= (+ time t) (current-seconds)) (callback)]
[else
(while-wait)
(wait time callback t)]))
@alexispurslane
alexispurslane / gist:7dd5dc71ec9c41d21f53
Last active August 29, 2015 14:01
Tail call optimized factorial in Racket.
(define fact (lambda (n [state 1])
(cond
[(zero? n) state]
[else
(factorial (- n 1) (* state n))])))
(fact 4)
@alexispurslane
alexispurslane / gist:2d4536fda36794f830fb
Last active August 29, 2015 14:01
FizzBuzz in Racket
#lang racket
(define (fizz-buzz [end 100] [n 1])
(letrec ([FB (lambda (n)
(cond
((< n end)
(displayln
(match (gcd n 15)
[15 "fizzbuzz"]
[3 "fizz"]
[5 "buzz"]
@alexispurslane
alexispurslane / dsl.m
Last active August 29, 2015 14:05
A simple level creating DSL. I am kinda proud of myself for doing this. This little DSL will probably be expanded and given it's own GUI for The Outer Ring 2.0
- (NSDictionary *) readMap: (NSString *)content
{
content = [content stringByReplacingOccurrencesOfString:@"--------------------" withString:@""];
NSMutableArray *map1 = [@[] mutableCopy];
NSArray *array = [content componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSMutableArray *arrayMut1 = [[NSMutableArray alloc] initWithArray:[self splitArrayWithArray:array rangeNumber:([array count] / 2)] copyItems:YES];
NSMutableArray *arrayMut = [NSMutableArray new];
for(NSArray *subarray in arrayMut1) {
NSMutableArray *subCopy = [NSMutableArray new];
@alexispurslane
alexispurslane / designer.html
Last active August 29, 2015 14:09
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@alexispurslane
alexispurslane / gist:f0901e7133022863f131
Created December 7, 2014 03:38
Fizzbuzz Functional in rust
/*
* Rust Fizzbuzz functional implementation
*/
fn fb (i: int) -> () {
let mod5 = i % 5 == 0;
let mod3 = i % 3 == 0;
match [mod5, mod3] {
[false, true] => println!("Fizz"),
[true, false] => println!("Buzz"),
@alexispurslane
alexispurslane / get-digits.rkt
Created February 24, 2015 20:56
Gets the digits of a number by converting it to a string, then separating the strings characters, and converting them to numbers. I am using this for my CARDIAC computer emulator.
(define (get-digits n)
(map string->number (map string (string->list (number->string n)))))