Skip to content

Instantly share code, notes, and snippets.

View yeonsh's full-sized avatar

Seunghoon Yeon yeonsh

View GitHub Profile
@yeonsh
yeonsh / gist:9407615
Created March 7, 2014 08:29
Date string to timestamp
import time
import datetime
date_string = '2013-03-07'
date = datetime.datetime.strptime(date_string, '%Y-%m-%d')
time.mktime(date.timetuple())
==> 1362582000.0
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
/**
* Use this class when you provide logics for background execution.
*
* Implement your code in onAsyncTaskExecute().
*
* If you have to reuse your code, define a dedicated task class using BDAsyncTaskSkeleton class.
@SuppressLint("NewApi")
@SuppressWarnings("unchecked")
public static void executeTaskInParallel(@SuppressWarnings("rawtypes") AsyncTask task, Bundle params) {
if (MyUtil.hasHoneycomb()) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
task.execute(params);
}
}
iex> 1 # integer
iex> 0x1F # integer
iex> 1.0 # float
iex> :atom # atom / symbol
iex> {1,2,3} # tuple
@yeonsh
yeonsh / tour_of_go_answers
Last active August 29, 2015 14:06
Tour of Go exercise solutions
// #38
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
board := make([][]uint8, dx)
for i := 0; i < dx; i++ {
board[i] = make([]uint8, dy)
@yeonsh
yeonsh / gist:4b3e59d3fc2fdb21c122
Created January 10, 2015 12:08
Python logging
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# create a file handler
handler = logging.FileHandler('hello.log')
handler.setLevel(logging.INFO)
@yeonsh
yeonsh / gist:811a32f4af42ee98578f
Created April 10, 2015 14:19
Change log format to make it conform to Linux g++ rules.
import os
import re
regex = re.compile(r"(.*)(GLOG[A-Z]*\([A-Z]+::[A-Z_]+\s*,\s*)(__FUNCTION__)\s*(\")([^\"]+\")(\s*,\s*.*){0,1}(\s*\)\s*;){0,1}")
def test_code():
s=[]
s.append(' GLOGNOFLA(LOGLEVEL::LL_DEBUG, __FUNCTION__ " toSign [%s]");')
s.append(' GLOGNOFLA(LOGLEVEL::LL_DEBUG, __FUNCTION__ " toSign [%s]", toSign.c_str());')
s.append('GLOGNOFLA(LOGLEVEL::LL_ERROR, __FUNCTION__ " failed(%s) : %s", rtn.curlerror.c_str(), curl->GetLastURL().c_str());')
@yeonsh
yeonsh / $ brew install $(brew deps owncloud-client)
Created September 11, 2015 04:06
$ brew install $(brew deps owncloud-client)
$ brew install $(brew deps owncloud-client)
Warning: cmake-3.3.1 already installed
Warning: pkg-config-0.28 already installed
==> Downloading https://homebrew.bintray.com/bottles/d-bus-1.8.20.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring d-bus-1.8.20.yosemite.bottle.tar.gz
==> /usr/local/Cellar/d-bus/1.8.20/bin/dbus-uuidgen --ensure=/usr/local/var/lib/dbus/machine-id
==> Caveats
To have launchd start d-bus at login:
ln -sfv /usr/local/opt/d-bus/*.plist ~/Library/LaunchAgents
@yeonsh
yeonsh / gist:f900fd820e3d0d23b142
Created September 11, 2015 04:52
cmake --help-policy CMP0042 (About @rpath)
$ cmake --help-policy CMP0042
CMP0042
-------
``MACOSX_RPATH`` is enabled by default.
CMake 2.8.12 and newer has support for using ``@rpath`` in a target's install
name. This was enabled by setting the target property
``MACOSX_RPATH``. The ``@rpath`` in an install name is a more
flexible and powerful mechanism than ``@executable_path`` or ``@loader_path``
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
start_time = NSDate.date()
class MyApplicationAppDelegate(NSObject):
state = 'idle'