Skip to content

Instantly share code, notes, and snippets.

@P4
P4 / default.reg
Last active May 6, 2021
Color schemes for Windows Command Prompt
View default.reg
Windows Registry Editor Version 5.00
; Default color scheme
; for Windows command prompt.
; Values stored as 00-BB-GG-RR
[HKEY_CURRENT_USER\Console]
; BLACK DGRAY
"ColorTable00"=dword:00000000
"ColorTable08"=dword:00808080
; BLUE LBLUE
@P4
P4 / Your language sucks.md
Last active Apr 23, 2021
Your programming language sucks
View Your language sucks.md

You appear to be advocating a new...

  • Functional
  • Imperative
  • Object-oriented
  • Procedural
  • Stack-based
  • "Multi-paradigm"
  • Lazy
  • Eager
@P4
P4 / user-script.util.js
Created Jul 10, 2020
UserScript utilities
View user-script.util.js
/** returns a promise that resolves when element becomes available */
function waitForElement(selector, timeout=1000) {
return new Promise((resolve, reject) => {
let start, element;
requestAnimationFrame(function wait(timestamp) {
if (start == null) start = timestamp;
element = document.querySelector(selector);
if (element) {
resolve(element);
} else {
@P4
P4 / coerce-boolean.ts
Created Apr 7, 2020
coerceBooleanProperty as property decorator
View coerce-boolean.ts
function coerceBooleanProperty(prop: unknown): boolean {
return !!prop;
}
const CoerceBoolean: PropertyDecorator = (proto, prop) => {
const values = new WeakMap();
Object.defineProperty(proto, prop, {
get() {
return values.get(this)
},
@P4
P4 / synology-reload.sh
Created May 8, 2019
acme.sh reloadcmd for Synology NAS; updates the certificate copies used by services with the renewed certificate, then reloads the service.
View synology-reload.sh
#!/bin/bash
# Let's Encrypt Certificate reload on Synology NAS
# Services configured through DSM to use a given certificate create their own copies of the certificate files.
# This script will update those copies after the original certificate is renewed.
#
# Install and configure acme.sh on the Synology NAS by following the tutorial:
# https://github.com/Neilpang/acme.sh/wiki/Synology-NAS-Guide
CERT_DIR=/usr/syno/etc/certificate
@P4
P4 / CustomLeafletMarkers.ts
Created Sep 7, 2016
Testing extending Leaflet components via TypeScript's inheritance model
View CustomLeafletMarkers.ts
/// <reference path='../leaflet/leaflet.d.ts' />
namespace L {
type LatLngExpression = L.LatLng | number[] | ({ lat: number; lng: number });
export var JSMarker = L.Marker.extend({
options: { title: 'MyMarker' },
initialize: function(latLng: LatLngExpression, options?: L.MarkerOptions) {
View nested-sum-types.ts
interface Inner<T> {
value: T;
}
interface Numeric {
content: Inner<number>;
}
interface Text {
content: Inner<string>;
@P4
P4 / create_sde_connection.py
Created Oct 5, 2016 — forked from odoe/create_sde_connection.py
Arcpy script to add data to mxd and publish to ArcGIS server without ArcMap
View create_sde_connection.py
'''
Created on Feb 24, 2011
The purpose of this script is to create the SDE connection file needed to connect to your SDE
@author: rrubalcava
'''
import os, arcpy
class CreateSDEConnection:
@P4
P4 / foreach.py
Last active Dec 14, 2015
Re-implement Python's for statement using @decorator syntax
View foreach.py
#! /usr/bin/python
def foreach(iterable):
def iterate_over(func):
iterator = iter(iterable)
while True:
try:
value=next(iterator)
func(value)
@P4
P4 / .bashrc
Last active Oct 13, 2015
.bashrc: custom prompt, aliases
View .bashrc
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Handy aliases
alias diff='~/bin/diff.py'
alias documents='cd /d/Dokumenty/'