Skip to content

Instantly share code, notes, and snippets.

View mrpapercut's full-sized avatar

Mischa Rodermond mrpapercut

View GitHub Profile
@mrpapercut
mrpapercut / app.js
Last active September 29, 2023 17:15
Chrome Packaged App example
/*
* Javascript goes here
*/
@mrpapercut
mrpapercut / emailaddresses.txt
Last active September 17, 2015 13:17
List of fake emailaddresses based on A Song Of Ice And Fire characters
Adarys, Alequo, alequo.adarys@asoiaf-mail.org
Ahai, Azor, azor.ahai@asoiaf-mail.org
Allyrion, Delonne, delonne.allyrion@asoiaf-mail.org
Allyrion, Ryon, ryon.allyrion@asoiaf-mail.org
Alyn, Sour, sour.alyn@asoiaf-mail.org
Ambrose, Alyn, alyn.ambrose@asoiaf-mail.org
Ambrose, Arthur, arthur.ambrose@asoiaf-mail.org
Ambrose, Aubrey, aubrey.ambrose@asoiaf-mail.org
Ambrose, Edmund, edmund.ambrose@asoiaf-mail.org
Antaryon, Ferrego, ferrego.antaryon@asoiaf-mail.org
@mrpapercut
mrpapercut / RunAsAdmin.bat
Created September 17, 2015 08:12
Batch script that runs code as admin when called as non-admin
@ECHO OFF
GOTO checkAdmin
:: Check if batch-file is run with admin privileges
:checkAdmin
FSUTIL dirty query %systemdrive% >nul 2>&1
IF %errorLevel% == 1 (
GOTO isNotAdmin
) ELSE (
GOTO isAdmin
@mrpapercut
mrpapercut / colorContrast.js
Created January 7, 2016 13:04
Calculate if your text is readable on a colored background for colorblind people
/**
* ColorContrast
* Check if your text is readable on your background for colorblind people
*
* Usage:
* colorContrast(foregroundColor, backgroundColor)
* if true, the contrast is sufficient
*/
const hexToRgb = hex => {
@mrpapercut
mrpapercut / Viewport Helper
Last active November 19, 2016 19:17
Google Chrome 49 removed the Viewport Helper, an indicator that shows the dimensions of the current window. Especially useful when developing a responsive website
(() => {
const vpd = document.createElement('div'),
st = {
'position': 'fixed',
'right': '0',
'top': '0',
'border': '5px solid #ccc',
'background': '#ccc',
'font-family': 'Arial',
'font-size': '13px',
@mrpapercut
mrpapercut / api.js
Last active December 6, 2016 20:59
Webcam to Philips Hue. Logical file order: package.json, server.js, api.js, index.html
'use strict';
import {HueApi, lightState} from 'node-hue-api';
import creds from './constants/credentials'; // JSON object containing Hue Bridge ip-address and user credentials
class Api {
constructor() {
this.api = new HueApi(creds.hue.hostname, creds.user.username);
this.lights = [];
}
@mrpapercut
mrpapercut / SunriseSunset.js
Last active January 5, 2022 11:47
Philips Hue automatic lighting based on sunrise/sunset
/**
* Automatically turns on lights based on sunrise/sunset
* Usage: use cronjob to trigger every night after midnight
*
* NPM packages required: superagent, node-hue-api
*/
import request from 'superagent';
import HueApi from 'node-hue-api';
@mrpapercut
mrpapercut / generator.php
Created May 19, 2017 11:02
Generate strong passwords with PHP
<?php
$symbols = str_split('!$%@#');
$chars = str_split('abcdefghijklmnopqrstuvwxyz0123456789');
$pwlen = isset($_POST['len']) ? (int) $_POST['len'] : 64;
$pwlen = $pwlen > 1024 ? 1024 : $pwlen; // Max length: 1024
$useSyms = isset($_POST['sym']) && $_POST['sym'] === '0' ? false : true;
$passArr = array();
function getRand() {
import moment from 'moment-timezone';
const isFridayFiveOClock = () => {
const curtime = moment().tz('Europe/Amsterdam');
const nextFriday = moment().tz('Europe/Amsterdam').day(5).hour(17).minute(0).seconds(0);
if (moment().format('d') >= 5) {
nextFriday.add(1, 'week');
}
@mrpapercut
mrpapercut / Counter.js
Created March 30, 2018 07:59
ES Modules
class Counter {
constructor() {
this.n = 0;
}
count() {
return this.n++;
}
}