Skip to content

Instantly share code, notes, and snippets.

View iShawnWang's full-sized avatar
🤗
2333

Shawn Wang iShawnWang

🤗
2333
View GitHub Profile
@bluejava
bluejava / Soon
Last active December 22, 2022 06:27
A Very Fast Javascript thread yield (see blog posting)
// See http://www.bluejava.com/4NS/Speed-up-your-Websites-with-a-Faster-setTimeout-using-soon
// This is a very fast "asynchronous" flow control - i.e. it yields the thread and executes later,
// but not much later. It is far faster and lighter than using setTimeout(fn,0) for yielding threads.
// Its also faster than other setImmediate shims, as it uses Mutation Observer and "mainlines" successive
// calls internally.
// WARNING: This does not yield to the browser UI loop, so by using this repeatedly
// you can starve the UI and be unresponsive to the user.
// Note: For an even faster version, see https://gist.github.com/bluejava/b3eb39911da03a740727
var soon = (function() {
@dimroc
dimroc / DDLogHelper.swift
Last active July 28, 2017 10:46
Wrapper around the Objective C DDLog found in CocoaLumberjack 2.x
import Foundation
public let defaultDebugLevel = DDLogLevel.Debug
public let defaultTag = NSString(format: "ManhattanForum")
class DDLogHelper {
class func SwiftLogMacro(async: Bool, level: DDLogLevel, flag flg: DDLogFlag, context: Int = 0, file: String = __FILE__, function: String = __FUNCTION__, line: UWord = __LINE__, tag: AnyObject? = defaultTag, format: String, args: CVaListPointer) {
let string = NSString(format: format, arguments: args) as String
SwiftLogMacro(async, level: level, flag: flg, context: context, file: file, function: function, line: line, tag: tag, string: string)
}
@brianmacarthur
brianmacarthur / flash-app.js
Last active July 10, 2023 18:41
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active April 8, 2024 18:07
The best FRP iOS resources.

Videos

@daehn
daehn / vibration.m
Created April 3, 2015 11:04
Custom iOS vibration pattern with 100ms duration using private API
NSMutableDictionary *vibrationParameters = [[NSMutableDictionary alloc] init];
vibrationParameters[@"VibePattern"] = @[@YES, @100];
vibrationParameters[@"Intensity"] = @1;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-function-declaration"
AudioServicesStopSystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, vibrationParameters);
#pragma clang diagnostic pop
@binderclip
binderclip / python-smtp-send-qq-mail.py
Last active February 16, 2023 14:59
Python & Email,附上用 Python 发送 QQ 邮箱邮件的代码
import smtplib
from getpass import getpass
def prompt(prompt):
return input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
subject = prompt("Subject: ")
print("Enter message, end with ^D (Unix) or ^Z (Windows):")
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@tahmidsadik
tahmidsadik / purgeAndroid.txt
Created September 19, 2015 18:47
How to completely remove Android Studio from Mac OS X
How to Completely Remove Android Studio
Execute these commands from the terminal
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
@armcknight
armcknight / install_xcode.sh
Last active February 26, 2021 22:35
Install Xcode via command line
#!/bin/sh
#
# install_xcode.sh
#
# Created by Andrew McKnight on 9/24/15
#
# takes a downloaded .dmg containing Xcode and installs it to a specified location/name, or defaults to /Applications and the DMG's filename
#