Skip to content

Instantly share code, notes, and snippets.

View madbence's full-sized avatar
🙈
watching cat videos on the internet

Bence Dányi madbence

🙈
watching cat videos on the internet
View GitHub Profile
@madbence
madbence / .tmux.conf
Created July 21, 2013 21:40
My current .tmux.conf file
# screen-like prefix
unbind C-b
set -g prefix C-a
# Indexing from 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded tmux config file."
@madbence
madbence / gist:6046873
Last active December 20, 2015 01:09
My current .vimrc file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" modeline magic!
set modeline
" required!
@madbence
madbence / dns.js
Created July 2, 2013 07:25
Simple DNS server in nodejs for testing purposes. Sometimes it works!
var udp = require('dgram');
var server = udp.createSocket('udp4');
var client = null;
server.on('message', function(msg, rinfo) {
if(rinfo.address = '127.0.0.1') {
client = rinfo;
} else {
server.send(msg, 0, msg.length, client.port, client.address);
}
var offset = 12,
public class App {
public interface A {
B foo();
}
public static class B {
B foo() { return null; }
}
public static class C implements A {
private int x;
public void baz(B b) {}
@madbence
madbence / gist:5639239
Last active May 23, 2023 17:35
Infix operators in C++ :o
#include <iostream>
using namespace std;
template<class T>
struct Bind {
T first;
T (*fun)(const T&, const T&);
Bind(T (*fun)(const T&, const T&), T f):first(f), fun(fun){}
T operator()(const T& o) { return fun(first, o); }
#include <iostream>
using namespace std;
int main()
{
int arr[4][4];
for(int i=0;i<4;i++) for(int j=0;j<4;j++) arr[i][j]=i*4+j;
for(int i=0;i<16;i++) {
cout<<((int*)arr)[i]<<", ";
#include <iostream>
template <class T>
class Vektor
{
protected:
T x;
T y;
public:
Vektor(const T& x = T(), const T& y = T()) : x(x), y(y) { } //Default konstruktor
@madbence
madbence / cpp_lab10_15+.cpp
Created April 16, 2013 19:51
Szoftver laboratórium 2, 10. labor, szorgalmi
// ha T nem primitív típus
template<class T>
bool isPrimitiveType() { return false; }
// kivéve, ha pl int.
// a teljes megoldáshoz double, stb-re is meg kéne írni, ezért fapados kicsit :-)
template<>
bool isPrimitiveType<int>() { return true; }
// A módosított Array konstruktor
@madbence
madbence / cpp_lab10_15.cpp
Created April 16, 2013 19:48
Szoftver laboratórium 2, 10. labor, 15. feladat
Array<int, 20> t(1);
t.at(8) = 12;
for (size_t i = 0; i < 8; i++)
cout << t.at(i) << endl;
//konstruktor:
explicit Array(size_t n = maxsiz, const T& value = T()) : siz(0) {
// default értékkel feltölti a tömb méretéig, utána tényleg memóriaszemét lesz!
// Ha kitöröljük, tényleg nem 0-kat kapunk...
while (siz < n && siz < maxsiz)
@madbence
madbence / cpp_lab10_11b.cpp
Created April 16, 2013 19:12
Szoftver laboratórium 2, 10. labor, 11. feladat, második próbálkozás
template <class T>
class OstreamFunctor {
ostream& os;
const char* delim;
public:
ostreamFunctor(ostream& os, const char* delim = ""):os(os),delim(delim){}
/**
* A const módosító kényelmi okokból van csak ott,
* ha akarnánk, lehagyhatnánk.
* Viszont akkor konstans objektumon nem működne, mi pedig szeretnénk azt is.