Skip to content

Instantly share code, notes, and snippets.

View Zeta611's full-sized avatar
🎯
Focusing

Jay Lee Zeta611

🎯
Focusing
View GitHub Profile
@chriseidhof
chriseidhof / RemoteValue.swift
Created June 28, 2019 10:27
Custom Lazy Loading
import Foundation
import SwiftUI
import Combine
import TinyNetworking
final class RemoteValue<A>: BindableObject {
let didChange = MyPublisher()
let endpoint: Endpoint<A>
var value: A? {
didSet {
@pgundlach
pgundlach / viznodelist.lua
Last active January 10, 2022 01:43
LuaTeX nodelist visualization
--
-- viznodelist.lua
-- speedata publisher
--
-- Written 2010-2020 by Patrick Gundlach.
-- This file is released in the spirit of the well known MIT license
-- (see https://opensource.org/licenses/MIT for more information)
--
-- visualizes nodelists using graphviz
@norswap
norswap / Parser.java
Last active February 26, 2022 13:45
Simple Handwritten JSON Recognizer
// Code for lecture [5. Writing Parsers by Hand]
// https://www.youtube.com/watch?v=Ytq0GQdnChg&list=PLOech0kWpH8-njQpmSNGSiQBPUvl8v3IM&index=5
import java.util.Scanner;
public final class Parser
{
// === SETUP ===================================================================================
private static final String EXAMPLE_INPUT =
@mikelane
mikelane / game_of_life.py
Last active March 21, 2022 22:52
Conway's Game of Life implemented using a 2d convolution.
import click
import difflib
import numpy as np
import random
import sys
import time
from os import name, system
from scipy.ndimage import convolve
@Zeta611
Zeta611 / Zcombinator.swift
Created August 9, 2022 12:53
[Fixed-point combinator in Swift] Fixed-point combinator (Z combinator) in Swift. Y combinator is not available, as Swift is a strict language. #demo
struct Fix<T> {
let x: (Fix<T>) -> T
}
func fix<T, U>(f: @escaping (@escaping (T) -> U) -> ((T) -> U)) -> (T) -> U {
{ _fix in
f { (_fix.x(_fix))($0) }
}(
Fix { _fix in
f { (_fix.x(_fix))($0) }
@rudolfratusinski
rudolfratusinski / parallels_tools_ubuntu_new_kernel_fix.md
Last active November 23, 2022 20:01
Parallels Tools fix for Ubuntu 18.04 and other Linux distributions with Kernel version >= 4.15

Preparation

  • In open Ubuntu 18.04 machine click Parallels Actions -> "Install Parallels Tools"

  • A "Parallels Tools" CD will popup on your Ubuntu desktop.

  • Open it by double mouse click, copy all the content to a new, empty directory on a desktop, name it for e.g. "parallels_fixed"

  • Open terminal, change directory to parallels_fixed (cd ~/Desktop/parallels_fixed)

  • Make command line installer executable (chmod +x install)

  • Change directory to "installer" (cd installer)

  • Make few other scripts executable: chmod +x installer.* *.sh prl_*

@mjm
mjm / ManagedObjectChangesPublisher.swift
Created November 3, 2019 20:41
Observe changes to a Core Data fetch request with Combine
import Combine
import CoreData
extension NSManagedObjectContext {
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>)
-> ManagedObjectChangesPublisher<Object>
{
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self)
}
}
@claudio-naoto
claudio-naoto / demo-en.saty
Created January 5, 2021 10:13
English translation of demo.saty
@require: stdjabook
@require: code
@require: itemize
@require: tabular
@require: proof
@import: local
document (|
title = {An outline of \SATySFi;};
author = {Takashi SUWA};
@Drup
Drup / difflist.ml
Last active June 12, 2023 17:26
Difference lists and Miniformat
type ('ty,'v) t =
| Nil : ('v, 'v) t
| Cons : 'a * ('ty, 'v) t -> ('a -> 'ty, 'v) t
let cons x l = Cons (x,l)
let plus1 l = Cons ((),l)
let one x = Cons (x,Nil)
@jdhao
jdhao / resize_and_pad_image_to_square
Last active June 15, 2023 04:12
this script will resize and pad an image to desired square size and keep its aspect ratio unchanged. Before running the script, please change the size and image path to valid value.
from PIL import Image, ImageOps
import cv2
desired_size = 368
im_pth = "/home/jdhao/test.jpg"
# im = Image.open(im_pth)
# old_size = im.size # old_size[0] is in (width, height) format
# ratio = float(desired_size)/max(old_size)