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 / PasswordGenerator.php
Last active November 29, 2016 01:57
Generating "Very Strong" Plesk passwords
<?php
function generatePassword($stronger = true) {
$password = "";
$length = $stronger ? 16 : 8;
$sets = array(
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz',
'0123456789',
'!@#$%^&*?_~',
@nahanil
nahanil / validate_abn.js
Created December 7, 2016 08:36
Validate an ABN Australian Business Number
/**
* https://abr.business.gov.au/HelpAbnFormat.aspx
*/
function validateAbn(abn) {
// The Australian Business Number (ABN) is a unique 11 digit identifier issued to all entities registered in the Australian Business Register (ABR).
var digits = abn.toString().split('');
if (digits.length != 11) {
return false;
}
@nahanil
nahanil / Raw vertical-bopomofo-ruby-text.css
Last active January 19, 2017 08:52
Vertical aligned Zhuyin/bopomofo ruby text with HTML & CSS (1st attempt)
p {
font-size: 1.9em;
color: #333;
}
ruby {
position: relative;
margin-right: 0.3em;
}
@nahanil
nahanil / cloudflare-failover.sh
Created February 24, 2019 08:55 — forked from Ara4Sh/cloudflare-failover.sh
CloudFlare A records failover script using CloudFlare api v4 (https://api.cloudflare.com) required jq and curl to run.
#!/bin/bash
# Copyright (C) 2016 Arash Shams <https://github.com/Ara4Sh>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
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";
@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>
...
@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 / 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
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 / 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/