Skip to content

Instantly share code, notes, and snippets.

View heejune's full-sized avatar

Heejune heejune

View GitHub Profile
@heejune
heejune / set_package_version.py
Last active September 22, 2017 07:13
AssemblyInfo.cs update version info
def set_package_version(manifest_file, target_version):
from xml.etree import ElementTree as et
et.register_namespace("", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
et.register_namespace("mp","http://schemas.microsoft.com/appx/2014/phone/manifest")
et.register_namespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
tree = et.parse(manifest_file)
e = tree.find('{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity')
struct routing_record
{
virtual reply handle(void*) abstract;
};
template <typename T>
struct typed_routing_recored;
template <typename RetType, typename classTy, typename... ArgType>
struct typed_routing_recored<RetType(classTy::*)(ArgType...) const> : public routing_record
struct routing_delegator
{
routing_delegator() {} // default
routing_delegator(std::vector<std::string> r) : ruleset(r) {}
// register functor handler
template <typename F>
void to(F&& f)
{
routing_data = std::make_unique<typed_routing_recored<decltype(&F::operator())>>(f);

Keybase proof

I hereby claim:

  • I am heejune on github.
  • I am heejune (https://keybase.io/heejune) on keybase.
  • I have a public key ASBTjB-ljb8r_A1ald0ZHD--uWUwa009owTp3KM3FZyKoQo

To claim this, I am signing this object:

#include <memory>
// note1. 홀수 n이 주어졌을 때, n이 몇 번째 홀수인지 알아내려면 (n - 3) >> 1 한다.
unsigned long get_nth_prime_with_optimized_sieve(unsigned long n) {
unsigned long precompute_max_count = 200000;
// prime number를 체크하기 위해 우선 대상이 될 모든 odd number들을 담을 배열을 만든다.
vector<bool> odd_numbers_divisible(precompute_max_count/2); // odd numers
/// snippet from
/// http://www.geeksforgeeks.org/sieve-of-eratosthenes/
///
std::vector<bool> SieveOfEratosthenes(unsigned long less)
{
// Create a boolean array "prime[0..n]" and initialize
// all entries it as true. A value in prime[i] will
// finally be false if i is Not a prime, else true.
vector<bool> prime(less + 1);
std::fill(begin(prime), end(prime), true);
unsigned long get_nth_prime_without_sieve(unsigned long n) {
if (n == 0) return 0;
if (n == 1) return 2;
unsigned long prime_num = 3;
unsigned long local_n = 2; // 2th prime number is 3
while (local_n != n) {
bool isPrime(unsigned long num)
{
if (num == 2)
return true;
if (num <= 1 || num % 2 == 0) // 0, 1, and all even numbers
return false;
for (unsigned long x = 3; x*x <= num; x += 2) {
if (num % x == 0)
@heejune
heejune / slack_uploader.py
Created February 28, 2017 02:05
how to upload a file with SlackClient library
from slackclient import SlackClient
class SlackBot(object):
'''
SlackBot:
'''
def __init__(self, logger, slackclient):
self.logger = logger or logging.getLogger(__name__)
self.slack_client = slackclient or SlackClient(os.environ.get('SLACK_BOT_TOKEN'))
@heejune
heejune / democore.cpp
Created February 25, 2017 12:40
wrl and cppwinrt combination
winrt::Windows::Foundation::IAsyncOperation<int> GetAsyncOp()
{
using namespace winrt;
using namespace Windows::Foundation;
for (int i = 0; i != 5; ++i)
{
co_await 5000ms;
}