Skip to content

Instantly share code, notes, and snippets.

View motiooon's full-sized avatar

Gabriel Baciu motiooon

View GitHub Profile
@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{��
function lbPick (a){
var str = '';
a.forEach(function(field){
str+='&filter[fields]['+field+']=1';
});
return str;
}
function lbGetPage(page){
var str = '&filter[limit]=50&filter[skip]=' + ((page-1) * 50);
@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 / 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: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",