Skip to content

Instantly share code, notes, and snippets.

Avatar

Henrik Wenz HaNdTriX

View GitHub Profile
@HaNdTriX
HaNdTriX / gist:6698380
Last active Dec 23, 2015
Closure Compiler - Externsfile for ZeptoJS
View gist:6698380
/**
* @fileoverview Externs for Zepto v1.0
*
* Note that some functions use different return types depending on the number
* of parameters passed in. In these cases, you may need to annotate the type
* of the result in your code, so the JSCompiler understands which type you're
* expecting. For example:
* <code>var elt = /** @type {Element} * / (foo.get(0));</code>
*
* @see http://zeptojs.com/
@HaNdTriX
HaNdTriX / image_to_data_url.js
Last active Jul 2, 2020
Convert an image to base64URL.
View image_to_data_url.js
/**
* Converts an image to a dataURL
* @param {String} src The src of the image
* @param {Function} callback
* @param {String} outputFormat [outputFormat='image/png']
* @url https://gist.github.com/HaNdTriX/7704632/
* @docs https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Methods
* @author HaNdTriX
* @example
*
View Order HTML elements based on viewport
(function($) {
function OrderedNode(element) {
this.$element = $(element);
this.maxViewport = parseInt(this.$element.data(this.maxViewportName));
this.saveOldState();
this.decide();
if (this.maxViewport) {
// Todo: Throttle
@HaNdTriX
HaNdTriX / install.sh
Last active Feb 19, 2016
Ubuntu nginx pm2 nodejs
View install.sh
#!/bin/bash -e
# Update System
echo 'Update System Packages'
apt-get update
# Install git
echo 'Installing git'
apt-get install git -y
@HaNdTriX
HaNdTriX / is_content_editable.js
Created Nov 20, 2014
Checks if an element is contentEditable
View is_content_editable.js
/**
* Checks if an element is editable.
* Does this by checking parent
* elements as well.
*
* @param {Node} targetNode
* @return {Boolean}
*/
function isContentEditable(targetNode){
while(targetNode.parentElement){
@HaNdTriX
HaNdTriX / gist:c2500d0919de633157b9
Last active Aug 29, 2015
Monkey-Patch: jquery-autocomplete.js (_renderItem & _renderMenu)
View gist:c2500d0919de633157b9
(function monkeyPatchJQueryAutocomplete($) {
/**
* Proxies a private
* prototype method to the
* options Object
*
* @param {Object} obj
* @param {String} funcName
*/
@HaNdTriX
HaNdTriX / imgURLToDataURL.es6
Last active Oct 31, 2018
Convert an imageURL to a base64 dataURL via canvas
View imgURLToDataURL.es6
/**
* Convert an imageURL to a
* base64 dataURL via canvas
*
* @param {String} url
* @param {Object} options
* @param {String} options.outputFormat [outputFormat='image/png']
* @param {Float} options.quality [quality=1.0]
* @return {Promise}
* @docs https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Methods
@HaNdTriX
HaNdTriX / selectize.inputmaxlength.plugin.js
Last active Apr 19, 2018
Selectize Plugin to allow to set a maxlength
View selectize.inputmaxlength.plugin.js
Selectize.define('inputMaxlength', function(options) {
var self = this;
this.setup = (function() {
var original = self.setup;
return function() {
original.apply(this, arguments);
this.$control_input.attr('maxlength', this.settings.inputMaxlength);
};
})();
});
@HaNdTriX
HaNdTriX / execInNewTerminalTab
Created Jun 18, 2015
Opens a new Terminal Tab and executes command
View execInNewTerminalTab
function execInNewTerminalTab {
osascript -e 'tell application "Terminal"
activate
tell application "System Events" to keystroke "t" using command down
do script "'"$1"'" in window 1
end tell'
}
@HaNdTriX
HaNdTriX / README.md
Last active May 16, 2017
Creating a webextension generator
View README.md

Hi

I am Henrik and I want to create a webextension generator that supports chrome, firefox, opera and safari. The stack I would like to use will contain:

  • yeoman for scaffolding
  • gulp as a build system
  • webpack for script compilation (modules, env variables, polyfills)
  • npm as a module system
  • and babel for ES2015
You can’t perform that action at this time.