Skip to content

Instantly share code, notes, and snippets.

View motiooon's full-sized avatar

Gabriel Baciu motiooon

View GitHub Profile
@motiooon
motiooon / gist:8421292
Created January 14, 2014 16:38
MergeSort in Javascript
function merge(left, right){
var li = 0;
var ri = 0;
var result = [];
while(li < left.length && ri < right.length){
if(left[li] < right[ri]){
result.push(left[li++])
@motiooon
motiooon / gist:8420731
Created January 14, 2014 16:04
QuickSort
function swap(items, firstIndex, secondIndex){
var temp = items[firstIndex];
items[firstIndex] = items[secondIndex];
items[secondIndex] = temp;
}
function partition(items, left, right){
var pointer = Math.floor((left+right)/2);
var i = left;
var j = right;
@motiooon
motiooon / gist:8408927
Created January 13, 2014 21:57
O(n^2) String computation to find reverse words
function reverse_word(w){
return w.split("").reverse().join("");
}
// O(n^2) Implementation
function hasreverse(string){
var s_length = string.length;
var words_reversed=[];

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

SECONDARY> rs.conf()
{
"_id" : "rs0",
"version" : 5,
"members" : [
{
"_id" : 0,
"host" : "127.0.0.1:27017"
},
{
@motiooon
motiooon / gist:5162042
Created March 14, 2013 15:02
Replica set
{
set: "rs0",
date: {
$date: "Thu Mar 14 11:00:32 2013"
},
myState: 2,
members: [
{
_id: 0,
name: "127.0.0.1:27017",
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@motiooon
motiooon / gist:3099844
Created July 12, 2012 18:14
encoding?
����JFIFHH���Photoshop 3.08BIM�xHH
����,6G{�'8BIM�,,8BIM� 8BIM�H/fflff/ff���2Z5-8BIM�p��������������������������������������������������������������������������������������������8BIM8BIM8BIM@@8BIM O�j���3����JFIFHH�� Adobe_CM��Adobed����   
   

   ��j�"��
��?

 3!1AQa"q�2���B#$R�b34r��C%�S���cs5���&D�TdE£t6�U�e�����u��F'���������������Vfv��������7GWgw��������5!1AQaq"2����B#�R��3$b�r��CScs4�%���&5��D�T�dEU6te������u��F���������������Vfv��������'7GWgw������� ?�!����
�����:�:+ ��<��%! �ƍ���'7����oĤ�-H���z>6>5?W�n̆5����'�&�oq�F��Я��E��o3��6���~�q{��
@motiooon
motiooon / gist:3099416
Created July 12, 2012 17:10
data in response to a request
/9j/4AAQSkZJRgABAQEASABIAAD/7R3gUGhvdG9zaG9wIDMuMAA4QklNA+kAAAAAAHgAAwAAAEgASAAAAAADDQIa/+L/4wMsAjYDRwV7A+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABJw8AAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4QklNA+0AAAAAABABLAAAAAEAAgEsAAAAAQACOEJJTQPzAAAAAAAJAAAAAAAAAAABADhCSU0D9QAAAAAASAAvZmYAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAAAQAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP////////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA/////////////////////////////wPoAAA4QklNBAQAAAAAAAccAgAAAgACADhCSU0EBgAAAAAABwAGAAAAAQEAOEJJTQQIAAAAAAAQAAAAAQAAAkAAAAJAAAAAADhCSU0EDAAAAAAXTwAAAAEAAACgAAAAagAAAeAAAMbAAAAXMwAYAAH/2P/gABBKRklGAAECAABIAEgAAP/tAAxBZG9iZV9DTQAB/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgICAkIDAkJDBELCgsRFQ8MDA8VGBMTFRMTGBEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAENCwsNDg0QDg4QFA4ODhQUDg4ODhQRDAwMDAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAagCgAwEiAAIRAQMRAf/dAAQACv/EAT8AAAEFAQEBAQEBAAAAAAAAAAMA
@motiooon
motiooon / gist:2999909
Created June 26, 2012 22:55
request image
app.get('/photos/hires/:id', function(req,res){
request({
//encoding: null,
method: 'GET',
uri: _photo
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.attachment(body);
}
})