Skip to content

Instantly share code, notes, and snippets.

View nurettin's full-sized avatar
🏠
Working from home

Nurettin Onur TUĞCU nurettin

🏠
Working from home
View GitHub Profile
@nurettin
nurettin / xkb.sh
Last active August 29, 2015 13:55
switch between us and tr keyboards while keeping modmap
#!/bin/bash
setxkbmap -query | grep "\Wtr" 1>/dev/null && setxkbmap us || setxkbmap tr
xmodmap /home/nurettin/.Xmodmap
@nurettin
nurettin / pwned_recursive_map.cpp
Created January 4, 2014 12:09
who wants types?
#include <iostream>
#include <map>
#include <string>
#include <boost/variant.hpp>
typedef boost::variant<std::string, double, int> Data;
struct Graph: std::map<Data, Graph>
{
Data data;
@nurettin
nurettin / pwned_combinator.cpp
Last active December 28, 2015 23:59
The Pwned Combinator
/*
The Pwned Combinator is a patten which gives you the ability to store a common base for templated classes in a container
while not losing the ability to access the member variables and functions of the derived instance.
In this pattern, the base class uses polymorphism to signal usage which then triggers the callable.
*/
struct Base
{
virtual void use()= 0;
@nurettin
nurettin / lazy_concept.cpp
Last active December 28, 2015 21:09
C++11 lazy parameters
#include <functional>
#include <vector>
#include <boost/optional.hpp>
struct LazyBase
{
std::vector<std::reference_wrapper<LazyBase>> dependents;
virtual void nullify()= 0;
virtual ~LazyBase(){}
};
@nurettin
nurettin / bench.cpp
Created November 15, 2013 12:01
pretty benchmark class
// the idea is to benchmark and output pretty results
#include <iostream>
#include <functional>
#include <chrono>
#include <vector>
struct Fun
{
std::string name;
@nurettin
nurettin / ruby.cpp
Created November 7, 2013 14:40
ruby in my c++
#include <functional>
struct Times
{
unsigned long long t;
Times(unsigned long long t)
: t(t)
{}
void operator()(std::function<void(unsigned long long)> block)
@nurettin
nurettin / .vimrc
Last active December 26, 2015 08:29
no tab to space expanding when editing Makefiles
syn on
set ts=2
set sw=2
set et
set ai
set nocp
set bg=dark
autocmd FileType make setlocal noet
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
@nurettin
nurettin / .Xmodmap
Created October 23, 2013 16:34
X keyboard modification to convert [CapsLock] to [Tab] (because my tab key broke)
remove Lock = Caps_Lock
keycode 66 = Tab ISO_Left_Tab Tab ISO_Left_Tab
keycode 23 = Caps_Lock NoSymbol Caps_Lock
@nurettin
nurettin / create_class_otf.rb
Created October 2, 2013 07:37
create_class_otf.rb
x= Class.new Object do
def inspect
"lol!"
end
end
module Lol
end
Object.const_set("Wtf", x)
@nurettin
nurettin / becauseican.cpp
Created September 14, 2013 10:42
C++, because I can.
#include <iostream>
#include <map>
#include <boost/any.hpp>
#include <curl/curl.h>
typedef std::map<std::string, boost::any> params_t;
void open(params_t params)
{
if(boost::any_cast<bool>(params["session"]))