Skip to content

Instantly share code, notes, and snippets.

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

OrthogonalConnection

The class OrthogonalConnection creates a polyline that goes from p1 to p2, composed only by horizontal and vertical segments. The shape of the line is controlled by the path parameter.

There are two ways to use this class:

  1. p1 and p2 are the start and end points of the line, and path is a string with the characters "-" and "|" indicating the horizontal and vertical segments of the line.

    For example "-|-" will start with a horizontal segment, that will go until the x coordinate intermediate between p1 and p2, then a vertical segment up to the y coordinate of p2, and finally a horizontal segment to p2.

@freak4pc
freak4pc / MKMultiPoint+Ext.swift
Last active April 25, 2024 04:38
Get a list of coordinates from a MKPolyline / MKRoute
public extension MKMultiPoint {
var coordinates: [CLLocationCoordinate2D] {
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,
count: pointCount)
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount))
return coords
}
}
@pythoninthegrass
pythoninthegrass / qr_gen.py
Created April 25, 2024 04:33
Generate QR codes from a URL
#!/usr/bin/env python3
"""SOURCE: https://github.com/pythoninthegrass/python_template/blob/main/boilerplate/qr_gen.py"""
import sys
from datetime import datetime
from pathlib import Path
try:
from pyqrcode import QRCode
@uwezi
uwezi / 20240309_opencv.py
Last active April 25, 2024 04:37
[video inclusion in Manim] Include video objects picture-in-picture. #manim #animate #video #opencv #videomobject
import cv2
from PIL import Image, ImageOps
from dataclasses import dataclass
@dataclass
class VideoStatus:
time: float = 0
videoObject: cv2.VideoCapture = None
def __deepcopy__(self, memo):
return self
@ViKingIX
ViKingIX / install_niresh_hackintosh.md
Created April 28, 2016 07:25
How to Install Niresh Yosemite on Your PC

How to Install Niresh Yosemite on Your PC

OS X Yosemite (10.10) is the latest OS X release of 2014 by apple, but Apple locks the operating system to only be installed in genuine Apple computers known as Macintosh & they cost a lot any how there is always a way if you want to install the operating system in your common pc, without paying high cost for a real mac you can make a Hackintosh

We have previously covered the article for Installing Niresh Mavericks on PC if you’re interested in Installing Mac OS X Yosemite on PC this article is for you, You may experience many problems while trying to Install Hackintosh, most of them can be fixed easily most troubleshoot informations are included in this guide so first just read all Instructions once before starting any procedures.

Few Notes about this OSX 10.10 & 10.10.1 (Intel & AMD Supported)

@kohya-ss
kohya-ss / gradio_llm.py
Last active April 25, 2024 04:30
gradioでLLMを利用する簡易クライアント
# Apache License 2.0
# 使用法は gist のコメントを見てください
import argparse
from typing import List, Optional, Union, Iterator
from llama_cpp.llama_chat_format import _convert_completion_to_chat, register_chat_completion_handler
import llama_cpp.llama_types as llama_types
from llama_cpp.llama import LogitsProcessorList, LlamaGrammar
from llama_cpp import Llama, llama_chat_format
import gradio as gr
@fabiolimace
fabiolimace / fn_tsid_milli.sql
Last active April 25, 2024 04:23
Function for generating Time Sortable ID with millisecond precision on PostgreSQL
/**
* Returns a Time Sortable ID with millisecond precision.
*
* Time component: 42 bits (2^42 = ~69 years)
*
* Random component: 22 bits (2^22 = 4,194,304)
*
* The time component is the count of milliseconds since 2020-01-01T00:00:00Z.
*
* Tags: tsid ulid snowflake id-generator generator time sortable sort order id
@sindresorhus
sindresorhus / esm-package.md
Last active April 25, 2024 04:20
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing