Skip to content

Instantly share code, notes, and snippets.

View kbinani's full-sized avatar

kbinani kbinani

View GitHub Profile
@kbinani
kbinani / GetModuleFileName.cpp
Last active September 12, 2019 01:22
GetModuleFileName (WinAPI) equivalent implementation for OSX
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>
#include <dlfcn.h>
#include <string>
std::string GetModuleFileName(const void *module)
{
if (!module) { return std::string(); }
uint32_t count = _dyld_image_count();
for (uint32_t i = 0; i < count; ++i) {
#!/usr/bin/env ruby
require 'tempfile'
require 'fileutils'
def usage
print "usage: xcode-textencoding [project-file] [text-encoding-name]\n"
print " project-file a file path of Xcode project (ex. some.xcodeproj)\n"
print " text-encoding-name screen name of text encoding\n"
end
#include "convert_text_encoding.hpp"
#include <CoreServices/CoreServices.h>
#include <memory>
namespace detail
{
//!
//! @brief Get string encoding of wstring.
CFStringEncoding get_wide_string_encoding();
@kbinani
kbinani / RunGitDaemon.vbs
Created March 28, 2013 04:28
A git-daemon starter script for Windows.
' About:
' A git-daemon starter script for Windows.
'
' Workflow:
' 1. C:\>mkdir GitRepositories
' 2. C:\>cd GitRepositories
' 3. C:\GitRepositories>mkdir sample.git
' 4. C:\GitRepositories>cd sample.git
' 5. C:\GitRepositories\sample.git>"C:\Program Files\Git\bin\git.exe" init --bare
' 6. Edit this script to change 'git' and 'repository_base_path'
set PREFIX="C:\Boost"
set MAX_JOB=4
call bootstrap.bat
b2.exe install link=static,shared --prefix=%PREFIX% -j %MAX_JOB%
b2.exe install link=static runtime-link=static --prefix=%PREFIX% -j %MAX_JOB%
call bootstrap.bat gcc
b2.exe install link=static,shared --prefix=%PREFIX% -j %MAX_JOB% toolset=gcc
b2.exe install link=static runtime-link=static --prefix=%PREFIX% -j %MAX_JOB% toolset=gcc
@kbinani
kbinani / build-httpd-rpm.sh
Last active December 11, 2015 13:59
build httpd rpm
#!/bin/bash
function build_httpd_rpm { (
local base_version=$1
local buildroot=$(rpmbuild --eval=%_topdir 2>/dev/null | tr -d '\n')
mkdir -p $buildroot
local major_version=$(echo $base_version | cut -f1 -d'.')
local minor_version=$(echo $base_version | cut -f2 -d'.')
local release_version=$(
// ==UserScript==
// @name Google Header
// @namespace http://kbinani.info/
// @description
// @include https://mail.google.com/*
// @include https://www.google.com/reader/*
// ==/UserScript==
(function() {
setInterval(function() {
@kbinani
kbinani / svn-export.sh
Last active December 18, 2021 01:03
A shell script to export svn repository without subversion client.
#!/bin/bash
function svn_export {
function svn_export_one { (
local url=$1
local directory=$2
local revision=$3
local prefix="$(echo $url | cut -b $(expr ${#base_url} + 2)-)"
for file in $(curl -L "$url?p=$revision" 2>/dev/null | grep '<li><a href=".*"' | sed 's:^.*<li><a href=".*">\(.*\)</a>.*$:\1:g'); do
if [ "$file" = "$(echo $file | sed 's:^.*\(/\)$:\1:g')" -a "$file" != ".." ]; then
while :; do if git svn fetch; then break; else sleep 60; fi done
@kbinani
kbinani / alias_svndiff.sh
Created January 8, 2013 05:39
A shell alias 'svndiff', colored svn diff command like 'git diff'.
alias svndiff='svn diff --diff-cmd=colordiff --extensions=" -u --strip-trailing-cr --ignore-space-change " | less --quit-if-one-screen'