Skip to content

Instantly share code, notes, and snippets.

@codepreneur
codepreneur / SpecRunner.html
Created June 22, 2014 13:03
Jasmine Spec Runner
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v2.0.0</title>
<link rel="shortcut icon" type="image/png" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine.css">
@codepreneur
codepreneur / AngularChat.html
Created June 28, 2014 23:36
Angular + Firebase = <3
<html ng-app="myapp">
<head>
</head>
<body ng-controller="MyController">
<div id="messagesDiv">
<div ng-repeat="msg in messages"><em>{{msg.from}}</em>: {{msg.body}}</div>
</div>
<input type="text" ng-model="name" placeholder="Name">
<input type="text" ng-model="msg" ng-keydown="addMessage($event)" placeholder="Message...">
<form name="form" ng-submit="submit()" novalidate>
<fieldset style="width: 30%">
<p>Name: <input type="text" ng-model="name" name="name" ng-minlength=3 ng-maxlength=20 ng-pattern="/^[a-zA-Z]+$/" required></p>
<section ng-show="form.name.$dirty && form.name.$invalid" style="color: red;">
<p ng-show="form.name.$error.required">Your name is required</p>
<p ng-show="form.name.$error.minlength">Your name must be greater than 3 characters</p>
<p ng-show="form.name.$error.maxlength">Your name cannot be longer than 20 characters</p>
<p ng-show="form.name.$error.pattern">Only letters please!</p>

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@codepreneur
codepreneur / README.md
Last active August 29, 2015 14:07 — forked from xavriley/README.md

Making Chiptune Music using Sonic Pi v2.0

Warning: this might not work on a RaspberryPi yet

I was curious about making retro gaming sounds using Sonic Pi. A couple of months and a lot of Googling later, here's the original Mario Bros theme as it was heard on the NES console.

I'm (just about) old enough to remember rushing home from school to play this game at Philip Boucher's house, sitting cross-legged in front of the TV till my feet got pins and needles. Working out how to recreate it for Sonic Pi was a lot of fun!

Getting the sounds of the NES chip

App.Chart = Ember.View.extend({
tagName: 'svg',
reScale: function() {
d3.selectAll( this.svg[0][0].childNodes ).remove();
Ember.run.scheduleOnce( 'afterRender', this, 'build' );
},
didInsertElement: function() {
var that = this;
$( window ).on( 'resize', function() {
Ember.run.debounce( that, that.reScale, 1000 );
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@codepreneur
codepreneur / UsefulConfig
Created January 22, 2015 15:52
Useful config commands
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
git lg -p (to include code changes too)
git lg -p <file> (to restrict logs/changes to specific file)
(function () {
var makeCallback = function(eventType, observer) {
if (eventType === 'value') {
return function(snap) {
observer.onNext(snap);
};
} else {
return function(snap, prevName) {
// Wrap into an object, since we can only pass one argument through.
observer.onNext({snapshot: snap, prevName: prevName});

Keybase proof

I hereby claim:

  • I am codepreneur on github.
  • I am codepreneur (https://keybase.io/codepreneur) on keybase.
  • I have a public key whose fingerprint is CF38 14A0 E78A AA1A 0C2D C2D0 FE63 3A62 FDC2 30A2

To claim this, I am signing this object: