Skip to content

Instantly share code, notes, and snippets.

@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
View nested-sum-types.ts
interface Inner<T> {
value: T;
}
interface Numeric {
content: Inner<number>;
}
interface Text {
content: Inner<string>;
@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 / 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 / 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 main-template.c
#include <stdio.h>
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
/* Library includes. */
#include "stm32f10x.h"
View tester.v
module tester (
//wejscia kontrolne
input clk,
input reset_n,
//interfejs do debugowania
output [1:0] dbg_state,
output [3:0] dbg_r0,
output [3:0] dbg_r1,
output [3:0] dbg_pc
@P4
P4 / Koch.asm
Last active Aug 29, 2015
Rysowanie krzywej Kocha: Generowanie przez LSystem, grafika żółwia
View Koch.asm
; Pawel Maniecki
; Asemblery, IET AGH
; Zadanie 3: Rysowanie krzywej Kocha
; Maksymalna liczba iteracji dla L-systemu: 6
; Maksymalna dlugosc odcinka: 100px
ITERMAX equ 6 ; Maksymalna ilosc iteracji ( nie wieksza od 6 )
; Dlugosc napisu opisujacego krzywa Kocha dla n iteracji dana jest wzorem
; K(n) = 7 * 4^n