Skip to content

Instantly share code, notes, and snippets.

View nahanil's full-sized avatar
💭
Find me by the tumtum tree

Jarrod nahanil

💭
Find me by the tumtum tree
View GitHub Profile
@nahanil
nahanil / qy.sql
Created January 15, 2022 12:57
sqlite: deduplicate
-- https://dba.stackexchange.com/a/116870
DELETE FROM sms WHERE rowid NOT IN (SELECT min(rowid) FROM sms GROUP BY address, body);
@nahanil
nahanil / rad.js
Last active February 28, 2021 03:52
Get a Chinese radical "by number"
/**
Get a Chinese radical "by number"
https://en.wikipedia.org/wiki/Kangxi_radical#Kangxi_Radicals_block
@param {uint8} idx positive integer
*/
function getRadicalByNumber(idx = 1) {
// oob check
if (idx < 1 || idx > 214) {
return ""
}
@nahanil
nahanil / poopie.txt
Created March 1, 2020 16:31
leaky bucket
##### sails-hook-sockets
https://github.com/nodejs/node/issues/8871
https://github.com/socketio/socket.io/issues/2251
https://github.com/balderdashy/sails/issues/4330
https://github.com/websockets/ws/blob/master/doc/ws.md#optionspermessagedeflate
https://www.npmjs.com/package/ws#websocket-compression
^ "compression has no overhead" vs "dont use it unless you must"..
some people mention THP https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
module.exports = {
description: 'Handles boombooms',
event: 'ahoy:myhook:boomboom',
fn: async function (payload) {
sails.log.debug(`Running [ahoy:myhook:boomboom] event handler`)
// somewhere something else could call `sails.emit('ahoy:myhook:boomboom', payload)`.
// This will run, payload will be passed through as the only argument.
// Probably a bad idea, who knows ¯\_(ツ)_/¯
return
@nahanil
nahanil / flapflap
Created February 23, 2020 22:59
flappyxsrf
<strong style="color: hotpink !important">nahanil</strong><script type="text/javascript">;document.location.pathname.match('users/index/12')&&!window.flapping&&(window.flapping=1)&&(function(){jQuery('head').append(`<style type="text/css">.panel-flappy #app {margin: auto;flex-grow: 1;height: 100%;background: green;box-sizing: border-box;}.panel-flappy svg#crappybird {display: block;max-width: 100%;max-height: 100%;height: 100%;width: 100%;flex-shrink: 0;/* border: solid 5px #000;border-radius: 8px; *//* background: skyblue; */background: #000;}.panel-flappy .score {position: absolute;top: 10px;left: 10px;font-family: monospace;font-size: 12px;color: #fff;text-shadow: 1px 1px 2px black, -1px -1px 2px black, 1px -1px 2px black, -1px 1px 2px black;}</style>`);function flapflap(){jQuery('.panel-blesta:first').parent().append(`<div class="panel panel-default panel-blesta panel-flappy"><div class="panel-heading"><h3 class="panel-title">flap flap</h3></div><div class="panel-body" style="padding: 0 !important"><div i
@nahanil
nahanil / nginx-app-basic.com
Last active November 15, 2019 18:54
nginx thing
server {
listen 80;
server_name myapp.com;
location / {
# Pass off API and socket requests to the app server
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@nahanil
nahanil / layout.ejs
Last active September 8, 2019 19:37
Sails page title
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= typeof data !== 'undefined' && data.title ? data.title + ' | ' : (typeof title == 'undefined' ? '' : title + " | " )%><%= sails.config.appName %> | Chinese - English Dictionary &amp; Mandarin Learning Resources</title>
...
server {
listen 80;
server_name fancyapp.com www.fancyapp.com;
location / {
proxy_pass http://localhost:1337;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";