Skip to content

Instantly share code, notes, and snippets.

echo $?

✨Eloone eloone

echo $?
View GitHub Profile
View onceRendered.js
$onceRendered(function(){ // do your thing});
'use strict';
angular.module('app.lib.onceRendered', [])
.factory('$onceRendered', ['$U', '$http', '$timeout', ServiceFactory]);
function ServiceFactory($U, $http, $timeout){
View interceptor.js
angular.module('app.lib.http.interceptorRequestFormatter', ['nvision.lib.xmlRequestFormatter'])
.config(['$httpProvider',function($httpProvider) {
.factory('InterceptorRequestFormatter', ['XmlRequestFormatter', InterceptorRequestFormatterProvider]);
function InterceptorRequestFormatterProvider(XmlRequestFormatter){
// Formats the request data
eloone / upload_file.js
Created Jul 25, 2015
upload file in angularjs
View upload_file.js
angular.module('folio.components.project.thumbUpload', [])
.factory('ThumbUpload', ['$q', '$http', '$log', ThumbUploadProvider]);
function ThumbUploadProvider($q, $http, $log){
function ThumbUploadService(){
this.upload = function(file, filename){
var deferred = $q.defer();
var fd = new FormData();
View set_caret_position.js
var range = document.createRange();//Create a range (a range is a like the selection but invisible)
range.selectNodeContents(;//Select the entire contents of the element with the range
range.setEnd(, pos);
range.collapse();//collapse the range to the end point. false means collapse to end rather than the start
selection = window.getSelection();//get the selection object (allows you to change selection)
selection.removeAllRanges();//remove any selections already made
eloone / binaryInsert.js
Last active Jun 22, 2019
Binary Insert
View binaryInsert.js
* Example :
* var a = [2,7,9];
* binaryInsert(8, a);
* It will output a = [2,7,8,9]
function binaryInsert(value, array, startVal, endVal){
eloone / regex.js
Created Oct 22, 2013
Some regexes
View regex.js
//matches type like kqsjdlqj@kjdfhdjhf (with @ in the middle)
if(/^[^@]+@[^@]+$/.test(type) === true){
eloone / filter_object_ppties.js
Last active Dec 25, 2015
Filter an object with another object's properties with UnderscoreJs. Allows to filter unwanted properties out of an object by mapping it on a reference object.
View filter_object_ppties.js
var book = {
title : 'brave new world',
author : 'aldous huxley',
rating : '2'
var params = {
title : 'lmkwxlkc',
eloone / key_values.js
Created Oct 7, 2013
Print key value pairs in Handlebars
View key_values.js
data = {
{ message: 'Validator "required" failed for path ctrl_path with value ``',
name: 'ValidatorError',
path: 'ctrl_path',
type: 'required',
value: '' },
eloone / .bashrc
Last active Dec 17, 2015
My git settings
View .bashrc
#append this to your .bashrc file in your home
#git auto-completion
source ~/
#git prompt
source ~/
eloone / calculate.js
Last active Dec 17, 2015
Recursive function to calculate a grid
View calculate.js
function calculate(cols, nb){
_this_.cols = cols;
_this_.rows = Math.ceil(nb/cols); = nb % cols;
_this_.boxDim = _this_.width/cols - 2*_this_.border;
if(_this_.boxDim <= 1){
debug.exec('warn', 'Dimensions of the boxes are too small to be seen');