Skip to content

Instantly share code, notes, and snippets.

(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 November 20, 2014 14:05
Checks if an element is contentEditable
/**
* 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 August 29, 2015 14:13
Monkey-Patch: jquery-autocomplete.js (_renderItem & _renderMenu)
(function monkeyPatchJQueryAutocomplete($) {
/**
* Proxies a private
* prototype method to the
* options Object
*
* @param {Object} obj
* @param {String} funcName
*/
@HaNdTriX
HaNdTriX / execInNewTerminalTab
Created June 18, 2015 09:00
Opens a new Terminal Tab and executes command
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 December 23, 2015 21:48
Closure Compiler - Externsfile for ZeptoJS
/**
* @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 February 19, 2016 04:03
Ubuntu nginx pm2 nodejs
#!/bin/bash -e
# Update System
echo 'Update System Packages'
apt-get update
# Install git
echo 'Installing git'
apt-get install git -y

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 19:32
Creating a webextension generator

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 July 19, 2017 00:42
next.js withRoute hoc
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 April 19, 2018 17:09
Selectize Plugin to allow to set a maxlength
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);
};
})();
});