Skip to content

Instantly share code, notes, and snippets.

View ComFreek's full-sized avatar
💭
I may be slow to respond.

ComFreek ComFreek

💭
I may be slow to respond.
View GitHub Profile
@ComFreek
ComFreek / bindObjEvt.js
Created September 29, 2012 19:38
bindObjEvt(): wrap functions in order to use other contexts and additional arguments
/**
* Wraps a function. It enables passing a new context and new arguments.
* @param func The actual function
* @param obj The context ('this' object) to pass to 'func'. If null is given, 'func' gets the context forwarded.
* @param args The arguments 'func' should receive. These will be added to the list of already passed arguments.
* @param addCtx Specifies whether the originally passed context should be added as an argument.
* @return A wrapper function.
*
* @author ComFreek
* @license Public Domain. Attribution optional.
@ComFreek
ComFreek / circleAnimater.js
Created December 27, 2012 17:17
CircleAnimater - animates any DOM object like a circle
// requestAnim shim layer by Paul Irish
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element) {
window.setTimeout(callback, 1000 / 60);
};
@ComFreek
ComFreek / extract-iso-lang-codes.js
Last active December 10, 2015 16:38
Extract all ISO 639-1 language codes from the Wikipedia article's table: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes.
// Wikipedia article: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
// jQuery Bookmarklet: http://marklets.com/jQuerify.aspx
// Extract language names
var str = ""; $("table td:nth-child(3)").each(function (idx, val) {str += $(val).text() + "\n";}); $("#bodyContent").prepend($("<textarea></textarea>").val(str));
// Extract language codes (2 characters)
var str = ""; $("table td:nth-child(5)").each(function (idx, val) {str += $(val).text() + "\n";}); $("#bodyContent").prepend($("<textarea></textarea>").val(str));
@ComFreek
ComFreek / extract-iso-country-codes.js
Created January 5, 2013 15:57
Extract all ISO 3166-1 country codes from the Wikipedia article's table: http://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements.
// Wikipedia article: http://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements
// jQuery Bookmarklet: http://marklets.com/jQuerify.aspx
// Extract country codes
var str = ""; $("table td:nth-child(3)").each(function (idx, val) {str += $(val).text() + "\n";}); $("#bodyContent").prepend($("<textarea></textarea>").val(str));
@ComFreek
ComFreek / Gruntfile.js
Created November 3, 2013 12:19
Default Gruntfile.js I get when creating a new Yeoman project.
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@ComFreek
ComFreek / Error log.txt
Last active January 1, 2016 00:59
Vagrant / PuPHPet error log: Could not find a suitable provider for mysql_user
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'debian-wheezy72-x64-vbox43'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
@ComFreek
ComFreek / so-list.user.js
Last active July 30, 2016 15:44
Additional list toolbar button for StackOverflow editor windows (note: as an answer to the following question: http://softwarerecs.stackexchange.com/q/2833/583)
// ==UserScript==
// @name StackOverflow List Button
// @description Additional list toolbar button for StackOverflow editor windows
// @version 1.0
//
// @match *://stackoverflow.com/*
// @match *://meta.stackoverflow.com/*
// @match *://pt.stackoverflow.com/*
//
// @match *://serverfault.com/*
@ComFreek
ComFreek / all.js
Created March 31, 2014 11:02
Retrieve all StackExchange domains!
/*
* Must be run on http://stackexchange.com/sites?view=list#traffic
* Your popup blocker must be deactivated.
*/
var links = []; $(".lv-info a").each(function () {
links.push(this.href);
});
var str = links.join("\n");
window.open("data:text/plain;base64," + btoa(str), "Links");
@ComFreek
ComFreek / BufferedImageTranscoder.java
Last active October 8, 2024 02:40
JavaFX & Batik SVG Renderer: Minimal example
/**
* This is a compilation of code snippets required to render SVG files in JavaFX using Batik.
* See my full post on StackOverflow: http://stackoverflow.com/a/23894292/603003
*/
package proofofconcept;
import java.awt.image.BufferedImage;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderOutput;