Skip to content

Instantly share code, notes, and snippets.

Avatar

Henrik Wenz HaNdTriX

View GitHub Profile
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 / 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 / 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 / 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 / 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
View shortcuts.md

Shortcuts

Mac

Action Shortcut
Jump to the next open tab ⌘ + Option + Right arrow
⌘ + Option + Tab
Jump to the previous open tab ⌘ + Option + Left arrow
⌘ + Option + Shift + tab
@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
@HaNdTriX
HaNdTriX / withRoute.js
Created Jul 19, 2017
next.js withRoute hoc
View withRoute.js
import React from 'react'
import Router from 'next/router'
const widthRoute = (Component) => {
return class extends React.Component {
componentDidMount() {
this.route = Router.route()
this.forceUpdate()
}
@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);
};
})();
});
You can’t perform that action at this time.