Skip to content

Instantly share code, notes, and snippets.

View meaku's full-sized avatar

Michael Jaser meaku

View GitHub Profile
@meaku
meaku / sim
Created November 4, 2016 16:17
"use strict";
const performance = window.performance;
function streamedPolling(baseUrl, onItem) {
return fetch("https://" + baseUrl + "/streamed-polling")
.then(response => {
const decoder = new TextDecoder();
const reader = response.body.getReader();
let buffer = "";
@meaku
meaku / .htaccess
Created March 18, 2013 13:14
.htaccess for SSL via SNI to prevent the certificate-error for unsupported browsers. Always share http links and https will be used if supported. Otherwise the connection will be http. SNI is not supported on IE on Windows XP (5 - 8) and Android < 4.x __Important Note__ Don't use this .htaccess if you need HTTPS for all your clients. It is just …
# HTTP(S) Stuff
# Redirect all users except IE 5-8 & Android < 4 to HTTPS
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_USER_AGENT} !MSIE\ [5-8]
RewriteCond %{HTTP_USER_AGENT} !Android.*(Mobile)?\ [0-3]
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
@meaku
meaku / pi-temp.js
Last active February 6, 2017 16:31
"use strict";
//hardware modules
const Raspi = require("raspi-io");
const five = require("johnny-five");
const board = new five.Board({
io: new Raspi()
});
//networking modules
# set default Maildir
MAILDIR="$HOME/Maildir"
# check if we're called from a .qmail-EXT instead of .qmail
import EXT
if ( $EXT )
{
# does a vmailmgr user named $EXT exist? if yes, deliver mail to his Maildir instead
CHECKMAILDIR = `dumpvuser $EXT | grep '^Directory' | awk '{ print $2 }'`
if ( $CHECKMAILDIR )
//PIN 12 (BCM18)
const ws281x = require("rpi-ws281x-native");
const numLeds = 10;
ws281x.init(numLeds);
let pixelData = new Uint32Array(numLeds);
pixelData = [
[255,0,0],
@meaku
meaku / params.js
Created April 21, 2020 18:51
something qs.stringify with indice style for UrlSearchParams
function appendObject(params, obj, prefix) {
for (let key of Object.keys(obj)) {
if (typeof obj[key] === "object") {
appendObject(params, obj[key], prefix ? `${prefix}[${key}]` : key);
} else {
params.append(prefix ? `${prefix}[${key}]` : key, obj[key]);
}
}
return params;
@meaku
meaku / test.js
Created October 6, 2021 09:58
test.js
Hello2();
(()=>{var Kt=Object.create;var lt=Object.defineProperty,zt=Object.defineProperties,Yt=Object.getOwnPropertyDescriptor,Qt=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,ee=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var Pt=(t,o,r)=>o in t?lt(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,k=(t,o)=>{for(var r in o||(o={}))At.call(o,r)&&Pt(t,r,o[r]);if(kt)for(var r of kt(o))ne.call(o,r)&&Pt(t,r,o[r]);return t},H=(t,o)=>zt(t,Qt(o));var re=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var oe=(t,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of te(o))!At.call(t,a)&&a!==r&&lt(t,a,{get:()=>o[a],enumerable:!(i=Yt(o,a))||i.enumerable});return t};var ie=(t,o,r)=>(r=t!=null?Kt(ee(t)):{},oe(o||!t||!t.__esModule?lt(r,"default",{value:t,enumerable:!0}):r,t));var Mt=(t,o,r)=>{if(!o.has(t))throw TypeError("Cannot "+r)};var T=(t,o,r)=>(Mt(t,o,"read from private field"),r?r.call(t):o
@meaku
meaku / gist:ad1e76df00d8ad8daa5c
Last active December 7, 2022 01:58
iojs / node.js flamegraphs using perf

Prerequisites

Record perf data

perf record -i -g -e cycles:u -- node --perf-basic-prof app.js

  • generate some load!