Skip to content

Instantly share code, notes, and snippets.

View codeb2cc's full-sized avatar
🎯
Focusing

Codeb Fan codeb2cc

🎯
Focusing
  • Eastworld AI
  • Singapore
View GitHub Profile
@codeb2cc
codeb2cc / issue.txt
Created November 29, 2012 06:03
Text base issue system template
==== ==== ==== ==== Issue #0 ==== ==== ==== ====
Summary:
Description:
Priority: Critical | Major | Normal | Minor
Type: Bug | Feature | Optimization
State: Open | In Progress | Fixed | Closed
Assignee:
Comments:
@codeb2cc
codeb2cc / ip.sh
Created October 29, 2012 02:50
Get PPPoe IP address
#!/bin/sh
if [ `nm-tool | ack eth0 -A 5 | ack State | sed 's/ *//g' | cut -f 2 -d ':'` == "connected" ]; then
# Interface eth0 UP
:
else
# Interface eth0 DOWN. Try to restart
ifup eth0
fi
@codeb2cc
codeb2cc / .bashrc
Last active October 10, 2015 00:48
PS1 on server
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
/*jshint asi:true, browser:true */
define(function (require, exports) {
var extend = function (obj) {
each(slice.call(arguments, 1), function (source) {
for (var prop in source) {
obj[prop] = source[prop]
}
})
@codeb2cc
codeb2cc / postMessageA.html
Created August 30, 2012 10:37
window.postMessage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p></p>
<div style="border: 1px solid whiteSmoke">
<iframe src="./postMessageB.html" frameborder="0" style="width: 100%;"></iframe>
@codeb2cc
codeb2cc / gist:3347349
Created August 14, 2012 08:02
Terminator config file
[global_config]
title_hide_sizetext = True
title_transmit_bg_color = "#ededed"
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
title_transmit_fg_color = "#080808"
title_inactive_bg_color = "#ededed"
[keybindings]
[profiles]
[[default]]
use_system_font = False
@codeb2cc
codeb2cc / gist:3302754
Created August 9, 2012 09:48
Sqlalchemy get_or_create implement
# -*- coding: utf-8 -*-
from sqlalchemy.exc import IntegrityError
from sqlalchemy.sql.expression import ClauseElement
def _get_or_create(session, model, defaults=None, **kwargs):
try:
query = session.query(model).filter_by(**kwargs)
instance = query.first()
@codeb2cc
codeb2cc / gist:3177704
Created July 25, 2012 18:24
Git log alias
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@codeb2cc
codeb2cc / gist:3150132
Created July 20, 2012 10:50
Inserted Script
;(function () {
"use strict"
var doc = document
var head = doc.head ||
doc.getElementsByTagName('head')[0] ||
doc.documentElement
function scriptOnload(node, callback) {
@codeb2cc
codeb2cc / mongoengine_index.py
Created March 12, 2012 03:55
MongoEngine Index Definition
# -*- coding:utf-8 -*-
from pprint import pprint
import pymongo, mongoengine
class TheDocument(mongoengine.Document):
field_a = mongoengine.StringField()
field_b = mongoengine.StringField()
field_c = mongoengine.StringField()