Skip to content

Instantly share code, notes, and snippets.

View weiland's full-sized avatar
🍫
🎓 && 💻 #GitHubDropICE

Pascal Weiland weiland

🍫
🎓 && 💻 #GitHubDropICE
View GitHub Profile
@weiland
weiland / defer.js
Created September 29, 2014 18:35
load deferred javascript files - (best practise, i tell ya!)
// put tis at the end of the body
function loadDeferred( ) {
var s = document.createElement( 'script' );
s.src = 'defer.js'; // concat all scripts which can be loaded deferred (listeners etc)
document.body.appendChild( s );
}
if ( window.addEventListener ) {
window.addEventListener( "load", loadDeferred, false );
}
@weiland
weiland / preloaderService.js
Last active August 29, 2015 14:07
Angular Image Preloader Service
(function () {
function PreloaderService( $http, $window, $q, ENV ) {
var PreloaderService = {};
PreloaderService.imageUrls = [];
PreloaderService.addImage = function ( imageUrl ) {
PreloaderService.imageUrls.push( imageUrl )
};
@weiland
weiland / console-shim.js
Created October 30, 2014 09:54
Console shim
(function( window ) {
if ( window.console ) {
return;
}
window.console = (function() {
var methods = 'assert,clear,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,table,time,timeEnd,timeStamp,trace,warn'.split(','),
console = {},
@weiland
weiland / Package Control.sublime-settings
Last active April 28, 2016 08:18
sublime 3 install package control
{
"in_process_packages":
[
],
"installed_packages":
[
"Alternate VIM Navigation",
"AutoFileName",
"Babel",
"Better CoffeeScript",
@weiland
weiland / xpath.js
Created November 14, 2014 18:56
xpath all links
Array.prototype.slice.call($x('//*[@id="mw-content-text"]/table/tbody/tr[*]/td[3]/a')).forEach(function(e,i) {console.log(e.href);})
@weiland
weiland / ItemsService.js
Last active March 15, 2016 12:21
Angular
(function () {
/**
* Deferred ItemsService
*/
function ItemsService($log, $http, $window, ENV) {
var ItemsService = {};
ItemsService.items = [];
@weiland
weiland / xhr-donwload.html
Created November 19, 2014 20:29
simple xhr downloader
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>xhr donwload</title>
</head>
<body>
<script>
var uri = 'https://domain.com/video.mp4';
var xhr = new XMLHttpRequest();
@weiland
weiland / Readme.md
Created November 26, 2014 20:34
jetbrains ide fix on mac os x yosemite

one has to change the required version number of Java to 1.*

Open /Applications/PhpStorm.app/Contents/Info.plist

<key>JVMVersion</key>
<string>1.*</string>
@weiland
weiland / trackPageView.js
Created November 28, 2014 12:25
Track PageView in Angular.js
angular.module('app')
.run(function($rootScope, $location, $routeParams, $window){
$rootScope.$on('$routeChangeSuccess', function() {
var params = [];
angular.forEach($routeParams, function(value, key){
params.push(key + '=' + value);
});
var locationPath = $location.path() + '?' + params.join('&');
$window._gaq.push(['_trackPageView', locationPath]);
});
@weiland
weiland / README.md
Last active August 29, 2015 14:10
ES6

Using ES6

compile js code: https://github.com/google/traceur-compiler

in node: node --harmony

in chrome: chrome://flags/#enable-javascript-harmony