Skip to content

Instantly share code, notes, and snippets.

/*
Given a sequence of heads and tails. How many significant subsequences are in this sequence, where the number of heads are not less than the number of tails?
Your standard output should be the number of subsequences.
Expected complexity: O(N*logN)
Example input:
data: [ 'H', 'T', 'H', 'T', 'T', 'H' ]
Example output:
11
*/
@brett-shwom
brett-shwom / gist:3f861cf8530de19b6046
Created June 6, 2014 21:34
Array.shift() resulting in incorrect rerendering in Ractive.js
<script src='http://cdn.ractivejs.org/latest/ractive.js'></script>
<script type='text/template' id='template'>
<div class='attribute' data-a="{{#a}}{{.}}{{/a}}"></div> <!--shift is buggy here-->
<div class='innerHTML'> {{#a}}{{.}}{{/a}}</div> <!--shift() works fine here-->
<br/> Does the attribute equal the innerHTML : <span class='doesTheAttributeEqualTheInnerHTML'></span>
<br/> Actual Attribute : <span class='actualAttributeValue'></span>
<br/> Expected Attribute : <span class='expectedAttributeValue'></span>
</script>
OAuth.initialize(config.oauthio.publicKey)
var oauthioResult
, twitterUser
, twitterUserProfile
OAuth
.callback('twitter', function(err, _oauthioResult) { //callback happens after the redirect
var promise = new Promise
@brett-shwom
brett-shwom / gist:8396210
Last active January 3, 2016 02:29
pull to close / momentum feedback
<style>
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
#container{
position:absolute;
top:0;
bottom:0;
left:0;
@brett-shwom
brett-shwom / gist:3185174
Created July 26, 2012 23:13
code snippet - 1132
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/json2-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/underscore-1.3.3-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/backbone-0.9.2-min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/2.5.3-crypto-sha1-hmac.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.5.4-min.js"></script>
<script type="text/javascript">
@brett-shwom
brett-shwom / gist:3092819
Created July 11, 2012 19:48
latest error
info: Creating snapshot 0.0.1-13
info: Updating app RedBull-brett
info: Activating snapshot 0.0.1-13 for RedBull-brett
info: Starting app RedBull-brett
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error:
error: There was an error while attempting to start your application.
error: Error spawning drone
error: Script prematurely exited
@brett-shwom
brett-shwom / gist:3092743
Created July 11, 2012 19:40
package.json
{
"name": "RedBull-brett",
"description": "Testing environment for Pusher",
"version": "0.0.1-12",
"dependencies": {
"express": "2.x",
"express-messages": "x",
"redis": "0.x",
"socket.io": "0.x",
"underscore": "1.x",
➜ red-bull git:(master) ✗ jitsu deploy
info: Welcome to Nodejitsu signedon
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing your application dependencies in node ./server/app.js
info: Checking app availability RedBull-brett
error: The subdomain you have requested is already in use.
prompt: subdomain: (signedon.red-bull.signedon)
info: Checking app availability RedBull-brett
info: Creating app RedBull-brett