Skip to content

Instantly share code, notes, and snippets.

View cburgmer's full-sized avatar

Christoph Burgmer cburgmer

View GitHub Profile
@cburgmer
cburgmer / ng-i18next-filter.js
Created October 18, 2013 09:08
Simple i18next translation filter for angular This solves async issues with the filter accessing the translation function before i18next is ready. The solution here is not optimal but clearly maps out the solution, something that https://gist.github.com/archer96/5239617 or https://github.com/archer96/ng-i18next/blob/master/src/provider.js fails …
angular.module('myApp')
.run(['$rootScope', function ($rootScope) {
window.i18n.init(options, function () {
// When finished loading translations, trigger re-evaluation of views for translations
$rootScope.$digest();
});
}])
.filter('translate', [function(){
return function(key, params) {
// i18next needs time to initialize (loading translations). In this phase translation does not work
@cburgmer
cburgmer / tooltip-html-unsafe.html
Created September 30, 2013 15:33
Minimal test case for tooltip-html-unsafe issue in AngularUI Bootstrap
<!DOCTYPE html>
<html ng-app="minimalTestCase">
<head>
<meta charset="UTF-8">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<!--script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.js"></script>
<style>
div {
@cburgmer
cburgmer / mockeryTestCase.php
Last active December 23, 2015 10:38
Work around for Mockery to test for a specific call parameter setting when several calls are made to the same method
<?php
require_once 'Mockery/Loader.php';
require_once 'Hamcrest/Hamcrest.php';
require_once 'PHPUnit/Framework/TestCase.php';
$loader = new \Mockery\Loader;
$loader->register();
use Mockery as m;
function get(url, mimeType, successCallback, errorCallback) {
var page = require("webpage").create(),
basePageMatch = /^(https?:)?\/\/[^\/]+/.exec(url),
basePage = basePageMatch ? basePageMatch[0] : url;
// HACK for relative protocol support
if (basePage.indexOf("//") === 0) {
basePage = "http:" + basePage;
}
$ ruby failing.rb -D
D, [2013-02-01T21:20:06.591576 #91923] DEBUG -- : USING JID: alice@localhost
D, [2013-02-01T21:20:06.591841 #91923] DEBUG -- : SENDING: (/Users/cburgmer/.rvm/gems/ruby-1.9.3-p327/gems/blather-0.8.2/lib/blather/stream/client.rb:11:in `start') <stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
D, [2013-02-01T21:20:06.592978 #91923] DEBUG -- : RECEIVING (stream) <stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="2990861908" from="localhost" version="1.0" lang="en"/>
D, [2013-02-01T21:20:06.593362 #91923] DEBUG -- : RECEIVING (features) <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>SCRAM-SHA-1</mechanism>
</mechanisms>
@cburgmer
cburgmer / findlamerz.js
Created October 8, 2012 11:37
A hacky JS solution for finding the slowest steps in your Jenkins build
function findLamerz() {
/*
* Marks the slowest steps in your Jenkins Console output.
* 1. Enable Timestamper: https://wiki.jenkins-ci.org/display/JENKINS/Timestamper
* 2. Open your full Jenkins console output: http://TEH_JENKINS/job/TEH_BUILD_NAME/42/consoleFull
* 3. Open the JS console of your browser and paste the whole function
* 4. Run the following steps on the console, one after one: n = findLamerz(); n.next(); n.next(); ...
*/
function parseSecondsFromTimestamp(time) {
@cburgmer
cburgmer / firefoxTransparencyBug.html
Created September 11, 2012 23:34
Test case for bug in Firefox where a transparent image is not properly transferred
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test case for bug in Firefox where a transparent image is not properly transferred</title>
</head>
<body>
<script type="text/javascript">
function loadImage(url, callback) {
var image = new window.Image();
@cburgmer
cburgmer / firefoxBackgroundBug.html
Created September 6, 2012 20:12
Workaround for bug in Firefox when rendering background images in HTML to a canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test case for bug in Firefox where a background image in a SVG isn't rendered to the canvas unless a workaround is applied</title>
</head>
<body>
<canvas id="canvas" style="border:1px solid black;" width="200" height="200"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("canvas"),
@cburgmer
cburgmer / resizable.css
Created August 27, 2012 11:01
The smallest "resizable" implementation there is
.resizable {
resize: both; /* Options: horizontal, vertical, both */
overflow: auto; /* Options: scroll, hidden, auto */
}
@cburgmer
cburgmer / binaryfile.js
Created July 4, 2012 20:36
Reading a binary file through AJAX
// See https://developer.mozilla.org/en/DOM/XMLHttpRequest/Sending_and_Receiving_Binary_Data
var readBinaryFile = function (url) {
var content, newContent = "";
$.ajax({
dataType: 'text',
mimeType: 'text/plain; charset=x-user-defined',
url: url,
async: false,
cache: false,