Skip to content

Instantly share code, notes, and snippets.

View luca3m's full-sized avatar

Luca Marturana luca3m

View GitHub Profile
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package testjmx;
import java.lang.management.ManagementFactory;
import java.util.Random;
import javax.management.MBeanServer;
@luca3m
luca3m / test.py
Created August 26, 2016 09:39
Python oddities
def func(param=[]):
param.append("test")
return param
assert func() == [ "test", ]
assert func() == [ "test", "test", ]
assert func() == [ "test", "test", "test" ]
@luca3m
luca3m / perf.sh
Created November 3, 2015 12:42
perf+flamegraph
perf record -F 99 -g -p $1 -- sleep 60
perf script > out.perf
./FlameGraph/stackcollapse-perf.pl out.perf > out.perf.folded
./FlameGraph/flamegraph.pl out.perf.folded > dragent_flame.svg
@luca3m
luca3m / test.cpp
Created August 28, 2015 10:35
C++ Usage of copy/move constructors on argument passing
#include <iostream>
#include <vector>
using namespace std;
class my
{
public:
my()
{
@luca3m
luca3m / octave-3.8.1-yosemite.patch
Created November 8, 2014 17:05
octave-3.8.1-yosemite.patch
--- b/configure.ac 2014-11-08 15:27:56.000000000 +0100
+++ a/configure.ac 2014-11-08 15:29:21.000000000 +0100
@@ -2651,7 +2651,7 @@
if test -n "$JAVA_CPPFLAGS"; then
JAVA_CPPFLAGS="-I${JAVA_CPPFLAGS}"
else
- JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I/System/Library/Frameworks/JavaVM.framework/Home/include -I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"
+ JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin"
fi
JAVA_LIBS="-framework JavaVM"
@luca3m
luca3m / gist:81c1ea252e77083233fb
Last active September 9, 2022 02:21
Boost::asio async_read
// schedule_read is called o start reading
void connection::connect()
{
boost::asio::ip::tcp::resolver resolver(_io);
boost::asio::ip::tcp::resolver::query query(_hostname, std::to_string(_port));
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
boost::system::error_code ec;
boost::asio::connect(_socket, iterator, ec);
if (ec)
@luca3m
luca3m / simple_pool.cpp
Created May 27, 2014 09:24
Simple pool with lambda
simple_pool::ptr_t pool = simple_pool::create();
// Calls block with a valid connection, retrying if something fails
pool->run_with_connection<void>([&](connection::ptr_t conn)
{
conn->run(command("SET")("foo")("bar"));
});
@luca3m
luca3m / lessjs.rb
Created December 15, 2013 20:09 — forked from andyfowler/lessjs.rb
module Jekyll
class LessCssFile < StaticFile
def write(dest)
# do nothing
end
end
# Expects a lessc: key in your _config.yml file with the path to a local less.js/bin/lessc
# Less.js will require node.js to be installed
@luca3m
luca3m / Gemfile
Created October 6, 2013 22:32 — forked from nu7hatch/Gemfile
# ...
gem 'padrino-warden', :git => "git://github.com/zmack/padrino-warden.git"
gem 'authtools'