Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
View GitHub Profile
@danielphillips
danielphillips / UILabel+dynamicSizeMe.h
Created Jun 2, 2011
Adjust UILabel to change it's frame according to it's content
View UILabel+dynamicSizeMe.h
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@paullewis
paullewis / gist:1981455
Created Mar 5, 2012
Quicksort in JavaScript
View gist:1981455
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@martinsik
martinsik / chat-frontend.js
Last active Oct 22, 2020
Node.js chat frontend and server
View chat-frontend.js
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@ChrisCinelli
ChrisCinelli / gist:2051841
Created Mar 16, 2012
Logging of Javascript error on the Frontend to the Backend
View gist:2051841
/* ==========================================================
*
* Log on a remote server most of the errors in the browser
*
* @author Chris Cinelli
*
* Depends on:
* stacktrace.js - https://github.com/eriwen/javascript-stacktrace
* jsonStringify.js - http://www.thomasfrank.se/json_stringify_revisited.html
*
@jlong
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@clarle
clarle / app.js
Created Jul 26, 2012
Short tutorial on how to use Express and node-mysql
View app.js
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@paul-delange
paul-delange / GIFDownloader.h
Created Nov 18, 2012
Convert remote GIF into something MPMoviePlayerController can use
View GIFDownloader.h
//
// GIFDownloader.h
// TheJoysOfCode
//
// Created by Bob on 29/10/12.
// Copyright (c) 2012 Tall Developments. All rights reserved.
//
#import <Foundation/Foundation.h>
@mattt
mattt / uiappearance-selector.md
Last active Oct 13, 2020
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3
View uiappearance-selector.md

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'   | \
@kendellfab
kendellfab / read_line.go
Created Nov 11, 2013
Golang --> Read file line by line.
View read_line.go
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())
}
}
View 0virtual-dom.md

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.

You can’t perform that action at this time.