Skip to content

Instantly share code, notes, and snippets.

View VincentHelwig's full-sized avatar
🏠
Working from home

Vincent Helwig VincentHelwig

🏠
Working from home
View GitHub Profile
@VincentHelwig
VincentHelwig / gist:4548b388dc11b25eebfa
Last active August 29, 2015 14:08
Javascript Url Parsing with regexp
// FROM http://jsperf.com/url-parsing
var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
var url = "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content";
urlParseRE.exec(url);
0: "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content"
1: "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread"
2: "http://jblas:password@mycompany.com:8080/mail/inbox"
3: "http://jblas:password@mycompany.com:8080"
// FROM http://jsperf.com/compare-array-unique-versions/4
Array.prototype.getUnique = function () {
var arr = this;
var newArr = [],
i = 0,
j = 0,
obj = {},
len = arr.length;
while (len--) {
if (!obj[arr[i]]) {
@VincentHelwig
VincentHelwig / gist:a6900c85b4e1365e331e
Created November 5, 2014 16:44
Quick Drush Uninstall/Reinstall of a Custom Module
drush pm-disable mymodule
drush pm-uninstall mymodule
drush pm-enable mymodule
@VincentHelwig
VincentHelwig / gist:5f5152fce47953e866f3
Last active August 29, 2015 14:08
Console log Fallback
var console = console || {
log: function( ){ },
info: function( ){ },
warn: function( ){ },
table: function( ){ }
};
@VincentHelwig
VincentHelwig / gist:c59015404272b6b310b3
Last active August 29, 2015 14:08
Art-ev Friday Tech
**History**
http://en.wikipedia.org/wiki/File:Mosaic_Netscape_0.9_on_Windows_XP.png
http://dailyjs.com/2010/05/24/history-of-javascript-1/
http://dailyjs.com/2010/05/31/history-of-javascript-2/
http://dailyjs.com/2010/06/07/history-of-javascript-3/
...
** How browsers work **
http://taligarsiel.com/Projects/howbrowserswork1.htm
<a href="mailto:mail@hostname.com">Email</a>
<a href="tel:01234567890">Phone Number</a>
<a href="callto:01234567890">Skyper Number</a>
// FROM : http://playground.deaxon.com/js/vanilla-js/
// and complement : http://putaindecode.fr/posts/js/de-jquery-a-vanillajs/
Events
$(document).ready(function() { }); document.addEventListener("DOMContentLoaded", function() { });
$("a").click(function() { }) [].forEach.call(document.querySelectorAll("a"), function(el) {
el.addEventListener("click", function() {});
});
Selectors
@VincentHelwig
VincentHelwig / push.js
Last active August 29, 2015 14:22
Cordova PushPlugin
var app = angular.module('pushApp');
app.run(function(PushFactory) {
document.addEventListener('deviceready', function () {
PushFactory.init();
});
});
app.factory('PushFactory', ['CONFIG', '$http', function(CONFIG, $http) {
'use strict';
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
main =
Html.beginnerProgram { model = model, view = view, update = update }
-- MODEL
[user]
name = xxx
email = xxx@domain
[push]
# Default push should only push the current branch to its push target, regardless of its remote name
default = upstream
# When pushing, also push tags whose commit-ishs are now reachable upstream
followTags = true
[color]