Skip to content

Instantly share code, notes, and snippets.

View lynxerzhang's full-sized avatar
🤒

frankwinter lynxerzhang

🤒
  • geckostudio
  • shanghai
View GitHub Profile
@oliveratgithub
oliveratgithub / emojis.json
Last active April 26, 2024 22:35
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "👩‍👩‍👧‍👧", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "👩‍👩‍👧‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "👩‍👩‍👦‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "👨‍👩&z
@timonus
timonus / UIWindow+AppSwitchScrollStopper.h
Last active January 6, 2017 19:01
AppSwitchScrollStopper
// UIWindow+AppSwitchScrollStopper.h
// Created by Tim Johnsen on 3/27/16.
#import <UIKit/UIKit.h>
@interface UIWindow (AppSwitchScrollStopper)
/// Call this early on in your app's lifecycle to avoid
/// scroll-related flashing when your app resumes from the background
- (void)installAppSwitchScrollStopper;
@astein
astein / html5_ima_sdk_example.js
Last active August 18, 2022 16:02
Example of using Google IMA SDK for HTML5
// video DOM inside creative
//<div id="videoContainer">
// <video id="videoContainer"></video>
//</div>
// load IMA SDK at init load time
$.getScript('//imasdk.googleapis.com/js/sdkloader/ima3.js');
// usage: startVideo( /* vast tag url */ );
@lynxerzhang
lynxerzhang / ColorRandom.swift
Created December 14, 2015 08:42
Random Color in Swift
//Jared Davidson's Random Colorization
//run in xcode7.1 and swift2.1
//drand48返回0 - 1的随机Double数值
var red = CGFloat(drand48())
var green = CGFloat(drand48())
var blue = CGFloat(drand48())
var view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
//随机色
view.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
@lynxerzhang
lynxerzhang / SortDemo.swift
Created December 14, 2015 08:15
Jared Davidson's swift sort demo
//Jared Davidson's swift sort demo
//run in xcode 7.1 and swift 2.1
var ary = [0, 10, 8, 2]
ary = ary.sort({ $0 < $1 })
print(ary)
//[0, 2, 8, 10]
var strs = ["objectivec", "swift", "js", "as"]
strs.sortInPlace({$0 < $1})
print(strs)
@runspired
runspired / leak.js
Created November 5, 2015 06:35
ES6 Fat Arrow ( => ) functions can cause memory leaks when used with Event Handlers.
class Foo {
constructor(element) {
this.element = element;
this.setupHandlers();
}
doFoo() {}
setupHandlers() {
@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
@JordanDelcros
JordanDelcros / combine-rgba-colors.js
Created July 31, 2015 09:55
Combine two RGBA colors with JavaScript
// Fast and easy way to combine (additive mode) two RGBA colors with JavaScript.
// [red, green, blue, alpha] based on these maximul values [255, 255, 255, 1].
var base = [69, 109, 160, 1];
var added = [61, 47, 82, 0.8];
var mix = [];
mix[3] = 1 - (1 - added[3]) * (1 - base[3]); // alpha
mix[0] = Math.round((added[0] * added[3] / mix[3]) + (base[0] * base[3] * (1 - added[3]) / mix[3])); // red
mix[1] = Math.round((added[1] * added[3] / mix[3]) + (base[1] * base[3] * (1 - added[3]) / mix[3])); // green
mix[2] = Math.round((added[2] * added[3] / mix[3]) + (base[2] * base[3] * (1 - added[3]) / mix[3])); // blue
@JadenGeller
JadenGeller / Inout.swift
Last active September 6, 2022 23:19
Inout is really UnsafeMutablePointer!
var a = 0
var b = 0
// UnsafeMutablePointer definition
func test2(x: UnsafeMutablePointer<Int>) {
x.memory += 1
// We have to manually dereference x within this method
}
// Inout definition
@DavidWells
DavidWells / clear-browser-cache.js
Last active February 24, 2021 09:55
Clear Browser cache. Run in your browsers javascript console
//Cache Buster
(function (){
  var rep = /.*\?.*/,
      links = document.getElementsByTagName('link'),
      scripts = document.getElementsByTagName('script'),
      process_scripts = false;
  for (var i=0;i<links.length;i++){
    var link = links[i],
        href = link.href;
    if(rep.test(href)){