Skip to content

Instantly share code, notes, and snippets.

View beinan's full-sized avatar

Beinan beinan

  • San Francisco, CA
View GitHub Profile
/*
* Copyright (c) 2014, Oracle America, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
(add-hook 'go-mode-hook (lambda() (setq go-tab-width 2)))
)
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@beinan
beinan / stack_by_queue.cpp
Created November 10, 2015 22:51
Implement a stack by a single queue
#include <queue>
class Stack {
queue<int> _q;
public:
// Push element x onto stack.
void push(int x) {
_q.push(x);
}
@beinan
beinan / median.cpp
Created November 3, 2015 01:22
Find Median from Data Stream
#include <queue>
#include <vector>
#include <functional>
using namespace std;
class MedianFinder {
public:
priority_queue<int, vector<int>> maxHeap; //store the numbers which are less than the median
priority_queue<int, vector<int>, greater<int>> minHeap; // numbers greater than the median
@beinan
beinan / gulpfile.coffee
Created July 7, 2015 21:11
Gulp file for express app with coffeescript, reactjs and browserify
source = require 'vinyl-source-stream'
gulp = require 'gulp'
gutil = require 'gulp-util'
browserify = require 'gulp-browserify'
coffee_reactify = require 'coffee-reactify'
coffeeify = require 'coffeeify'
notify = require 'gulp-notify'
rename = require('gulp-rename')
nodemon = require("gulp-nodemon")