Skip to content

Instantly share code, notes, and snippets.

@sparkstar
sparkstar / random_image_generator.py
Last active January 16, 2023 19:19
[python] random image generator
"""
20180828 code fixed
$ pip freeze
numpy==1.15.1
Pillow==5.2.0
pkg-resources==0.0.0
"""
@jbnv
jbnv / NameGenPostgreSQLEnglish.sql
Created June 2, 2015 01:07
Name Generator (PostgreSQL; English)
SELECT
arrays.firstnames[s.a % ARRAY_LENGTH(arrays.firstnames,1) + 1] AS firstname,
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ' from s.a%26+1 for 1) AS middlename,
arrays.lastnames[s.a % ARRAY_LENGTH(arrays.lastnames,1) + 1] AS lastname
FROM generate_series(1,300) AS s(a) -- number of names to generate
CROSS JOIN(
SELECT ARRAY[
'Adam','Bill','Bob','Calvin','Donald','Dwight','Frank','Fred','George','Howard',
'James','John','Jacob','Jack','Martin','Matthew','Max','Michael',
'Paul','Peter','Phil','Roland','Ronald','Samuel','Steve','Theo','Warren','William',
'use strict';
class Abstract {
// A static abstract method.
static foo() {
if (this === Abstract) {
// Error Type 2. Abstract methods can not be called directly.
throw new TypeError("Can not call static abstract method foo.");
} else if (this.foo === Abstract.foo) {
// Error Type 3. The child has not implemented this method.
throw new TypeError("Please implement static abstract method foo.");
@nikhita
nikhita / update-golang.md
Last active July 3, 2024 13:01
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@iPublicis
iPublicis / myapp-node-watcher.path
Last active March 26, 2024 21:06
NODE.JS app as a systemd service with CI controller
#########
# File: myapp-node-watcher.path
#
# Save this to /etc/systemd/system/
# Run systemctl enable myapp-node-watcher.path && systemctl daemon-reload && systemctl start myapp-node-watcher.path
#
[Path]
PathModified=/home/myuser/myappdir/public_html
[Install]
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
{
"$id": "https://json-schema.org/draft/2020-12/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Core and Validation specifications meta-schema",
"$dynamicAnchor": "meta",
"allOf": [
{
"$ref": "meta/core"
},
{