Skip to content

Instantly share code, notes, and snippets.

@chrisallick
chrisallick / gist:5630817
Created May 22, 2013 20:53
Wanna convert hex values of emojis into NSStrings so you can render them to the screen? Hahhahaha... YES!
-(NSString *)hexToString:(NSString *)hex {
NSScanner *scan = [[NSScanner alloc] initWithString:hex];
unsigned int val;
[scan scanHexInt:&val];
char cc[4];
cc[3] = (val >> 0) & 0xFF;
cc[2] = (val >> 8) & 0xFF;
cc[1] = (val >> 16) & 0xFF;
cc[0] = (val >> 24) & 0xFF;
NSString *s = [[NSString alloc]
For most of us it was our first job out of college. Living in New York, working on what we through were big important projects and figuring out what we wanted from life. A really fun time in our lives. However, the particular project we were working on had become a slog. The day to day was wearing on us and there was no leadership. You know when you feel like you're not sure what or why your doing anything and you look around at your work place wondering who's steering the ship? Well, our tech leader who wasn't particularly helpful introduces us to Will. Huge smile, scragly hair and immediately someone we looked up to. I was pretty full of myself, still am, but I remember sitting around having beers and talking and him showing me projects he worked on on the side. It didn't even occur to me that you could "jam on a passion project" after work. I was so inspired that somoene would use their talent as a coder to try and make projects just for fun that made people happy.
Well, within a couple weeks Will
@chrisallick
chrisallick / gist:6016417
Created July 17, 2013 00:07
iOS AVAudioPlayer audio fade in.
soundPath = [[NSBundle mainBundle] pathForResource:@"soundtrack" ofType:@"m4a"];
soundtrack = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:nil];
[soundtrack setVolume: 0.0];
[soundtrack prepareToPlay];
}
return self;
}
-(void)doVolumeFade {
if (soundtrack.volume < 0.1) {
@chrisallick
chrisallick / pixelateCapture.java
Created July 23, 2013 00:24
pixelate the camera input, processing.
// Learning Processing
import processing.video.*;
// Number of columns and rows in our system
int cols, rows;
// Variable to hold onto Capture object
Capture video;
PImage output;
float avg_r, avg_g, avg_b;
@chrisallick
chrisallick / pixelfy.java
Created July 25, 2013 21:30
pixelate a webcam, step through pixel size with up and down arrows
// Learning Processing
import processing.video.*;
// Number of columns and rows in our system
int cols, rows;
// Variable to hold onto Capture object
Capture video;
PImage output;
float avg_r, avg_g, avg_b;
@chrisallick
chrisallick / ip2cb.rb
Created August 4, 2013 23:18
This application will figure out your host ip and copy to clip board. It also uses the gotonow application so you can easily open it on mobile safari as described by: http://clubsexytime.com/projects/gotonow/
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
myip = Socket::getaddrinfo(Socket.gethostname,"echo",Socket::AF_INET)[0][3]
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
//
// AnimalRecordView.m
// SoundFarm
//
// Created by chrisallick on 9/11/13.
// Copyright (c) 2013 GSP BETA Group. All rights reserved.
//
#import "AnimalRecordView.h"
//
// MenuView.m
// GoodyVibrations
//
// Created by chrisallick on 3/22/13.
// Copyright (c) 2013 chrisallick. All rights reserved.
//
#import "MenuView.h"
#import "PRTween.h"
Borgs = function( _w, _h, _num ) {
var self = this;
this.borgs = new Array();
this.create = function() {
for( var i = 0; i < _num; i++ ) {
if( i < 5 ) {
self.borgs.push( new Borg( getRandomInt(50, _w-50 ), getRandomInt( 50, _h-50), 10 ) );
} else {
self.borgs.push( new Borg( getRandomInt(50, _w-50 ), getRandomInt( 50, _h-50), getRandomInt( 4000, 10000) ) );
@chrisallick
chrisallick / RGBFromPixel
Created October 23, 2013 22:56
My dopest hack. I have no idea how to use openFrameworks, but this will get the pixels from your screen and then give you back the rgb value of wherever you are clicking...
void testApp::mousePressed(int x, int y, int button) {
receivedImage = FALSE;
ofImage theScreen; //declare variable
theScreen.grabScreen(0,0,1024,768); //grab at 0,0 a rect of 1024x768. Equivalent to loadPixels();
const ofPixelsRef pixels= theScreen.getPixelsRef();
ofLog() << (int)pixels.getColor(x,y).r << ", " << (int)pixels.getColor(x,y).g << ", " << (int)pixels.getColor(x,y).b;
ofxOscMessage m;
m.setAddress("/color");
m.addStringArg(ofToString((int)pixels.getColor(x,y).r) +","+ ofToString((int)pixels.getColor(x,y).g) +","+ ofToString((int)pixels.getColor(x,y).b));