Skip to content

Instantly share code, notes, and snippets.

@guilbep
guilbep / quickBubbleSort.c
Last active December 31, 2015 05:58
I made a bubble sort algorithm not very effective just for the purpose of showing how.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct list {
struct list* next;
int value;
} s_list;
@guilbep
guilbep / Gruntfile.js
Created December 13, 2013 15:54
best grunt file
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
files: [{
expand: true,
cwd: './partials/',
@guilbep
guilbep / Preferences.sublime-settings
Created December 13, 2013 16:12
My sublime text 3 user preferences
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"font_size": 9,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
80
@guilbep
guilbep / fakefilternewday
Last active August 29, 2015 13:56
New property for each day
module.filter('setDayApart', function() {
return function(input) {
var res = [];
var dayBefore;
angular.forEach(input, function(row, key) {
if (row.day !== dayBefore) {
row.newDay = true;
}
res.push(row);
dayBefore = row.day;
@guilbep
guilbep / $resourceWrapper for retry + timeout
Created February 25, 2014 16:10
Create $resource wrapper with retry and timeout
(function(window, angular, document, undefined) {
'use strict';
angular.module('mmResource', ['ng', 'ngResource']).
provider('mmResource', function(){
var common = this.common = {
retryTimeout : 4000,
retryMax: 3
};
define(['resources/resources-module'], function(module) {
module.factory('lolRSRC', ['customResource', '$rootScope', '$q',
function(customResource, $rootScope, $q) {
var defer = $q.defer();
$rootScope.$on('$locationChangeSuccess', function(){
test.test();
});
var test = customResource(
apiUrl + "fafeeafe/:item", {
@guilbep
guilbep / morris-directive.js
Created March 26, 2014 14:59
Morris directive
define(['directives/directive-module', 'morris'], function(module, Morris) {
module.directive('xngMorris', function($parse, $compile, $interval) {
return {
restrict: 'A',
scope: true,
controller: function($scope, $element, $attrs, $transclude) {
var morris;
// var isDataSet = false;
define(['directives/directives-module'], function(module) {
module.directive('xngTooltip', function($parse) {
return {
restrict: 'A',
priority: 0,
scope: true,
link: function postLink(scope, element, attrs, ctrl) {
var getter = $parse(attrs.xngTooltip),
setter = getter.assign,
value = getter(scope);
module.filter('cutTree', [
function() {
return function(tree) {
var res = [];
var i = 0;
angular.forEach(tree, function(tree1) {
var level1 = {};
var level2 = [];
angular.forEach(tree.children, function(tree2) {
@guilbep
guilbep / xngDisabled
Last active August 29, 2015 14:06
Directive to disable all childrens but some
module.directive('xngDisabled', function($parse) {
return {
restrict: 'A',
scope: {
xngDisabled : "@"
},
link: function (scope, element, attrs, ctrl) {
var setDisable = function (el, disable){
if(disable === "true") {
//condition-disabled