Skip to content

Instantly share code, notes, and snippets.

View curist's full-sized avatar
😮

Chung-Yu Chang curist

😮
View GitHub Profile
var net = require('net');
var isPrime = (function() {
var table = new Array(2000000);
var len = table.length;
var sqrtlen = Math.ceil(Math.sqrt(len));
for (var i = 2; i < sqrtlen; i++) {
if(table[i]) {
continue
@curist
curist / lang_detect
Last active July 5, 2017 04:53
building language detector for local usage
hg clone https://code.google.com/p/chromium-compact-language-detector
cd chromium-compact-language-detector/src
curl https://chromium-compact-language-detector.googlecode.com/hg-history/51f2ced495a49d78267239da0184a61cb7519a06/build.sh > build.sh 
curl https://gist.github.com/curist/2767346/raw/e21a1c52e84ee6e867995323e7eb228c91f1786c/example.cc > example.cc
sh ./build.sh
cp example ~/bin/
@curist
curist / translate.rb
Last active July 5, 2017 04:43
google translate script
#!/usr/bin/env ruby
require 'readline'
require 'json'
require 'uri'
# for lang_detect you may want to check https://gist.github.com/2767346
LANG_DETECTOR = 'lang_detect'
class GoogleTranslate
def initialize

multiple files in the same gist

formatting

@curist
curist / github.js
Created June 25, 2012 09:47
github plugin for octopress using v3 API
var github = (function(){
function render(target, repos){
var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) {
fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
}
t.innerHTML = fragment;
}
return {
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# zsh_themes:
# git/ruby: bira, dpoggi
# git only: takashiyoshida, duellj, candy
$ diff .git-completion.sh /etc/bash_completion.d/git
292c292,296
< u="$(parse_git_dirty)"
---
> if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
> if [ -n "$(git ls-files --others --exclude-standard)" ]; then
> u="%"
> fi
> fi
@curist
curist / blogpost.md
Created November 20, 2012 06:30
Test as a new blog post

The Title

Shall we caching the gist API result at a seperate server?

That means when create a new blog post, user must also update the server file providing blog posts list, it seems will only calling the gist API one time, when the blog updated.

On the other hand, if we do this all by client side, heavier gist API calling, but creating blog post just meaning create new gist, named you_name_it.md, it's more DRY.

Let's see how the second approach performed, shall we?

@curist
curist / blogpost.md
Created November 22, 2012 06:11
foo bar

foo

  • some
  • list
  • items

bar

var i = 0;
@curist
curist / blogpost.md
Last active December 11, 2015 20:18
gist-vim and this gist-driven-blog