Skip to content

Instantly share code, notes, and snippets.

View attomos's full-sized avatar
💆‍♀️

Nattaphoom Chaipreecha attomos

💆‍♀️
View GitHub Profile
" JSDoc形式のコメントを追加(functionの行で実行する)
" hogeFunc: function() の形式と function hogeFunc() に対応
" 関数定義でない場合は、コメントだけ出力する
function! AddJSDoc()
let l:jsDocregex = '\s*\([a-zA-Z]*\)\s*[:=]\s*function\s*(\s*\(.*\)\s*).*'
let l:jsDocregex2 = '\s*function \([a-zA-Z]*\)\s*(\s*\(.*\)\s*).*'
let l:line = getline('.')
let l:indent = indent('.')
let l:space = repeat(" ", l:indent)
UPSTART
sudo vi /etc/init/<reponame>.conf
add inside:
description "<reponame>"
author "name"
start on (local-filesystems and net-device-up IFACE=eth0)
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@attomos
attomos / logger.py
Last active December 21, 2015 01:59
Colorised JSON log watcher with a tag manager.
import time
import json
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
RESET = '\033[0m'
def termcolor(fg=None, bg=None):
codes = []
@attomos
attomos / prepend.py
Created August 25, 2013 04:18
Prepend files in current directory with specified text. I used this Gist to prepend my imported blog (markdown files) to serve with Jekyll.
#!/usr/bin/env python
# encoding: utf-8
import os
text_to_prepend = '# encoding: utf-8'
for root, dirs, files in os.walk('./'):
for f in files:
if f != 'prepend.py':
for file in *.markdown; do
mv "$file" "`basename $file .markdown`.md"
done

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
" vim: set ft=vim:
"set runtimepath+=~/git_repos/vimperator-plugins
let mapleader = ","
" Fast tabs {
map <S-H> gT
map <S-L> gt
" }
" Now, I can close my find bar on Vimperator

Bash (Readline)

Moving

ctrl + a                 Goto BEGINNING of command line
ctrl + e                 Goto END of command line
ctrl + b                 move back one character
ctrl + f                 move forward one character

alt + f move cursor FORWARD one word