Skip to content

Instantly share code, notes, and snippets.

View leafbird's full-sized avatar

choi sung ki leafbird

View GitHub Profile
@leafbird
leafbird / README.md
Last active January 8, 2023 22:51 — forked from acamino/README.md
Shortcuts to Improve Your Bash & Zsh Productivity

Shortcut — Action

  • CTRL + A — Move to the beginning of the line
  • CTRL + E — Move to the end of the line
  • CTRL + [left arrow] — Move one word backward (on some systems this is ALT + B)
  • CTRL + [right arrow] — Move one word forward (on some systems this is ALT + F)
  • CTRL + U — (bash) Clear the characters on the line before the current cursor position
  • CTRL + U —(zsh) If you're using the zsh, this will clear the entire line
  • CTRL + K — Clear the characters on the line after the current cursor position
  • ESC + [backspace] — Delete the word in front of the cursor
namespace Cs.Core.Core
{
using System;
using System.Collections.Generic;
using System.Linq;
// 참고 : https://www.geeksforgeeks.org/lru-cache-implementation/
public sealed class LruCache<TKey, TElement>
{
private readonly LinkedList<(TKey Key, TElement Value)> timeline = new LinkedList<(TKey, TElement)>();
namespace Utility
{
using System;
using System.Linq.Expressions;
using System.Reflection;
public static class PropertySelector
{
public static PropertyInfo GetPropertyInfo<T>(this T obj, Expression<Func<T, object>> selector)
{
@leafbird
leafbird / FunctionTraits.h
Last active August 29, 2015 14:14
Typelist: Implemented by variadic templates
#include "TypeList.h"
// from : https://functionalcpp.wordpress.com/2013/08/05/function-traits/
template<class F>
struct function_traits;
// function pointer
template<class R, class... Args>
struct function_traits<R(*)(Args...)> : public function_traits<R(Args...)> {
@leafbird
leafbird / HttpClient.cpp
Last active August 29, 2015 14:13
HttpClient with boost::asio
#include "StdAfx.h"
#include "HttpClient.h"
namespace AsioHttp
{
using boost::asio::ip::tcp;
class Client::ClientImpl
{
@leafbird
leafbird / Singleton.cs
Created March 5, 2014 10:59
...One approach is to use an idiom referred to as Double-Check Locking [Lea99]. However, C# in combination with the common language runtime provides a static initialization approach, which circumvents these issues without requiring the developer to explicitly code for thread safety.
// from http://msdn.microsoft.com/en-us/library/ff650316.aspx
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
private Singleton(){}
public static Singleton Instance
{
@leafbird
leafbird / slnParser.cs
Created September 3, 2013 06:02
C#에서 visual studio 솔루션파일 파싱해주는 코드. 출처 : http://stackoverflow.com/questions/707107/library-for-parsing-visual-studio-solution-files
public class Solution
{
//internal class SolutionParser
//Name: Microsoft.Build.Construction.SolutionParser
//Assembly: Microsoft.Build, Version=4.0.0.0
static readonly Type s_SolutionParser;
static readonly PropertyInfo s_SolutionParser_solutionReader;
static readonly MethodInfo s_SolutionParser_parseSolution;
static readonly PropertyInfo s_SolutionParser_projects;
@leafbird
leafbird / fstream_utf8.cpp
Created June 25, 2013 15:25
std::fstream 계열로 파일 I/O를 할 때 utf-8인코딩을 사용하도록 설정하는 코드. 출처 : http://sockbandit.wordpress.com/2012/05/31/c-read-and-write-utf-8-file-using-standard-libarary/
#include <fstream>
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
...
// Write file in UTF-8
std::wofstream wof;
wof.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8<wchar_t,0x10ffff,std::generate_header>));
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
AllocConsole();
function asyncMap( list, fn, cb_ ) {
var n = list.length
, result = []
, errState = null;
function cb (er, data) {
if (errState) return;
if (er) return cb_(errState = er);
results.push(data);
if (--n === 0) // 모든 리스트 처리 완료시