Skip to content

Instantly share code, notes, and snippets.

View zry656565's full-sized avatar
🚀
Ship it

Jerry Zou zry656565

🚀
Ship it
View GitHub Profile
@zry656565
zry656565 / custom-scrollbar.styl
Created October 10, 2017 10:12
custom-scrollbar
::-webkit-scrollbar {
width: 12px
height: 12px
}
::-webkit-scrollbar-track {
background-color: transparent
}
::-webkit-scrollbar-thumb {
@zry656565
zry656565 / getScrollBarSize.js
Created October 6, 2017 08:03
getScrollBarSize
// From: https://github.com/react-component/util
let cached;
export default function getScrollBarSize(fresh) {
if (fresh || cached === undefined) {
const inner = document.createElement('div');
inner.style.width = '100%';
inner.style.height = '200px';
@zry656565
zry656565 / Portal.js
Last active October 6, 2017 08:02
Portal Pattern
// From: https://github.com/react-component/util
import React from 'react';
import PropTypes from 'prop-types';
import { createPortal } from 'react-dom';
export default class Portal extends React.Component {
static propTypes = {
getContainer: PropTypes.func.isRequired,
children: PropTypes.node.isRequired,
/**
* shortcut plugin
* Created date: 2017.01.16
* TODO (feature):
* 1. support different key binding in Windows / Mac
*/
const keyPairs = [
[8, 'Backspace'],
[9, 'Tab'],
OBJS = MovieList.o Movie.o NameList.o Name.o Iterator.o
CC = g++
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
p1 : $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o p1
MovieList.o : MovieList.h MovieList.cpp Movie.h NameList.h Name.h Iterator.h
@zry656565
zry656565 / gulpfile.js
Created May 18, 2016 11:30 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
function binarySearch(array, start, end, target) {
while (true) {
if (start > end) return -1;
if (end - start < 2) {
if (target === array[end]) return end;
else if (target === array[start]) return start;
else return -1;
}
var mid = Math.floor((start + end) / 2);
if (target === array[mid]) return mid;
@zry656565
zry656565 / LPS.js
Created April 4, 2016 07:22
Longest Palindromic Subsequence
/**
* @param {string} s
* @return {int}
*/
var longestPalindromeLength = function(s) { 'use strict'
let n = s.length;
if (n <= 1) return n;
let L = {
arr: [],
var x,
y,
i,
j,
k,
begin,
end,
len,
sum,
COUNT = 10;
@zry656565
zry656565 / is_installed.sh
Created February 18, 2016 07:14 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script. Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1