Skip to content

Instantly share code, notes, and snippets.

View Dr4K4n's full-sized avatar

Stefan Ortgies Dr4K4n

View GitHub Profile
@alexandrevicenzi
alexandrevicenzi / index.html
Last active September 25, 2024 00:16
Bootstrap CSS Animate Loading Icon Button
<!-- Code snippet -->
<div class="form-group">
<div class="col-md-12 text-center">
<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>
</div>
</div>
@kevinwestern
kevinwestern / angular-indexeddb.js
Created May 10, 2014 19:30
Angular indexedDB
// Code goes here
var myApp = angular.module('myApp', ['ngResource']);
myApp.factory('indexedDB', ['$window', '$q', function($window, $q) {
var version = 2;
var indexedDB = $window.indexedDB;
var request = indexedDB.open('myapp', version);
var db = null;
var defer = $q.defer();
@akhoury
akhoury / handlebars-helper-x.js
Last active February 17, 2024 13:25
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " name == 'Sam' && age === '12' " }}
BOOM
@stephanvd
stephanvd / multifact_sum_aggregator.js
Created October 31, 2013 09:33
Aggregate over multiple fact fields. Result looks like this: http://imgur.com/fI636rq The aggregator returns first field for renderers without multifield support. The renderer is a modified version of the built-in table to support multifield. Quick and dirty but it gets the job done. For https://github.com/nicolaskruchten/pivottable.
multifactSumAggregator = function() {
return function(facts) {
return function() {
var summedFacts = {};
for (_i = 0, _len = facts.length; _i < _len; _i++) {
summedFacts[facts[_i]] = 0
}
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@janmoesen
janmoesen / switcheroo.sh
Created November 1, 2011 22:14
Atomic symlink switcheroo test script for GNU mv
#!/bin/bash
# Make a temporary directory for our little test.
mkdir linkage.tmp || exit $?;
cd linkage.tmp;
# Create two directories and a symlink to the first.
rm -rvf v1 v2 current;
mkdir v1 v2;
ln -s v1 current;