Skip to content

Instantly share code, notes, and snippets.

View Alexintosh's full-sized avatar
🧑‍🍳
Baking

Alessio Delmonti Alexintosh

🧑‍🍳
Baking
View GitHub Profile
@Alexintosh
Alexintosh / $localstorage
Created March 18, 2015 11:59
Angular factory for local storage
.factory('$localstorage', ['$window', function($window) {
return {
set: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key, defaultValue) {
return $window.localStorage[key] || false;
},
setObject: function(key, value) {
$window.localStorage[key] = JSON.stringify(value);
//app.js
.run(function($ionicPlatform, $notification, androidConfig, iosConfig) {
$ionicPlatform.ready(function() {
if( ionic.Platform.isWebView() ){
var push = $window.PushNotification.init({
"android": androidConfig,
"ios": iosConfig,
"windows": {}
@Alexintosh
Alexintosh / SearchHelper
Last active October 19, 2015 11:53
Helper to search text inside objects
(function(){
'use strict';
angular
.module('ad-utils')
.factory('SearchHelper', Search);
function Search($log, $filter){
var service = {
string: searchStrInObj
@Alexintosh
Alexintosh / JS Regex
Created December 3, 2015 18:15
Regex ex
UK NUMBERS
$scope.phoneRegex = /^(\s*(\s*^\+44\s*)|^(\s*4{2})|(\s*^0{2}4{2}\s*)|(\s*^0)\s*|)(\s*[123456789]\s*)(\s*\d\s*){8,9}\s*$\s*/;
//WARNING This regex will accept only UK numers (+447, 07)
$scope.phoneRegex = /^(\s*(\s*^\+44\s*)|^(\s*4{2})|(\s*^0{2}4{2}\s*)|(\s*^0)\s*|)(\s*[7]\s*)(\s*\d\s*){9}\s*$\s*/;
//Generic phone number
var doc = new $window.jsPDF("p", "mm", "a4");
$timeout(function(){
$window.html2canvas( $document[0].getElementsByClassName('print-pass'), {
onrendered: function(canvas){
var imgData = canvas.toDataURL('image/png');
//Page size in mm
var pageHeight = 295;
var imgWidth = 210;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
(function(){
'use strict';
angular
.module('app')
.directive('hideTabs', function($rootScope) {
return {
restrict: 'A',
link: function($scope, $el) {
$rootScope.hideTabs = 'tabs-item-hide';
(function(){
// Find all YouTube videos
var $allVideos = $(".video_responsive"),
// The element that is fluid width
$fluidEl = $("body");
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
$(this)
(function(){
'use strict';
angular
.module('adutils.ui')
.directive('counterSelector', function() {
return {
restrict: 'E',
replace: true,
template: '<div><div class=row><button class="button button-outline col-20 f50 secondary ion-minus-circled"ng-click=sub()></button><div class=col><div style=font-size:74px;padding:10px;font-weight:bolder>{{valLabel}}</div></div><button class="button button-outline col-20 f50 secondary ion-plus-circled"ng-click=plus()></button></div><h4 class="onb-subtitle tcenter">years of experience</h4></div>',
(function(){
'use strict';
angular
.module('starter')
.factory('$openAmat', openAmat);
function openAmat($log, $http, $q){
var service = {
nearBy: nearBy,
@Alexintosh
Alexintosh / diff
Last active August 6, 2019 02:26
React boilerplate in subfolder
internals/webpack/webpack.base.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
File internals/webpack/webpack.prod.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
app/app.js