Skip to content

Instantly share code, notes, and snippets.

View jweyrich's full-sized avatar
:octocat:
Making some lives easier and happier!

Jardel Weyrich jweyrich

:octocat:
Making some lives easier and happier!
View GitHub Profile
@jweyrich
jweyrich / strdup_realloc.diff
Created December 17, 2010 13:27
Libevent code review
diff --git a/evdns.c b/evdns.c
index a1636a1..6f453da 100644
--- a/evdns.c
+++ b/evdns.c
@@ -3068,7 +3068,7 @@ search_request_new(struct evdns_base *base, struct evdns_request *handle,
handle->search_index = 0;
}
EVUTIL_ASSERT(handle->search_origname == NULL);
- handle->search_origname = mm_strdup(name);
+ handle->search_origname = mm_strdup(name); // XXX need retval check?
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE( "compare/long_to_unsigned_x", "Should compile fine." )
{
long long_var = 1L;
unsigned char unsigned_char_var = 1;
unsigned short unsigned_short_var = 1;
unsigned int unsigned_int_var = 1;
unsigned long unsigned_long_var = 1L;
@jweyrich
jweyrich / popen_streambuf
Last active April 18, 2022 08:34
popen + streambuf
#include <cstdio>
#include <iostream>
#include <fstream>
#define BUFFER_SIZE 1024
class popen_streambuf : public std::streambuf {
public:
popen_streambuf()
: _fp(NULL)
@jweyrich
jweyrich / hdio.cpp
Last active January 14, 2018 14:26
Retrieve Hard Disk Model, Serial, UUID
//
// Compile:
// CXXFLAGS=-lblkid make hdio
// Run:
// sudo ./hdio /dev/<device>
//
// Author: Jardel Weyrich (jweyrich at gmail dot com)
//
#include <blkid/blkid.h>
@jweyrich
jweyrich / Impl.h
Created March 6, 2013 15:15
Block using parameters with concrete types Refs https://twitter.com/Cocoanetics/status/309299850808283136
@interface SenTestCase : NSObject
@end
@interface SpecificSenTestCase : SenTestCase
@property (nonatomic, assign) NSUInteger param;
@end
typedef void (^DTSenTestCaseBlock)(SenTestCase *testCase);
@interface Impl : NSObject
@jweyrich
jweyrich / TransactionalTask.java
Last active December 29, 2015 16:09
Quick and ugly support for transactional tasks using vraptor-tasks and Hibernate.
package ...;
import br.com.caelum.vraptor.tasks.Task;
import javax.inject.Inject;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@jweyrich
jweyrich / AdminNotifierTask.java
Last active December 14, 2016 13:38
Example of a Quartz job that sends email notifications using FreeMarker templates from an application built with VRaptor. Dependencies: - vraptor-3.5.3 - vraptor-tasks-1.1.0 - vraptor-freemarker-1.1.2
package ...;
import br.com.caelum.vraptor.ioc.ApplicationScoped;
import br.com.caelum.vraptor.ioc.Container;
import br.com.caelum.vraptor.tasks.scheduler.Scheduled;
import br.com.caelum.vraptor.tasks.Task;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@jweyrich
jweyrich / output.c
Created March 15, 2014 05:32
quick & simple printing with indentation level (spaces, not tabs)
#include <stdio.h>
#include <stdarg.h>
void outputf(int level, const char *format, ...) {
FILE *stream = stdout;
static const int tab_size = 4;
const int width = level * tab_size + 1;
va_list args;
va_start(args, format);
//
// Compile and run:
// LDFLAGS="-lpcre" make pcre_ucp_test && ./pcre_ucp_test
//
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <pcre.h>
@jweyrich
jweyrich / example1.cpp
Last active November 10, 2017 18:22
Game engine draft
x=0,y=0,z=0
rootNode = 50, 50, 0 (world = 50,50,0)
card2 = 10, 0, 0 (world = 60,50,0)
salvou x=0,y=0,z=0
salvou x=50,y=50,z=0