Skip to content

Instantly share code, notes, and snippets.

@markbao
markbao / avit2.zsh-theme
Last active September 8, 2016 23:54
avit2 custom zsh theme
# AVIT ZSH Theme
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
%{$fg[$CARETCOLOR]%}❯%{$resetcolor%} '
PROMPT2='%{$fg[$CARETCOLOR]%}❮%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
@markbao
markbao / # Integrating Slate into a Rails app.md
Created July 15, 2016 22:33
Integrating Slate into a Rails app

Integrating Slate into a Rails app

Want to use the excellent rich text editor Slate in a Rails app? Beware – since you'll be integrating React with your Rails app, it'll turn out pretty complicated and you'll have to do things (e.g. start server, managing dependencies, etc.) a bit differently than before. Let's start.

1. Install react_on_rails

react_on_rails is pretty much the best option for integrating React into Rails. Install it like so:

  1. Add this to your gemfile:
@markbao
markbao / keybase.md
Created April 25, 2016 05:13
keybase.md

Keybase proof

I hereby claim:

  • I am markbao on github.
  • I am markbao (https://keybase.io/markbao) on keybase.
  • I have a public key ASCRjPYm1aoV0zF9ksCKvVxgHe7fs-KrXQv-wskwLKnk7Ao

To claim this, I am signing this object:

Verifying that +markbao is my blockchain ID. https://onename.com/markbao
var token = speakeasy.time({
key: secret.base32,
encoding: 'base32'
});
console.log(token);
var qr = require('qr-js');
var authURL = 'otpauth://totp/SecretKey?secret=' + encodeURIComponent(secret.base32);
console.log(qr.toDataURL(authURL))
var speakeasy = require("speakeasy")
// Generate a secret key of length 20
var secret = speakeasy.generate_key({length: 20})
console.log(secret.base32)
@markbao
markbao / demo1.js
Created December 23, 2015 23:18
Speakeasy Demo
var speakeasy = require("speakeasy")
// Generate a secret key of length 20
var secret = speakeasy.generate_key({length: 20})
console.log(secret.base32)
@markbao
markbao / twitter-list-in-menu-bar.js
Last active August 29, 2015 14:26
Userscript to add a Twitter list to the Twitter web interface's menu bar. Looks like this: http://i.imgur.com/ji9TLOU.png
// ==UserScript==
// @name Twitter List in Menu Bar
// @description Userscript to add a Twitter list to the Twitter web interface's menu bar. By Mark Bao. Looks like this: http://i.imgur.com/ji9TLOU.png
// @version 1
// @namespace https://twitter.com/
// @include https://twitter.com/*
// ==/UserScript==
var text = '<li class="list-item">\
<a role="button" href="[REPLACE-ME]-https://twitter.com/username/lists/list-name" class="" data-placement="bottom" data-original-title="">\