Skip to content

Instantly share code, notes, and snippets.

View yllieth's full-sized avatar
🇨🇦

Sylvain RAGOT yllieth

🇨🇦
View GitHub Profile
@yllieth
yllieth / gulpfile.js
Last active May 13, 2019 20:18
Cleaning generated files from ts/less compilation
const cleanGeneratedFilesBasedOn = (mapFileExtension, sourceFileExtension, otherExtensionsToDelete) => {
const debug = true;
const startTime = new Date().getTime();
if (!Array.isArray(otherExtensionsToDelete)) {
otherExtensionsToDelete = [];
}
const pattern = '{,!(node_modules)/**/}*' + mapFileExtension;
return glob(pattern, (err, files) => {
let toDelete = [];
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="page">
<div id="nav-top-bar">topbar</div>
@yllieth
yllieth / arrays.js
Last active March 30, 2017 13:35
standard operations on arrays/objects
// returns elements not ends
function elementsNotEndsBy(ending, array) {
var regex = new RegExp(ending + '$');
return array.filter(entry => !regex.test(entry));
}
elementsNotEndsBy('berry', ['strawberry', 'apple', 'blueberry']); // => ['apple']
elementsNotEndsBy('allEntries', ['strawberry', 'apple', 'blueberry']); // => ['strawberry', 'apple', 'blueberry']
elementsNotEndsBy('allEntries', []); // => []
@yllieth
yllieth / promise-all.js
Last active April 25, 2017 22:20
Catching error in chained promises
function fn1(previous) {
console.log('previous: ' + previous, 'current: step1');
return Promise.resolve('step1');
}
function fn2(previous) {
console.log('previous: ' + previous, 'current: step2');
return Promise.reject('step2');
}
@yllieth
yllieth / mixins.scss
Last active June 16, 2016 06:46
Foudation utility generator
// A row with fixed height, background-color and text-color. Useful to create topbars of footers
@mixin banner($bg: $body-background, $color: $body-font-color, $height: $banner-height) {
height: $height;
line-height: $height;
background-color: $bg;
color: $color;
};
// Fine positionning mixin. Useful to align rebellious elements
@mixin offset($size, $origin: top) {
// angular version
angular
.module('predicsis.tools.urlParser')
.factory('urlParser', function () {
function urlParser(url) {
var parser = document.createElement('a'), searchObject = {}, queries, split, i;
// Let the browser do the work
parser.href = url;
@yllieth
yllieth / 1-setup.sh
Last active August 29, 2015 14:11
Angular dependencies graph
sudo apt-get install graphviz
npm install grunt-angular-modules-graph --save-dev
npm install grunt-graphviz --save-dev
@yllieth
yllieth / app.js
Last active August 29, 2015 14:10
AngularJS templates
angular
.module('myHubApp', [...])
.factory('apiRestangular', function(Restangular, baseUrl) {
return Restangular.withConfig(function(RestangularConfigurer) {
RestangularConfigurer.setBaseUrl(baseUrl.API);
});
})
.factory('api', function(apiRestangular) {
return {
one: function(resource, id) {
@yllieth
yllieth / extension.js
Created November 6, 2014 10:59
Angular filter to extract extension from a file
angular.module('tools.filter')
.filter('extension', function() {
return function(input) {
return input.split('.').pop()
};
});
@yllieth
yllieth / uploadDirective.js
Last active August 29, 2015 14:08
S3 direct upload with angularJS and fineuploader
angular.module("hub.upload")
.directive("fineUploaderS3", function($compile, $interpolate, $translate, baseUrl) {
return {
restrict: "A",
replace: true,
link: function($scope, element, attrs) {
var wrapper = document.getElementById("upload-s3")
new qq.s3.FineUploader({