Skip to content

Instantly share code, notes, and snippets.

View nielk's full-sized avatar
🦊

Alexandre Oger nielk

🦊
View GitHub Profile
@nielk
nielk / binary-search.md
Last active August 29, 2015 14:12
binary-search.algo

Binary Search

  1. set min to 0 and max to array length
  2. compute guess as the result of (min + max)/2 rounded down
  3. if guess is greater than target value then I set max to guess - 1
  4. if guess is lesser than target value then I set min to guess + 1
  5. if guess is equal to target value I return guess
  6. if max < min or min > max then the target value is not contained in array
  7. if guess is not equal to target value I return to step 2.
@nielk
nielk / pre-commit.sh
Created December 18, 2014 13:43
pre-commit test js
# pre-commit: run casperjs tests
echo "**********************************"
echo "pre commit ..."
echo "**********************************"
if [ -x "$(command -v casperjs)" ]; then
echo "**********************************"
echo "executing test"
echo "**********************************"
@nielk
nielk / oop.js
Created October 29, 2014 08:57
OOP javascript object inheritance constructor prototype
/**
* Animal constructor
**/
var Animal = function(name) {
this.name = name;
};
Animal.prototype.speak = function() {
console.log('my name is ' + this.name);
};
@nielk
nielk / app.js
Last active August 29, 2015 14:07
app manager vhost subdomain nodejs express
var evh = require('express-vhost'),
express = require('express'),
server = express(),
PORT = 80;
server.use(evh.vhost());
server.listen(PORT);
evh.register('test.alexandreoger.eu', require('./test/index.js').app);
// evh.register(domain, server);
@nielk
nielk / drush.txt
Created July 28, 2014 07:57
drush cache disable
drush vset cache 0
drush vset preprocess_css 0
drush vset preprocess_js 0
@nielk
nielk / gist:9262c152867a7dba8337
Created July 16, 2014 18:57
baseline grid css
#baseline.show-grid {
background: -webkit-linear-gradient(top,rgba(50,50,50, 0.2)0,rgba(50,50,50, 0.2)1px,rgba(255, 255, 255, 0)1px,rgba(255, 255, 255, 0)2px);
background: -webkit-gradient(linear,left top,left bottom,color-stop(0px,rgba(50,50,50,.2)),color-stop(1px,rgba(50,50,50,.2)),color-stop(1px,rgba(255,255,255,0)),color-stop(2px,rgba(255,255,255,0)));
background: linear-gradient(to bottom,rgba(50,50,50, 0.2)0,rgba(50,50,50, 0.2)1px,rgba(255, 255, 255, 0)1px,rgba(255, 255, 255, 0)2px);
background-size: 100% 1rem;
}
@nielk
nielk / js-checklist.md
Last active August 29, 2015 14:02
Javascript checklist

Javascript checklist

Legend:

☐ item

✔ item done

Checklist

☐ use 'use strict';

@nielk
nielk / EventFactory.js
Created June 11, 2014 13:40
Event scroll touch click
//
// .important touch/click event
// ==========================================================================
/**
* Event factory
*/
var eventFactory = function($elt, callback) {
var flag = true;
var touchStartPos;
@nielk
nielk / index.html
Created June 3, 2014 13:01
menu toggle scroll
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container">
<h1>
Lorem ipsum
</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque, suscipit velit nihil deleniti cumque reiciendis ea expedita commodi aut nemo assumenda asperiores harum dolorum ipsum at quidem ad iste fugiat. consectetur adipisicing elit. Neque, suscipit velit nihil deleniti cumque reiciendis ea expedita commodi aut nemo assumenda asperiores harum dolorum ipsum at quidem ad iste fugiat. </p>
@nielk
nielk / my-module.js
Last active August 29, 2015 14:01
javascript pattern with jquery
var myModule = (function($, window) {
// private property
var myProp = "hello";
// private methods
function myPrivateMethod() {
alert($('*').length);
};
// public methods
return {
init: function() {