Skip to content

Instantly share code, notes, and snippets.

@Gerjo
Gerjo / gist:3406433
Created August 20, 2012 18:23
JavaScript prototype inheritance.
function Animal(name) {
this.ssname = name;
console.log("Animal ctor", arguments);
}
Animal.prototype.walk = function() {
console.log("Animal walks", this.ssname);
}
Cat.prototype = new Animal();
@Gerjo
Gerjo / reflection.cpp
Created October 23, 2012 13:53
Pointer to member.
#include <cstdlib>
#include <iostream>
using namespace std;
class Bar {
public:
Bar(std::string thoughts) : _thoughts(thoughts) {
@Gerjo
Gerjo / lambda.cpp
Created October 23, 2012 15:08
Lambda style functions:
#include <cstdlib>
#include <iostream>
#include <functional>
using namespace std;
// http://en.cppreference.com/w/cpp/language/lambda
int main(int argc, char** argv) {
// Completely inline:
@Gerjo
Gerjo / pointers.c
Created October 23, 2012 15:11
Pointers in C
/*
* Simple program to demonstrate a couple uses for pointers. This program was
* written so I could learn more about how to apply pointers and their syntax.
* As I'm a C novice, please don't just take this file for granted as it may
* contain errors and or bad practises.
*
* By Gerard (gerjo) Meier
*/
#include <stdio.h>
@Gerjo
Gerjo / events.cpp
Created October 24, 2012 12:27
Events in Guerrilla tactics
registerEvent(IDENT_IAM, [this] (Packet* packet) -> Packet* {
_state = IDENT_ACCEPTED;
return new Packet(PacketTypes::IDENT_ACCEPTED, "Welcome.");
});
registerEvent(PING, [this] (Packet* packet) -> Packet* {
return new Packet(PacketTypes::PONG, "PONG");
});
registerEvent(REQUEST_LARGE_PACKET, [this] (Packet* packet) -> Packet* {
@Gerjo
Gerjo / shared_pointer_threads.cpp
Created October 25, 2012 16:10
Shared pointer and threading
#include <cstdlib>
#include <map>
#include <string>
#include <memory>
#include <thread>
#include <iostream>
#include <functional>
#include <unistd.h>
using std::shared_ptr;
@Gerjo
Gerjo / git_pull_all.php
Created October 28, 2012 20:08
Git pull all, a script that forks mutliple 'git submodule pull' actions. Much faster than "--recurse-submodules".
#!/usr/bin/php
<?php
$path = trim(`pwd`);
$submodulePath = $path . DIRECTORY_SEPARATOR . ".gitmodules";
$commands = array("cd {$path} && git pull");
if(is_file($submodulePath)) {
$ini = parse_ini_file($submodulePath, true);
==8793== Syscall param ioctl(generic) points to uninitialised byte(s)
==8793== at 0x37B7CEA2F7: ioctl (syscall-template.S:82)
==8793== by 0x37CF8035F7: drmIoctl (xf86drm.c:167)
==8793== by 0x5FA2BA7: drm_intel_gem_bo_free (intel_bufmgr_gem.c:930)
==8793== by 0x5FA2C9D: drm_intel_bufmgr_gem_destroy (intel_bufmgr_gem.c:1587)
==8793== by 0x5999BAD: intelDestroyScreen (intel_screen.c:382)
==8793== by 0x59DD35A: driDestroyScreen (dri_util.c:114)
==8793== by 0x37D36482B1: ??? (in /usr/lib64/libGL.so.1.2)
==8793== by 0x37D36204A5: ??? (in /usr/lib64/libGL.so.1.2)
==8793== by 0x37D3620522: ??? (in /usr/lib64/libGL.so.1.2)
==10693== HEAP SUMMARY:
==10693== in use at exit: 217,921 bytes in 1,488 blocks
==10693== total heap usage: 274,279 allocs, 272,791 frees, 72,070,871 bytes allocated
==10693==
==10693== 39 bytes in 1 blocks are definitely lost in loss record 23 of 95
==10693== at 0x4A08301: operator new(unsigned long) (vg_replace_malloc.c:298)
==10693== by 0x37C18BC2D8: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (new_allocator.h:94)
==10693== by 0x37C18BDCC4: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (basic_string.tcc:140)
==10693== by 0x37C18BDDA2: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (basic_string.h:1722)
==10693== by 0x41C289: Network::init() (Network.cpp:157)
==11337== HEAP SUMMARY:
==11337== in use at exit: 217,867 bytes in 1,487 blocks
==11337== total heap usage: 276,445 allocs, 274,958 frees, 74,240,734 bytes allocated
==11337==
==11337== 39 bytes in 1 blocks are definitely lost in loss record 23 of 94
==11337== at 0x4A08301: operator new(unsigned long) (vg_replace_malloc.c:298)
==11337== by 0x37C18BC2D8: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (new_allocator.h:94)
==11337== by 0x37C18BDCC4: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (basic_string.tcc:140)
==11337== by 0x37C18BDDA2: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (basic_string.h:1722)
==11337== by 0x41C2ED: Network::init() (Network.cpp:157)