Skip to content

Instantly share code, notes, and snippets.

View mytharcher's full-sized avatar
🏠
Working from home

Junyi mytharcher

🏠
Working from home
View GitHub Profile
@mytharcher
mytharcher / MY_Session.php
Created November 20, 2013 13:14
CI improvements
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* @package php-bootstrap
* @author mytharcher
* @copyright Copyright (c) since 2013
* @license MIT Licenced
*/
@mytharcher
mytharcher / app.js
Created March 13, 2013 05:29
Partials path config for Hogan(Mustache) in Express.js
app.set('partials', require('./lib/partials'));
@mytharcher
mytharcher / .bash_profile
Last active December 14, 2015 17:28
Mac profiles
export PS1="\w $ "
export CLICOLOR=1
export GREP_OPTIONS="--color=auto"
alias cl="source cl.sh"
alias work="cd ~/work"
alias ll="ls -al"
alias ahosts="vi ~/etc/apache2/httpd-vhosts.conf"
alias vhosts="sudo vi /etc/hosts"
alias subl='open -a "Sublime Text 2"'
@mytharcher
mytharcher / migrate.js
Last active December 14, 2015 11:09
Node script for migrating all images in markdown posts into figure tags.
/**
* usage:
*
* $ node migrate.js path/to/posts/dir
*/
var fs = require('fs');
var path = require('path');
var ENCODING = 'utf8';
@mytharcher
mytharcher / binarySearch.js
Created November 29, 2012 06:39
JavaScript snips
function binarySearch (array, matcher) {
var len = array.length,
head = 0,
tail = len - 1,
offset = got = Math.ceil(tail / 2);
if (offset == tail) {
return offset;
}
@mytharcher
mytharcher / fix-win2mac-txt.sh
Created November 28, 2012 00:26
Common shells
#!/bin/bash
#Change all txt file from Windows form to Max form.
for post in $(find . -type f)
do
# echo $post
cat $post > temp.md
mv -f ./temp.md $post
done
@mytharcher
mytharcher / authorization.js
Created November 7, 2012 15:16
A demo testing HTTP 401 authorization on node.js
var approot = process.env.PWD;
var db = require(approot + '/lib/db');
var encrypt = require(approot + '/lib/encrypt');
exports = module.exports = function (req, res, next) {
console.log('processing authorization...');
var session = req.session;
@mytharcher
mytharcher / er-package.sh
Created August 10, 2012 09:13
Web assets package script for ER project
#!/bin/sh
WORK_BASE=$(pwd)
CLIENT_DIR=$WORK_BASE/un-web-client/src/main/webapp
TEMP_DIR=$WORK_BASE/building_temp
cd $CLIENT_DIR
### process *.html -> tpl.html
sed 's/.*"\(.*\.html\)".*/\1/' "assets/js/~template.js" | grep tpl | xargs cat |
@mytharcher
mytharcher / references.rb
Last active October 5, 2015 05:47 — forked from olov/references.rb
Jekyll markdown references plugin by Olov Lassus: Keep all your markdown reference-style link definitions in one file (_references.md)
# references.rb: jekyll markdown references plugin
#
# add this file to your _plugins directory (create it if needed)
# create a file (exactly) named _references.md in your Jekyll site root,
# then add your markdown reference-style link definitions to it.
# for example:
# [jsshaper]: http://jsshaper.org "an extensible framework for JavaScript syntax tree shaping"
#
# you can now reference these links in any markdown file
# for example:
@mytharcher
mytharcher / compressor.rb
Last active May 10, 2022 01:56
A jekyll plugin for compressing HTML, JavaScript files when rendering.
#
# File compressor plugin for jekyll
# =================================
#
# By [mytharcher](https://github.com/mytharcher)
# 2012-05-20
#
# Updated by [nicoespeon](https://github.com/nicoespeon)
# 2013-04-12
#