Skip to content

Instantly share code, notes, and snippets.

View motiooon's full-sized avatar

Gabriel Baciu motiooon

View GitHub Profile
#!/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: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",
SECONDARY> rs.conf()
{
"_id" : "rs0",
"version" : 5,
"members" : [
{
"_id" : 0,
"host" : "127.0.0.1:27017"
},
{

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

@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=[];
@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: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:8421888
Created January 14, 2014 17:09
Binary Search
function bSearch(items, value){
var startIndex = 0;
var stopIndex = items.length-1;
var middle = Math.floor((startIndex + stopIndex)/2);
while(value !== items[middle] && startIndex < stopIndex){
if(value > items[middle]){
startIndex = middle + 1;
}else if(value < items[middle]){
@motiooon
motiooon / gist:8426785
Last active January 3, 2016 06:59
Find reversed words in a string. O(n) this time.
var string = "qwertyuiopasdfghjleirbaglgabrielmnbvcdrgythacnakancajuilsre";
function find_reverses(str){
var j = 0;
var potential_reverses = [];
while(j < string.length){
if(string[j] === string[j+2]){
potential_reverses.push({letter:string[j], index: j+2});
}
@motiooon
motiooon / boot.js
Created June 6, 2014 13:11 — forked from jdx/boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run