Skip to content

Instantly share code, notes, and snippets.

View fuji246's full-sized avatar

Jiantao Fu fuji246

View GitHub Profile
@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active May 3, 2024 08:06
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@simonjenny
simonjenny / slideshow.py
Last active May 18, 2023 14:52
Slideshow for Raspberry Pi (or any other Python capable OS)
# -*- coding: utf-8 -*-
import os, pygame, random
pygame.init()
pygame.mouse.set_visible(False)
BACKGROUND = (0,0,0)
INTERVAL = os.getenv('INTERVAL', 60)
IMAGEFOLDER = os.getenv('IMAGEFOLDER', 'images')
@ingconti
ingconti / QRImage.swift
Created June 8, 2019 12:12
QRCodeImage for iOS and OSX: allows to create a correct QR code without blur (ported from https://gist.github.com/snej/c210cc4cbfe8fd277186)
//
// QRImage.swift
// QRCodeSample
//
// Created by ing.conti on 08/06/2019.
// Copyright © 2019 ing.conti. All rights reserved.
//
@sgr-ksmt
sgr-ksmt / file.swift
Created September 26, 2016 05:55
Safe DispatchQueue.main.sync (Swift3.0)
extension DispatchQueue {
class func mainSyncSafe(execute work: () -> Void) {
if Thread.isMainThread {
work()
} else {
DispatchQueue.main.sync(execute: work)
}
}
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T {
@dennislysenko
dennislysenko / BKTree.swift
Created June 11, 2015 02:09
Fuzzy String Matching (BK Tree)
// Fuzzy string-matching algorithm
// Implementation of algorithm described at: http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees
// Essentially builds an index of strings by levenshtein distance (N-ary tree) on which you can run range queries.
// The root node can be chosen arbitrarily. Each node holds a string and a collection of edges, representing distance to other strings, which then have their own children and so on, building a complete index.
// See https://github.com/vy/bk-tree for (impressive) performance statistics despite this tending to create an unbalanced N-ary tree
class BKTreeNode {
var value: String
var edges: Dictionary<Int, BKTreeNode>
@endolith
endolith / output.png
Last active April 18, 2024 04:22
Detecting rotation and line spacing of image of page of text using Radon transform
output.png