Skip to content

Instantly share code, notes, and snippets.

View JoostKiens's full-sized avatar

Joost Kiens JoostKiens

View GitHub Profile
@JoostKiens
JoostKiens / MakeReactComponent
Last active August 23, 2017 08:15
Make a React component.
#!/bin/bash -e
ORIGINAL_WORKING_DIR=$(pwd)
WORKSPACE=$(cd $(dirname $0); pwd)
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
NAME=""
@JoostKiens
JoostKiens / convertImageToGrayscale.js
Created February 19, 2015 12:50
Convert an image to grayscale using canvas, takes around 25 ms for an image of 500px x 400px
define(function () {
'use strict';
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
return function ($srcImg) {
var deferred = $.Deferred();
var srcImg = $srcImg[0];
@JoostKiens
JoostKiens / iBeaconCalculateDistance.js
Last active October 26, 2022 17:40
iBeacon calculate distance in meters
// Based on http://stackoverflow.com/a/20434019
function calculateAccuracy(txPower, rssi) {
if (rssi === 0) {
return -1; // if we cannot determine accuracy, return -1.
}
var ratio = rssi * 1 / txPower;
if (ratio < 1.0) {
return Math.pow(ratio, 10);
@JoostKiens
JoostKiens / index.html
Last active November 7, 2016 14:29
Checkboxes with css, no js
<div>
<input type="checkbox" id="floep">
<label for="floep">Floep</label>
</div>
<div>
<input type="checkbox" id="flap" checked="checked">
<label for="flap">Flap</label>
</div>
@JoostKiens
JoostKiens / jquery.toggleHtml.js
Created July 10, 2014 07:48
Advanced jQuery plugin to switch between one piece of html and another
/**
* Copyright (C) 2014 Joost Kiens
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@JoostKiens
JoostKiens / _media-queries.less
Created June 16, 2014 14:59
Named Media queries, drop in for bootstrap
/**
* Named media queries based on Bootstrap variables
* Usage:
* .module {
* @media @lg { … }
* @media @md, @sm { … }
* @media @md-or-less { … }
* }
*
* @lg-or-more (=> 1200) - - -
@JoostKiens
JoostKiens / localStorageUtils.js
Last active February 11, 2024 22:34
Simple AMD module with basic localStorage utilities
define(function () {
'use strict';
function removeItem(itemKey) {
localStorage.removeItem(itemKey);
}
function getItem(itemKey) {
return JSON.parse(localStorage.getItem(itemKey));
@JoostKiens
JoostKiens / .editorconfig
Created June 4, 2014 10:09
Editor Configuration file,
# see http://editorconfig.org/ for usage
# and editor support
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
@JoostKiens
JoostKiens / dutchLicensePlate.js
Last active August 23, 2017 11:09
Dutch License Plate Functions
define(function () {
'use strict';
function getSidecodeByLicensePlate (licensePlate) {
var sidecodes = [];
var i = 0;
licensePlate = licensePlate.replace(/-/g, '').toUpperCase();
// See http://nl.wikipedia.org/wiki/Nederlands_kenteken#Alle_sidecodes
@JoostKiens
JoostKiens / index.html
Last active December 14, 2015 07:19
A CodePen by Joost Kiens. CSS Page curl - CSS Page curl with one div.
<div class="curl"></div>
<h1>CSS Page Curl</h1>
<p>hover over page curl to resize</p>