Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
echo $?

✨Eloone eloone

💭
echo $?
View GitHub Profile
View onceRendered.js
/*
Usage:
$onceRendered(function(){ // do your thing});
*/
(function(angular){
'use strict';
angular.module('app.lib.onceRendered', [])
.factory('$onceRendered', ['$U', '$http', '$timeout', ServiceFactory]);
function ServiceFactory($U, $http, $timeout){
View interceptor.js
(function(angular){
angular.module('app.lib.http.interceptorRequestFormatter', ['nvision.lib.xmlRequestFormatter'])
.config(['$httpProvider',function($httpProvider) {
$httpProvider.interceptors.push('InterceptorRequestFormatter');
}])
.factory('InterceptorRequestFormatter', ['XmlRequestFormatter', InterceptorRequestFormatterProvider]);
function InterceptorRequestFormatterProvider(XmlRequestFormatter){
// Formats the request data
@eloone
eloone / upload_file.js
Created Jul 25, 2015
upload file in angularjs
View upload_file.js
(function(angular){
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(this.target);//Select the entire contents of the element with the range
range.setEnd(this.target.firstChild, 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
selection.addRange(range);
@eloone
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
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
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
eloone / key_values.js
Created Oct 7, 2013
Print key value pairs in Handlebars
View key_values.js
/*
data = {
ctrl_path:
{ message: 'Validator "required" failed for path ctrl_path with value ``',
name: 'ValidatorError',
path: 'ctrl_path',
type: 'required',
value: '' },
@eloone
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-completion.sh
#git prompt
source ~/.git-prompt.sh
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
@eloone
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);
_this_.rest = 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');
You can’t perform that action at this time.