Skip to content

Instantly share code, notes, and snippets.

John Wu tjwudi

Block or report user

Report or block tjwudi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tjwudi
tjwudi / README.md
Last active Aug 4, 2017
Roundtable - React & Redux
View README.md

We use CodeSandbox for this interactive session.

JSX

JSX is just syntax sugar for some React JavaScript API. For example, the following JSX code ...

<DashboardUnit data-index="2">
  <h1>Scores</h1>
@tjwudi
tjwudi / sublime_scopes.list
Created Sep 10, 2013
Sublime Text snippet scope list
View sublime_scopes.list
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CSS: source.css
D: source.d
Diff: source.diff
@tjwudi
tjwudi / c_program_opt.md
Last active Feb 16, 2017
计算机系统结构课程学习报告
View c_program_opt.md

基于计算机体系结构的C程序性能优化

摘要

本文主要介绍如何从计算机体系结构的角度,利用计算机系统的硬件特点来优化软件代码。本文采用C语言进行样例的描述,但是在大多数其他的编程语言中也能够适用。
首先,我们将阐述为何需要从计算机体系结构的角度进行程序优化。接着,我们抽象出了从计算机体系结构的角度分析性能问题的模式。然后,我们将了解几种被广泛应用在各种体系结构上的,基于体系结构的程序性能优化方式,并将改进前后的性能进行对比。最后,我们将综合所有在文中谈到的程序性能优化方式,一同探讨如何进行进一步的优化。

程序性能优化的两个大方向

尽管本文主要阐述程序性能优化,但是我们还是必须首先支出,编写程序的主要目标就是编写出可用的程序,而非高效的程序。我们所做的一切优化,都应该是在写出正确、可交付的程序的基础上。也就是说,可用性是程序性能优化的地基。
在建立好地基后,我们就可以思考让我们的程序运行得更加快速。一般而言,程序性能优化有两个大方向:

  1. 选择更合适的算法以及数据结构
  2. 让编译器或者解释器能够更好对你的代码进行优化
View 1.py
def sign_in(user_credential, role):
"""Sign in an user.
:param user_credential: User's credential
:param role:
"""
View app.js
angular.module('App').config(function (RestangularProvider) {
// convert json request to x-www-form-urlencoded request
RestangularProvider.setFullRequestInterceptor(function (el, op, what, url) {
if (op === "put" || op === "post") {
var res = "";
_.forOwn(el, function (v, k) {
if (!_.isFunction(v)) {
res += k + "=" + encodeURIComponent(v) + "&";
View master-install.sh
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y oracle-java8-set-default
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
CODENAME=$(lsb_release -cs)
echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/mesosphere.list
sudo apt-get -y update
sudo apt-get install -y mesosphere
@tjwudi
tjwudi / hamming_code.js
Last active Feb 8, 2016
Communication subsystem (simulation) using Hamming code
View hamming_code.js
// needs async library support
var
async = require('async');
(function lifeCycle(){
var
workflow = {
body : [],
end : function() {},
util : {},
View gist:bc63370afd912a86e6cd
{
init: function(elevators, floors) {
function Tour (pickupRequest, direction, startFloorNum) {
this.pickingUp = !!pickupRequest;
this.pickupRequest = pickupRequest;
this.direction = direction; // either 'up' or 'down'
this.startFloorNum = startFloorNum;
}
function Controller (elevator) {
View gist:aabe51ef24b575589935
{
init: function(elevators, floors) {
function Controller (elevator) {
var currentController = this;
this.elevator = elevator;
elevator.on('floor_button_pressed', function (floorNum) {
currentController.goToFloor(floorNum);
});
}
View gist:8432502

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

You can’t perform that action at this time.