Skip to content

Instantly share code, notes, and snippets.

@ikupenov
ikupenov / db-client.ts
Created February 29, 2024 18:40
Intercepting Drizzle db calls
import { and, type DBQueryConfig, eq, type SQLWrapper } from "drizzle-orm";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres, { type Sql } from "postgres";
import { type AnyArgs } from "@/common";
import {
type DbClient,
type DbTable,
type DeleteArgs,
@gilangvperdana
gilangvperdana / README.md
Last active December 22, 2025 03:06
Make your Ubuntu Server be Router!

Goals

  • Can use Ubuntu Server 20.04 LTS to be Router Gateway include DHCP Server
  • Client who connected to Ubuntu Server can be access Internet

Environement

  • Ubuntu 20.04 LTS
  • 2 Interface
    • 1 Interface from WAN / ISP (enp2s0)
    • 1 Interface for distribution clients (enx00e04c534458)
@plembo
plembo / pandocdocx2md.md
Last active January 1, 2026 21:00
Convert docx to markdown with pandoc

Convert Word documents to markdown with pandoc

I use pandoc to convert masses of Word documents to markdown. Still working on a generic script, but for now here's the "gist" of what I type into the terminal:

$ myfilename="example"
$ pandoc \
-t markdown_strict \
--extract-media='./attachments/$myfilename' \
$myfilename.docx \
@SiddharthShyniben
SiddharthShyniben / ninja-code.md
Last active October 25, 2022 09:35
Ninja Code from javascript.info. For my self reference.

Ninja code

Learning without thought is labor lost; thought without learning is perilous.

Confucius

Programmer ninjas of the past used these tricks to sharpen the mind of code maintainers.
Code review gurus look for them in test tasks.
Novice developers sometimes use them even better than programmer ninjas.
Read them carefully and find out who you are – a ninja, a novice, or maybe a code reviewer?

@Leko
Leko / dining-philosophers.js
Created February 28, 2018 17:17
The dining philosophers implementation of Node.js
/**
* The dining philosophers implementation of Node.js
*
* See also:
* http://rust-lang-ja.github.io/the-rust-programming-language-ja/1.6/book/dining-philosophers.html
*
* (c) 2018 Leko
*/
const cluster = require('cluster')
@siwalikm
siwalikm / aes-256-cbc.js
Last active August 11, 2025 11:49
AES-256-CBC implementation in nodeJS with built-in Crypto library
'use strict';
const crypto = require('crypto');
const ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b"; // set random encryption key
const IV = "5183666c72eec9e4"; // set random initialisation vector
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex');
const phrase = "who let the dogs out";
var encrypt = ((val) => {
@JuneKelly
JuneKelly / BaselineTest.txt
Created December 12, 2017 13:45
Full text of the Baseline Test from Blade Runner 2049
A blood black nothingness began to spin.
Began to spin.
Let's move on to system.
System.
Feel that in your body.
@cowboy
cowboy / quine-examples.js
Last active December 29, 2025 21:14
A few JavaScript quines
// Today, I noticed that someone favorited this tweet of mine from 2012:
// https://twitter.com/cowboy/status/232587756486938624
// !function $(){console.log('!'+$+'()')}() #quine
// So I fooled around for a little bit:
// Shortest JavaScript quine?
(function _(){return'('+_+')()'})()
// Have fun with this one!
@DustinD2
DustinD2 / OpenSSL Verify Signature in Bash
Created December 5, 2012 23:27
This is a sample openssl bash script to create a matching RSA key pair and create a signed sha1 digest of the script itself using the private key. The digest is then verified against the public key.
#!/bin/bash
#create our key pairs
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
#sign and verify
openssl dgst -sha1 -sign private.pem -out "$0".sha1 $0
openssl dgst -sha1 -verify public.pem -signature "$0".sha1 $0