Skip to content

Instantly share code, notes, and snippets.

View astagi's full-sized avatar
💫

Andrea Stagi astagi

💫
View GitHub Profile
@astagi
astagi / newmath.go
Last active September 14, 2018 21:59
package main
// #cgo pkg-config: python3
// #include <Python.h>
// int PyArg_ParseTuple_LL(PyObject *, long long *, long long *);
import "C"
import (
"fmt"
)
@astagi
astagi / trysum.py
Last active September 14, 2018 21:59
from newmath import sum
print (sum(5,4))
@astagi
astagi / newmath.c
Last active September 17, 2018 09:07
Extending Python with Go - Part 1
#include <Python.h>
static PyObject *sum(PyObject *self, PyObject *args) {
const long a, b;
if (!PyArg_ParseTuple(args, "LL", &a, &b))
return NULL;
return PyLong_FromLong(a + b);
}
static PyMethodDef MathMethods[] = {
@astagi
astagi / README.md
Last active January 7, 2016 09:42
Programming Sphero BB-8

Programming Sphero BB-8

Install dependencies

$ sudo npm install cylon cylon-ble -g
$ npm install sphero noble

Get your BB-8 UUID

$ cylon-ble-scan

@astagi
astagi / appdemo.js
Created August 21, 2015 09:11
Text to speech Angular Service
var app = angular.module('demo', ['textToSpeech']);
app.controller('demoCtrl', function($scope, $timeout, textToSpeech) {
textToSpeech.onVoiceReady(function(){
textToSpeech.speak(
'You worked 9 hours!!',
'UK English Male',
{pitch: 2}
).then(function() {
alert('Finish!');
}, function(err) {
@astagi
astagi / progress.py
Created January 27, 2015 11:58
Show progress in console with Python Add new snippet
import sys
def show_progress(actual, total):
percentage = actual / float(total)
done = int(50 * percentage)
sys.stdout.write("\r[%s%s] %d %%" % ('=' * done, ' ' * (50-done), percentage * 100))
sys.stdout.flush()
@astagi
astagi / fixnslash
Created October 12, 2014 17:52
Hack'n'Slash fix for Mac OSX
chmod +x ~/Library/Application\ Support/Steam/SteamApps/common/HacknSlash/Hack.app/Contents/MacOS/Hack
@astagi
astagi / jenkinsgae.sh
Last active August 29, 2015 14:00
Jenkins build script for GAE + Virtualenv
export GAEPATH=/your/path/for/google_appengine
export PATH=$PATH:$GAEPATH
export PATH=$WORKSPACE/venv/bin:/usr/local/bin:$PATH
export PYENV_HOME=$WORKSPACE/.pyenv/
export PYTHONPATH=$PYTHONPATH:$GAEPATH
if [ -d $PYENV_HOME ]; then
rm -rf $PYENV_HOME
fi
@astagi
astagi / centerresize
Created December 23, 2013 17:16
Resize images 200x200 centered
im.resize({
srcPath: src ,
dstPath: dst,
width: 200,
height: "200^",
customArgs: [
"-gravity", "center",
"-extent", "200x200"
]
}, function(err, stdout, stderr) {
@astagi
astagi / build.sh
Created September 13, 2013 20:47
Just a simple script to build your Pebble app and launch the deploy server
#!/bin/sh
./waf build
python -m SimpleHTTPServer 8000