Skip to content

Instantly share code, notes, and snippets.

🌊

Alexandre Moreno moleike

🌊
Block or report user

Report or block moleike

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moleike
moleike / rethrow.cc
Last active Aug 29, 2015
Convert a C++ exception into a Java exception
View rethrow.cc
void rethrow_cpp_exception_as_java_exception()
{
try
{
throw;
}
catch (const package::Exception& e)
{
jclass jc = env->FindClass("group/package/Exception");
if(jc) env->ThrowNew (jc, e.what());
@moleike
moleike / heap-lambda.cc
Last active Aug 29, 2015
Lambda in a C callback
View heap-lambda.cc
#include <functional>
#include <iostream>
// using a lambda in a C callback
extern "C" void
register_callback (void (*callback)(void *), void * context)
{
// for simplicity we just call it
callback (context);
View later.cc
// credit to http://stackoverflow.com/a/14665230/339222
#include <functional>
#include <chrono>
#include <future>
#include <iostream>
class later
{
public:
View browser.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gtk
import webkit
def entry_activated_cb(entry, embed):
embed.load_uri(entry.get_text())
# Widgets and signals
View carousel.qml
@moleike
moleike / NavigationDrawer.qml
Last active Aug 29, 2015 — forked from jbache/NavigationDrawer.qml
Qt Quick Navigation Drawer
View NavigationDrawer.qml
/*
Copyright (c) 2014 Cutehacks A/S
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@moleike
moleike / server.js
Last active Sep 12, 2015 — forked from mixonic/server.js
Node.js + Socket.io + Bash. A collaborative terminal for your browser.
View server.js
//
// This server will start a bash shell and expose it
// over socket.io to a browser. See ./term.html for the
// client side.
//
// You should probably:
//
// npm install socket.io
// curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js
//
@moleike
moleike / list.cc
Last active Sep 15, 2015
Linked list using polymorphic lambdas
View list.cc
// http://lists.boost.org/Archives/boost/2014/06/214213.php
// http://stackoverflow.com/questions/25338795/is-there-a-name-for-this-tuple-creation-idiom
#include <iostream>
#include <string>
#include <functional>
auto list = [](auto ...xs) {
return [=](auto access) { return access(xs...); };
};
@moleike
moleike / tags.cc
Created Nov 19, 2015
tag dispatching based on type traits
View tags.cc
#include <iostream>
struct fast_speed_tag {};
struct slow_speed_tag {};
template <typename T>
struct traits { // default
typedef slow_speed_tag speed;
};
@moleike
moleike / restful.js
Created Mar 29, 2016 — forked from BinaryMuse/restful.js
Express API with Async/Await
View restful.js
import express from "express";
/**
* Takes a route handling function and returns a function
* that wraps it after first checking that the strings in
* `reserved` are not part of `req.body`. Used for ensuring
* create and update requests do not overwrite server-generated
* values.
*/
function checkReservedParams(routeHandler, ...reserved) {
You can’t perform that action at this time.