This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class Iterator, class Function> | |
void forEach(Iterator begin, Iterator end, Function& fun) { | |
for(;begin!=end;begin++){ | |
fun(*begin); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]<<", "; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); } |
OlderNewer