Skip to content

Instantly share code, notes, and snippets.

@rikschennink
rikschennink / nudgeable.ts
Last active October 22, 2023 05:53
⌨️ A Svelte action to add arrow key interaction to an element
export default (element: HTMLElement, options: any = {}) => {
// if added as action on non focusable element you should add tabindex=0 attribute
const {
direction = undefined,
shiftMultiplier = 10,
bubbles = false,
stopKeydownPropagation = true,
} = options;
@petersirka
petersirka / parser-transform.js
Created March 19, 2017 22:15
Parse transform SVG attribute
String.prototype.parseTransform = function() {
var prop = ['translate', 'matrix', 'rotate', 'skewX', 'skewY', 'scale'];
var val = this.match(/(translate|matrix|rotate|skewX|skewY|scale)\(.*?\)/g);
var obj = {};
if (val) {
for (var i = 0, length = val.length; i < length; i++) {
var item = val[i];
var index = item.indexOf('(');
var v = item.substring(index + 1, item.length - 1).split(/\,|\s/);
var n = item.substring(0, index);
@mlynch
mlynch / cordova-plugin-guide.md
Last active February 3, 2023 00:21
Cordova Plugin Developer Guide

Cordova Plugin Development Guide (iOS and Android)

Version: 0.0.1 updated 7/1/2016

Cordova Plugins are the magic that enable our mobile web app content to access the full power of Native SDKs underneath, but through clean JavaScript APIs that work the same across all platforms we target.

Building Cordova plugins is scary for many Cordova and Ionic developers, but it doesn't have to be. This simple guide walks through the what, when, why, and how of Cordova plugin development for iOS and Android.

Introduction

# Example integration of a background-image uploader
# Author: Guillaume Piot
# Email: guillaume@cotidia.com
# Company: Cotidia Ltd
# Licence: MIT
#
# The div holder is absolute positioned within the parent div
#
# <div class="[ article__image ] [ article-image ] [ editable ] [ parallax ]" data-name="article_image">
# <div
@ProLoser
ProLoser / AngularJS-Cachebusting.js
Last active September 10, 2020 12:54
Elegant cache-busting for AngularJS HTML assets
anglar.module('myApp',['ui']).config(["$provide", function($provide) {
return $provide.decorator("$http", ["$delegate", function($delegate) {
var get = $delegate.get;
$delegate.get = function(url, config) {
// Check is to avoid breaking AngularUI ui-bootstrap-tpls.js: "template/accordion/accordion-group.html"
if (!~url.indexOf('template/')) {
// Append ?v=[cacheBustVersion] to url
url += (url.indexOf("?") === -1 ? "?" : "&");
url += "v=" + cacheBustVersion;
}
@alanstevens
alanstevens / install_all.sh
Created March 19, 2012 18:29
Server Setup
#!/usr/bin/env bash
#
# execute this script as root with:
# curl https://raw.github.com/gist/2123030/install_all.sh | bash -s MyAwesomeHostName
#
if [[ ! "root" = "$(whoami)" ]] ; then
echo -e "****\nThis script must be run as root.\n****" && exit 1
fi
@alanstevens
alanstevens / install-packages.sh
Created December 19, 2011 22:29
A script to install/uninstall my default packages on a fresh Linux Mint system.
#! /usr/bin/env bash
#
# execute this script with:
# curl https://raw.github.com/gist/1499222/install-packages.sh | sudo bash -s <username> <public_key_url>
# curl https://raw.github.com/gist/1499222/install-packages.sh | sudo bash -s 'alan' 'https://dl.dropbox.com/s/qfo16yktbn23q9j/id_rsa.pub?dl=1'
#
user_name=$1
public_key=$2
@aronwoost
aronwoost / README.md
Created July 25, 2011 19:48
Build auto-deploy with php and git(hub) on an EC2 Amazon AMI instance

Kind of continue from the other gist how to install LAMP on an Amazon AMI

##Install git

sudo yum install git-core

##Create ssh directory since it doesn't exists by default on the Amazon AMI

@faisalman
faisalman / print_r.js
Last active September 13, 2021 02:57
PHP-like print_r() & var_dump() equivalent for JavaScript
/**
* PHP-like print_r() equivalent for JavaScript Object
*
* @author Faisalman <fyzlman@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/879208
*/
var print_r = function (obj, t) {
// define tab spacing