Skip to content

Instantly share code, notes, and snippets.

@ionox0
ionox0 / swJobModel.js
Last active January 20, 2016 02:54
Switch Job Model (explanation for coffeescript --> js translation)
}.call(this), function() {
var bind = function(fn, me) {
return function() {
return fn.apply(me, arguments);
};
};
// IIFE - gets run immediately:
!function() {
/*
Array One Array Two Result
["a"] ["a"] => True
["ab"] ["ac"] => False
["aa"] ["ab"] => False
["cbb"] ["abbc"] => True
["abbccdd"] ["abbcccdd"] => True
*/
function check(a, b){
@ionox0
ionox0 / findCommonAncestor.js
Created June 9, 2015 02:40
findCommonAncestor.js
// Name == ionox0
process.stdin.resume();
process.stdin.setEncoding("ascii");
var input = '';
process.stdin.on("data", function(chunk){
input += chunk;
});
process.stdin.on("end", function(){
findAntecedent(input);
@ionox0
ionox0 / gist:f82ec6f49bc9560cbec2
Last active August 29, 2015 14:20
insertion sort vs quicksort
var items = [1, 2, 5, 134, 234, 324, 234, 324, 23, 234, 23, 234, 234, 523, 523, 235, 235, 23, 235, 2354, 2354, 23, 45, 23, 4, 2, 7, 4, 67, 3];
console.time('insertionsort');
console.log(insertionsort(items));
console.timeEnd('insertionsort');
console.time('quicksort');
console.log(quicksort(items, 0, items.length-1));
console.timeEnd('quicksort');
@ionox0
ionox0 / cool.java
Created May 6, 2015 02:06
Are two words anagrams? (you get what i mean...)
class MyClass {
public static void check_anagrams(String[] firstWords, String[] secondWords) {
String characters = "abcdefghijklmnopqrstuvwxyz";
int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
for (int i = 0; i < firstWords.length; i++){
char a;
char b;
int firstWordValue = 1;
int secondWordValue = 1;
for (int j = 0; j < firstWords[i].length(); j++){
@ionox0
ionox0 / gist:fbb6d69f9b9652752c0b
Created May 1, 2015 20:41
Device Tokens Curling
Device Tokens curling:
GET-------------------------------
curl 'http://api.local.mimedia.com:8080/2.0/deviceToken' -X GET -H 'X-MiMedia-Session-Key: -90948020389859841180276180322974804394' -H 'Content-Type: application/json' -H 'Accept: application/json' --compressed
POST------------------------------
(old)
curl 'http://api.local.mimedia.com:8080/2.0/deviceToken' -X POST -H 'X-MiMedia-Session-Key: -90948020389859841180276180322974804394' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"deviceToken":"a361a04345c93070e39af0150870499974d393bf625ccca987f0520bc59416ec","uuid":"b7c66d4345670021a94e14faf03c9594d3105676", "thirdPartyPushNotificationServer":"APPLE"}' --compressed
(new)
curl 'http://api.local.mimedia.com:8080/2.0/deviceToken' -X POST -H 'X-MiMedia-Session-Key: -90948020389859841180276180322974804394' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"deviceToken":"a361a04345c93070e39af0150870499974d393bf625ccca987f0520bc59416ec", "thi
@ionox0
ionox0 / gist:4dfd32fb73d8433522cc
Last active August 29, 2015 14:20
ES6 Promises
/****
Implemented for gathering Allen Brain Atlas API data
[ionox0 - Allen Brain Visualizer](https://github.com/ionox0/Allen-Brain-Atlas-V2)
****/
/*jshint esnext: true */
var _ = require('underscore');
var RSVP = require('rsvp');
module.exports = {
@ionox0
ionox0 / gist:ced45a79066e9cfee9e4
Last active August 29, 2015 14:19
Modal Dialog App w/ Marionette
@MM.module 'DialogApp', (DialogApp, App, Backbone, Marionette, $, _) ->
@on
'start': ->
$('#dialog-region').on 'click.anywhere', (evt) ->
API.hide()
'stop': ->
$(document).add(App.contextMenuRegion.el).off('.anywhere')
API.hide()
@ionox0
ionox0 / Anagram Checker
Created December 3, 2014 14:43
Takes two arrays of words and checks if each of the words successive pair are anagrams of one another
class AnagramChecker {
public static void check_anagrams(String[] firstWords, String[] secondWords) {
String characters = "abcdefghijklmnopqrstuvwxyz";
int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
for (int i = 0; i < firstWords.length; i++){
char a;
char b;
int firstWordValue = 1;
int secondWordValue = 1;
for (int j = 0; j < firstWords[i].length(); j++){
$(document).ready(function() {
ws = new WebSocket("ws://" + location.hostname + ":8080/");
ws.onmessage = function(event) {
$("#messages").append("<p>" + event.data + "</p>");
};
ws.onclose = function() {
console.log("Socket closed");
};