Skip to content

Instantly share code, notes, and snippets.

View zhuangh's full-sized avatar
🎯
Focusing

Hao Zhuang zhuangh

🎯
Focusing
View GitHub Profile
#include <boost/uuid/sha1.hpp>
#include <sstream>
#include <cstddef>
#include <string>
std::string Sha1sum(void *data, std::size_t count) {
boost::uuids::detail::sha1 hasher;
char hash[20];
hasher.process_bytes(data, count);
unsigned int digest[5];
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>
var googleapis = require('googleapis')
, OAuth2Client = googleapis.OAuth2Client
, config = require('./config.json');
var oauth2Client = new OAuth2Client(config.CLIENT_ID, config.CLIENT_SECRET, config.REDIRECT_URL);
@zhuangh
zhuangh / git.md
Created August 10, 2014 01:02 — forked from suziewong/git.md

github的多人协作

  1. github上你可以用别人的现成的代码 直接 git clone 即可了

  2. 然后你也想改代码或者贡献代码咋办?

Fork

@zhuangh
zhuangh / backend-architectures.md
Last active September 2, 2015 08:42 — forked from ngocphamm/backend-architectures.md
Backend Architectures
@zhuangh
zhuangh / latency.txt
Created November 16, 2015 17:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@zhuangh
zhuangh / linalg_ops.cc
Last active January 18, 2018 22:37
Tensorflow LU ops
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@zhuangh
zhuangh / ops.pbtxt
Last active February 5, 2018 18:17
tensorflow LU ops related
op {
name: "Lu"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "l"
description: "The lower triangular matrix L."
@zhuangh
zhuangh / lu_ops.cc
Created January 14, 2018 00:33
tensorflow lu ops related
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@zhuangh
zhuangh / lu_ops_test.py
Last active January 18, 2018 22:36
tensorflow lu ops related (test script)
import tensorflow as tf
import numpy as np
w = np.array([[3,-1,-1], [-1,5.0,-1], [1, 0 ,10]])
print(w)
W = tf.constant(w)
l, u, p, q = tf.lu(W)
pinv = tf.matrix_inverse(p)
qinv = tf.matrix_inverse(q)