Skip to content

Instantly share code, notes, and snippets.

var EnglishDictionary = function (words) {
var self = {};
var letterHash = initLeterHash();
// this is efficient enough to get 1mil primes fast.
function getPrimes(num) {
var primes = [2, 3];
for (var n = 5; primes.length < num; n += 2) {
var sqrt = Math.sqrt(n);
var isPrime = true;
@simianhacker
simianhacker / json_path.sql
Last active May 13, 2019 17:40
Here is a set of functions for working with a PostgreSQL+JSON+PLV8 database.
-- Function: json_path(json, text)
-- DROP FUNCTION json_path(json, text);
CREATE OR REPLACE FUNCTION json_path(data json, path text)
RETURNS text AS
$BODY$
/* JSONPath 0.8.0 - XPath for JSON
*
* Copyright (c) 2007 Stefan Goessner (goessner.net)
@elithrar
elithrar / wale_postgres_recovery.md
Last active May 3, 2021 15:38
WAL-E + Postgres 9.x (single server + DB) Setup and Recovery

A quick "how to" on what you need to do to both setup AND recover a single-server PostgreSQL database using WAL-E

  • WAL-E: https://github.com/wal-e/wal-e
  • Assuming Ubuntu 12.04 LTS ("Precise")
  • We'll be using S3. Make sure you have an IAM in a group with GetObject, ListBucket and PutObject on the bucket you want to use (and that it's not public).

Setup:

  1. These packages:
test('stuff', async () => {
// форкаем домен, создаем новый независимый скоуп
const scope = fork(root, {
// в конфиге форка будут модификации, которые применятся к скоупу
values: new Map()
.set($myStore, value), // подменили стартовое значение стора эксклюзивно для этого скоупа
handlers: new Map()
.set(myFx, mockHandler) // подменили хэндлер эффекта эксклюзивно для этого скоупа
});
-- Description:
-- ------------
--
-- This is an example schema for storing collectd metrics in a TimescaleDB
-- dabase (see https://www.timescale.com/). It is based on the PostgreSQL
-- schema contributed by Sebastian Harl.
--
-- Prerequisities:
-- ---------------
--
@nickjacob
nickjacob / systemd-prblm.service
Last active March 17, 2023 16:11
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"
@eyecatchup
eyecatchup / hammerhead-from-lrx21o-to-lrx22c.md
Last active November 1, 2023 08:35
A step-by-step guide how to manually flash the Android 5.0.1 (LRX22C) OTA-Update on a Nexus 5 with modified system (custom recovery/kernel, rooted, modified framework etc.)..

Update: For those interested, here's the version for updating from Android 5.1.0 (LMY47D/LMY47I) to Android 5.1.1 (LMY48B):
https://gist.github.com/eyecatchup/dab5cf7977008e504213


  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;
@aldur
aldur / README.md
Created November 14, 2017 19:44
OnePlusRoot

Root OnePlus5 without unlocking the bootloader

Gain adb root.

$ adb shell am start -n com.android.engineeringmode/.qualcomm.DiagEnabled --es "code" "angela"

Download Magisk-v14.0 and extract it somewhere. Download MagiskManager.

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active February 25, 2024 13:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@jakub-g
jakub-g / async-defer-module.md
Last active March 14, 2024 02:02
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)