Skip to content

Instantly share code, notes, and snippets.

Avatar

Heejune heejune

View GitHub Profile
@heejune
heejune / gist:1e75b323e596eaafa21f
Created May 24, 2015 13:22
Mixing CRT link type will cause debug assert when it freed
View gist:1e75b323e596eaafa21f
if (pHead->pBlockHeaderPrev)
{
pHead->pBlockHeaderPrev->pBlockHeaderNext = pHead->pBlockHeaderNext;
}
else
{
_ASSERTE(_pFirstBlock == pHead);
_pFirstBlock = pHead->pBlockHeaderNext;
}
@heejune
heejune / gist:05e1dccc33943d193352
Created May 24, 2015 13:25
cpprestsdk json test
View gist:05e1dccc33943d193352
#include <cpprest\json.h>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
web::json::value root;
std::wstring filepath = L"config.json";
std::ifstream ifs;
@heejune
heejune / output.log
Created December 7, 2015 00:40
LNK2019 error message while linking QT with static lib
View output.log
2>xxxwidget.obj : error LNK2019: unresolved external symbol "void __cdecl yyy::zzzstring(...)" (?zzzstring@xxx@@YAXPAU_GUID@@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z) referenced in function __catch$?nnn@mmm@@...... :
fatal error LNK1120: 1 unresolved externals
@heejune
heejune / build.py
Created December 7, 2015 15:14
Launch a msbuild=
View build.py
# Sample code snippet..
def start(self, version):
msbuild = os.getenv('MSBUILD_PATH', r"C:\Program Files\MSBuild\12.0\Bin\MSBuild.exe")
project_output_dir = os.getenv('PROJECT_OUTPUT_DIR', r'c:\Build_distribute\')
if not os.path.exists(msbuild):
raise Exception('not found ' + msbuild)
projects = [r"..\yoursolution.sln", r"..\yourproject\yourproject.vcxproj"]
@heejune
heejune / manage_version.py
Created December 7, 2015 15:19
Specify the version at .rc resource file
View manage_version.py
# source taken from
# http://stackoverflow.com/questions/4003725/modifying-rc-file-with-python-regexp-involved
# target_version = "2,3,4,5"
def set_rc_version(rcfile, target_version):
with open(rcfile, "r+") as f:
rc_content = f.read()
# first part
@heejune
heejune / ocr_bot.py
Created January 26, 2016 01:08
telegram bot example uses the tesseract to process OCR request
View ocr_bot.py
import sys
import asyncio
import random
import telepot
from telepot.delegate import per_chat_id
from telepot.async.delegate import create_open
import os
import traceback
@heejune
heejune / setup-orgmode.el
Created March 5, 2016 04:08
orgmode XeLaTex override example
View setup-orgmode.el
(eval-after-load 'org
(lambda()
(require 'ob-C)
(require 'org-bullets)
(require 'ox-taskjuggler)
(require 'ox-latex)
;; …
(setq org-latex-to-pdf-process
@heejune
heejune / PDFFile_webbrowser_invoke.cs
Created June 21, 2016 00:58
Convert the PDF file into base64 string and pass it to the webbrowser control
View PDFFile_webbrowser_invoke.cs
if (locateText.Text.EndsWith("pdf", true, null) == true &&
File.Exists(locateText.Text) == true)
{
var buffer = File.ReadAllBytes(locateText.Text);
// Document.InvokeScript seems not understanding the Blob type
//object[] args = { fileBytes };
//webBrowser1.Document.InvokeScript("PDFViewerApplication.open", args);
// so convert it to base64 and pass it
@heejune
heejune / invoke_pdfjs_viewer_with_base64.js
Created June 21, 2016 01:01
Open PDFjs as base64 string
View invoke_pdfjs_viewer_with_base64.js
// https://github.com/heejune/WinForm-PDFjs/blob/master/WinFormPDFViewer/pdfjs-1.4.20-dist/web/viewer.js
// PDFViewerApplication.open wrapper for base64 param
window.openPdfAsBase64 = function (base64) {
var binary_string = window.atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
@heejune
heejune / countera.py
Created July 19, 2016 16:50
Telegram bot takes a photo using a pi camera and replies back running on Raspberry Pi
View countera.py
import sys
import asyncio
import telepot
from telepot.aio.delegate import per_chat_id, create_open
import picam
"""
$ python3.5 countera.py <token>