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
var net = require('net');
net.createServer(function(sock) {
console.log('rikveszt!');
var start = new Date().getTime();
var payload = '';
for (var i = 0; i < 10000; i++) {
payload += 'LoL';
}
var j = 0;
var i = 0;
setInterval(function() {
i = Math.random() * 30 - 15;
for (var j = 0, l = document.getElementsByTagName('*'); j < l.length; j++) {
l[j].style.webkitTransform = 'rotate(' + (i / 50) + 'deg) translate(' + Math.sin(i / 6) * 10 + 'px,' + Math.sin(i / 6) * 10 + ')';
}
}, 100);
@madbence
madbence / cpp_lab10_10.cpp
Last active December 16, 2015 07:28
Szoftver laboratórium 2, 10. labor, 10. feladat
template<class Iterator, class Function>
void forEach(Iterator begin, Iterator end, Function& fun) {
for(;begin!=end;begin++){
fun(*begin);
}
}
@madbence
madbence / cpp_lab10_11a.cpp
Last active December 16, 2015 07:28
Szoftver laboratórium 2, 10. labor, 11. feladat, első próbálkozás
template<class T>
void print(const T& o) {
cout<<o<<", ";
}
//meghívás:
forEach(it1, it1+10, print<int>);
//de működik iterátorral is, minden varázslás nélkül!
forEach(intarr1.begin(), intarr1.end(), print<int>);
@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.
@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_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
#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
#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]<<", ";
@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); }