Skip to content

Instantly share code, notes, and snippets.

@fogmoon
fogmoon / parseURLParameters.js
Created September 11, 2018 06:35 — forked from pirate/parseURLParameters.js
Parse URL query parameters in ES6
function getUrlParams(search) {
let hashes = search.slice(search.indexOf('?') + 1).split('&')
let params = {}
hashes.map(hash => {
let [key, val] = hash.split('=')
params[key] = decodeURIComponent(val)
})
return params
}
@fogmoon
fogmoon / gist:e4c235e4bfc1be4b3a3ea9069ac33b32
Created October 9, 2018 13:26 — forked from stereokai/gist:36dc0095b9d24ce93b045e2ddc60d7a0
CSS rounded corners with gradient border
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 4px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;
background-clip: content-box, border-box;
}
....
exports.genGameHash = function(serverSeed) {
return crypto.createHash('sha256').update(serverSeed).digest('hex');
};
function divisible(hash, mod) {
// We will read in 4 hex at a time, but the first chunk might be a bit smaller
// So ABCDEFGHIJ should be chunked like AB CDEF GHIJ
var val = 0;
@fogmoon
fogmoon / scatter_example.js
Created February 22, 2019 08:45 — forked from miguelmota/scatter_example.js
JavaScript Scatter EOSIO (eosjs) example
const ScatterJS = require('scatterjs-core').default
const ScatterEOS = require('scatterjs-plugin-eosjs').default
const Eos = require('eosjs')
ScatterJS.plugins(new ScatterEOS())
const connectionOptions = {
initTimeout: 10000
}
const network = {
@fogmoon
fogmoon / rounding_decimals.md
Created June 6, 2019 16:28 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

--
-- This example shows how bad MySQL is when handling foreign key locks.
-- Deadlock happens when multiple transactions are inserting child records
-- pointing to the same parent and then try to update the parent record.
--
-- The solution is to always try to update the parent record first
-- but it could be hard to track the when database schema is more complex.
--
-- Based on: https://bugs.mysql.com/bug.php?id=48652
--
@fogmoon
fogmoon / tmux-cheatsheet.markdown
Created September 10, 2019 15:48 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
# Generate $prerender_ua bool value based on user agent
# indexation bots will get this as 1,
# prerender user agent will always get 0 (avoid loops)
map $http_user_agent $prerender_ua {
default 0;
@fogmoon
fogmoon / update-geoip-databases.sh
Created February 4, 2020 14:50 — forked from theel0ja/update-geoip-databases.sh
updates GeoLite2 databases
rm -rf dist/ *.tar.gz GeoLite2-*/
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz
tar -xzvf GeoLite2-City.tar.gz
tar -xzvf GeoLite2-Country.tar.gz
tar -xzvf GeoLite2-ASN.tar.gz
@fogmoon
fogmoon / test_kill.ini
Created April 21, 2020 14:38 — forked from ultrabug/test_kill.ini
uwsgi-2.0.x emperor not killing spooler processes example code and ini
[uwsgi]
plugins = python27
socket = 127.0.0.1:3090
master = true
enable-threads = true
log-syslog = uwsgi.test
disable-logging = true