Skip to content

Instantly share code, notes, and snippets.

View juehan's full-sized avatar

John.L juehan

  • Sydney, Australia
View GitHub Profile
#include <future>
#include <iostream>
#include <chrono>
//Speculative execution using std::future<> wait_for()
int quick_but_gestimation()
{
for (int i=0; i < 2; i++)
{
@juehan
juehan / cpp11_cond_variable_example.cpp
Created January 24, 2013 02:49
Consumer - producer example using C++11 thread
#include <condition_variable>
#include <mutex>
#include <future>
#include <iostream>
#include <chrono>
#include <queue>
bool isReady;
std::mutex mutex;
std::condition_variable condvar;
@juehan
juehan / cpp11_multidimensional_array.cpp
Created January 16, 2013 01:55
C++11 way of multidimensional array
#include <iostream>
#include <array>
int main(){
//multi-dimensional array with newly introducted in C++11
// a hundred array of 10 element array
const size_t i = 100;
std::array<std::array<size_t, 10>, i> myarr;
@juehan
juehan / async_future_example02.cpp
Created January 14, 2013 10:17
C++11 async() and future<> allow us task based parallel programming.
#include <future>
#include <iostream>
#include <vector>
int main()
{
std::cout << "Task parallerism using C++11 async() and future<>" << std::endl;
std::cout << "Main thread id: " << std::this_thread::get_id()
@juehan
juehan / cpp11_thread_async_future.cpp
Last active December 11, 2015 02:09
C++11 high level thread interface using async() and future<>
#include <future>
#include <iostream>
void print2Screen(char c)
{
for(int i = 0; i < 50; i++)
{
std::cout.put(c).flush();
_sleep(100); //sleep 100 millisec
@juehan
juehan / geolocation.html
Created December 13, 2012 05:57
Geolocation API in HTML5
<!doctype html>
<html>
<head>
<title>Geolocation API in HTML5</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
</head>
<body>
<p>Geolocation API in HTML5</p>
<button id="btnGeo">Show where i am</button>
@juehan
juehan / jscript_basic.html
Created December 5, 2012 00:28
javascript basic terminology
<html>
<head>
<title>
JohnL javascript practice
</title>
<script type="text/javascript">
var titleOfApplication = "JohnL application";
window.titleOfApplication;
@juehan
juehan / sqlite_test.py
Created November 24, 2012 22:28
python sqlite3 test code
'''
C:\temp\sqlite> sqlite3 test.db "create table location (lid integer primary key, lname text);"
C:\temp\sqlite> sqlite3 test.db "insert into location (lid, lname) values (0, "Waitara, NSW");"
Software\sqlite3.exe: Error: too many options: "Waitara"
-help for a list of options.
C:\temp\sqlite> sqlite3 test.db "insert into location (lid, lname) values (0, 'Waitara, NSW');"
C:\temp\sqlite> sqlite3 test.db "insert into location (lid, lname) values (1, 'Hornsby, NSW');"
C:\temp\sqlite> sqlite3 test.db "insert into location (lid, lname) values (2, 'Rhodes, NSW');"
C:\temp\sqlite> sqlite3 test.db "insert into location (lid, lname) values (3, 'Strathfield, NSW');"
C:\temp\sqlite>
@juehan
juehan / sublimeText2configForKorean
Created November 10, 2012 01:08
sublime text2 한글 셋팅
//Preference > Setting-user 로 이동하여 다음 내용 입력
{
"color_scheme":"Packages/color scheme - Default/Twilight.tmTheme",
"font_size": 12,
"font_face": "Malgun Gothic"
}
@juehan
juehan / Cpp11UniformInitialization.cpp
Created November 10, 2012 00:53
C++11: Uniform Initialization
/*
* Uniform Initialization: C++11
* compiled under g++4.7.2
* */
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>