Skip to content

Instantly share code, notes, and snippets.

View lanqy's full-sized avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
  • Shenzhen,China
View GitHub Profile
@tdegrunt
tdegrunt / walk.go
Created September 29, 2014 11:53
Replace some text in a bunch of files with golang
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
@dexteryy
dexteryy / standards_for_webapps_on_mobile.md
Last active August 17, 2017 02:16
W3C Standards for Web Apps on Mobile (After HTML5)
@lihnux
lihnux / StringToByteArray.js
Created August 6, 2014 06:05
Javascript Convert String to Byte Array
var url = "Hello World";
var data = [];
for (var i = 0; i < url.length; i++){
data.push(url.charCodeAt(i));
}
@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@jlongster
jlongster / bloop.js
Last active September 5, 2022 23:33
bloop
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@kendellfab
kendellfab / read_line.go
Created November 11, 2013 17:41
Golang --> Read file line by line.
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@72lions
72lions / concat.array.buffers.js
Created January 14, 2013 09:22
Concatenates two ArrayBuffers
/**
* Creates a new Uint8Array based on two different ArrayBuffers
*
* @private
* @param {ArrayBuffers} buffer1 The first buffer.
* @param {ArrayBuffers} buffer2 The second buffer.
* @return {ArrayBuffers} The new ArrayBuffer created out of the two.
*/
var _appendBuffer = function(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@paul-delange
paul-delange / GIFDownloader.h
Created November 18, 2012 09:10
Convert remote GIF into something MPMoviePlayerController can use
//
// GIFDownloader.h
// TheJoysOfCode
//
// Created by Bob on 29/10/12.
// Copyright (c) 2012 Tall Developments. All rights reserved.
//
#import <Foundation/Foundation.h>