Skip to content

Instantly share code, notes, and snippets.

@Yaffle
Yaffle / gist:1287361
Last active April 27, 2024 04:19
crc 32 in javascript
function crc32(s/*, polynomial = 0x04C11DB7, initialValue = 0xFFFFFFFF, finalXORValue = 0xFFFFFFFF*/) {
s = String(s);
var polynomial = arguments.length < 2 ? 0x04C11DB7 : (arguments[1] >>> 0);
var initialValue = arguments.length < 3 ? 0xFFFFFFFF : (arguments[2] >>> 0);
var finalXORValue = arguments.length < 4 ? 0xFFFFFFFF : (arguments[3] >>> 0);
var table = new Array(256);
var reverse = function (x, n) {
var b = 0;
@ncornette
ncornette / .xinitrc
Created December 4, 2014 09:15
.xinitrc for kiosk mode
#!/bin/sh
# invoke global X session script
#. /etc/X11/Xsession
# HOW-TO :
# 1. Disable any Display Manager (lightdm/gdm/gdm3) from executing on startup
# 2. Allow user to start X :
# a. Edit /etc/X11/Xwrapper.config
# b. Set value : "allowed_users=anybody"
# 3. insert "su kiosk -c xinit &" into /etc/rc.local
@yvele
yvele / get-npm-package-version.sh
Last active April 27, 2024 04:19
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
echo $PACKAGE_VERSION
@jmshal
jmshal / designer.html
Created August 15, 2014 23:22
designer
<link rel="import" href="../core-input/core-input.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
// Red
$color-red-50: #fde0dc;
$color-red-100: #f9bdbb;
$color-red-200: #f69988;
$color-red-300: #f36c60;
$color-red-400: #e84e40;
$color-red-500: #e51c23;
$color-red-600: #dd191d;
$color-red-700: #d01716;
$color-red-800: #c41411;
// Created by Max Luster (@maxluster)
// Usage instructions at https://bugsnag.com/blog/responsive-typography-with-chained-media-queries
// Requires SASS >= 3.3
// Enhanced by Breakpoint 2.4.x and Compass 1.0 (alpha)
// For SASS 3.2.x support, use https://gist.github.com/maxluster/c9ecc6e4a6770e507c2c
// Provides a simplified syntax for chaining media queries across named or numeric breakpoints
@mixin responsive($properties, $default-value, $responsive-values){
// No named breakpoints by default
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
Uncaught TypeError: Cannot set property 'exports' of undefined main.js:9200
defineExport main.js:9200
browserifyShim main.js:9198
browserifyShim main.js:9200
(anonymous function) main.js:9204
require.AyKrkQ main.js:9206
s main.js:1
(anonymous function) main.js:1
require../core/button.js main.js:9215
s main.js:1
@jmshal
jmshal / test.js
Created March 21, 2015 06:35
Playing around with DataView and ArrayBuffer in JavaScript...
var typeReference = [
['Byte', 'Int8' ],
['UnsignedByte', 'Uint8' ],
['Short', 'Int16' ],
['UnsignedShort', 'Uint16' ],
['Long', 'Int32' ],
['UnsignedLong', 'Uint32' ],
['Float', 'Float32'],
['Double', 'Float64']
];