Skip to content

Instantly share code, notes, and snippets.

View zhenyanghua's full-sized avatar
🐢
I may be slow to respond.

Zhenyang Hua zhenyanghua

🐢
I may be slow to respond.
View GitHub Profile
@zhenyanghua
zhenyanghua / Readme.md
Last active March 16, 2016 15:34
Migration from SVN to GIT

Migration from SVN to Git

Migration is not always easy. However, git-svn is a quite useful tool to do the job.

To do the job right, this post from stackoverflow is tremendously helpful in my entire process.

I wrote the m.py to automate the entire process.

@zhenyanghua
zhenyanghua / style.css
Created March 31, 2016 23:20
Bootstrap tab content style fix.
.tab-content > .tab-pane { display: block; height: 0; overflow: hidden; }
.tab-content > .active { display: block; height: auto; }
@zhenyanghua
zhenyanghua / app.js
Last active April 21, 2016 19:03 — forked from johnlindquist/app.js
Toggle Subscription
const Observable = Rx.Observable;
const toggleButton = document.querySelector('#toggle');
const toggleClick$ = Observable.fromEvent(toggleButton, 'click');
const interval$ = Observable.interval(1000);
const toggle$ = toggleClick$
.startWith(false)
.scan((acc, curr)=> !acc); //toggles true/false
@zhenyanghua
zhenyanghua / 1.Prerequisites.md
Created June 28, 2016 14:05 — forked from erodewald/1.Prerequisites.md
Reverse proxy on Windows with Apache 2.4 for Couchpotato/Sonarr

###Pre-requisites:

  1. Any version of Windows newer than XP or Server 2003.
  2. A good text editor. I recommend Sublime Text 2.
  3. If you use Sublime Text, you can get very helpful syntax highlighting while editing Apache Conf files by installing Package Control. Once fully installed and SublimeText is restarted, CTRL+SHIFT+P -> Install Package -> ApachConf (enter).
  4. This assumes you have a public domain pointing to your WAN IP. Figure that out from whatismyip.com. If you purchase a domain and use a CNAME or A-record, it can take some time for the DNS changes to propagate. I've seen anywhere from 15 mins to several hours.
  5. Within your router, you must forward port 80 to your LAN IP which hosts Apache.
@zhenyanghua
zhenyanghua / webpack.config.js
Created July 28, 2016 02:26
learn-react-server-v0.0.1
import path from 'path';
import webpack from 'webpack';
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: [
'webpack-hot-middleware/client',
'./index'
],
output: {
@zhenyanghua
zhenyanghua / main.js
Last active September 19, 2016 12:36
ArcGIS Online login flow through JS 3.x
require([
'app/config',
'dojo/ready',
'dojo/on',
'dojo/dom',
'esri/arcgis/OAuthInfo',
'esri/IdentityManager'],
function(
config,
ready,
@zhenyanghua
zhenyanghua / Customer.js
Created October 4, 2016 19:04
Loopback query role by user Id
var _ = require('underscore');
module.exports = function(Customer) {
Customer.getRolesById = function (id, cb) {
Customer.getApp(function (err, app) {
if (err) throw err;
var RoleMapping = app.models.RoleMapping;
var Role = app.models.Role;
RoleMapping.find({ where : { principalId: id }}, function (err, roleMappings) {
var roleIds = _.uniq(roleMappings
@zhenyanghua
zhenyanghua / DataStructure.md
Last active January 31, 2017 16:18
Data Structure in JavaScript

Data Structures with JavaScript

This is a list of implementation and usage of popular data structure with JavaScript.

Currently include:

  • Queue
    • Priority Queue
    • Circular Queue
  • linked List
@zhenyanghua
zhenyanghua / transpose.js
Created January 13, 2017 22:25
Algorithms
/**
* Question - Given an image represented by an N x N matrix, where
* each pixel in the image is 4 bytes, write a method to rotate the
* image by 90 degress. Can you do this in place?
*
* rotateCopy() method is a brute force method to transpose one item
* at a time and return a new array. It is very slow. The time
* complexity is O(N^2), and it take as N^2 * [0-2^32) bits of memory.
*
* rotate() method performs a cyclic swap on the edges on each layer.