Skip to content

Instantly share code, notes, and snippets.

/* $ g++ -Wall -std=c++0x pyt.cpp */
#include <iostream>
struct triple {
int x, y, z;
};
class pyt {
public:
$ uname -a
Linux computer 2.6.32-431.5.1.el6.i686 #1 SMP Wed Feb 12 09:07:48 CET 2014 i686 i686 i386 GNU/Linux
$ python
Python 2.6.6 (r266:84292, Jan 23 2014, 10:37:44)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python pyseektest.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Alejandro Santos, @alejolp.
"""
This program deadlocks beacuse producers are also consumers and the Queue
has a fixed limit. When the consumer reaches a specific level on the expansion
tree, deadlocks.
"""
package test2;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPAdministrator;
import com.espertech.esper.client.EPRuntime;
#include <openssl/bio.h>
#include <openssl/evp.h>
void base64calc(const unsigned char* msg, size_t msgsize, char* out, size_t outsize) {
BIO *bio, *b64, *mem;
// Shit, this base64 thing with openssl was hard to get right.
b64 = BIO_new(BIO_f_base64());
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Ref: http://listas.python.org.ar/pipermail/pyar/2014-January/027667.html
Sea f una función continua en [a, b], tal que f presenta un único
máximo en [a, b]. Por ejemplo f puede ser una parábola con los cuernos
hacia abajo, y f no puede ser de la forma de los cuernos de Sauron
@alejolp
alejolp / gist:6325894
Created August 24, 2013 03:31
portaudio issue
#include <iostream>
#include <cmath>
#include <portaudio.h>
#define SAMPLE_RATE 22050
int input_channels = 2; /* <<< THIS VALUE TO ZERO WORKS!! */
@alejolp
alejolp / gist:6254971
Last active December 21, 2015 05:09
Arduino SWR Meter
/*
* Arduino SWR Meter
* Por Alejandro Santos LU4EXT ([email protected])
*
* Conectar en Analog0 la salida de potencia directa, y en Analog1 la salida de reflejada.
* Creado para usarlo junto a un puente de ROE, por ejemplo el de XQ2FOD.
* http://ludens.cl/Electron/swr/swr.html
*/
#include <LiquidCrystal.h>
@alejolp
alejolp / soundmodem.sh
Created November 9, 2012 04:45
/etc/init.d/soundmodem
#! /bin/sh
#
# soundmodem Start Soundmodem driver.
#
# Author: Thomas Sailer, <[email protected]>
#
### BEGIN INIT INFO
# Provides: soundmodem
# Required-Start: $remote_fs $syslog $named $network $time
>>> def f():
... for x in xrange(10):
... print "Mi thread id: ", thread.get_ident()
... sys.stdout.flush()
... time.sleep(0.1)
...
>>>
>>>
>>> tt = [thread.start_new_thread(f, tuple()) for y in xrange(10)]
Mi thread id: >>> 139873167742720