Skip to content

Instantly share code, notes, and snippets.

View guglielmino's full-sized avatar

Fabrizio Guglielmino guglielmino

View GitHub Profile
@guglielmino
guglielmino / gist:60cfb8ef4cf47ec9a629
Created January 24, 2015 15:39
Sample code for Pushetta
import urllib2
import json
def sendNotification(token, channel, message):
data = {
"body" : message,
"message_type" : "text/plain"
}
req = urllib2.Request('http://api.pushetta.com/api/pushes/{0}/'.format(channel))
from pushetta import Pushetta
API_KEY="00112233445566778899aabbccddeeff00112233"
p=Pushetta(API_KEY)
p.pushMessage("raspi", "Hello World"")
@guglielmino
guglielmino / PushettaEthernetShield
Last active August 29, 2015 14:14
A sample to use Pushetta API from Arduino with Ethernet shield
#include <SPI.h>
#include <Ethernet.h>
/////////////////
// MODIFY HERE //
/////////////////
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 }; // Be sure this address is unique in your network
char APIKEY[] = "ffaabb444f1177772222f7243534badaanaa1100"; // Put here your API key
char CHANNEL[] = "my channel"; // and here your channel name
boolean DEBUG = true;
#!/usr/bin/python
# -*- coding: utf-8 -*-
from smbus import SMBus
from pushetta import Pushetta
import math
import time
import cv2
def DetectFace(img, face_cascade, callback):
image = None
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x, y, w, h) in faces:
@guglielmino
guglielmino / PostOnFb
Created June 26, 2015 08:23
Post on Facebook
postOnWall: function(message, name, description, link, picture, caption, onlyOne, cookieName) {
//vedo se ho il cookie settato
var alreadyPosted = "";
alreadyPosted = leggiCookie(cookieName); // jshint ignore:line
if (alreadyPosted !== "true") {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var userId = response.authResponse.userID;
var access_token = response.authResponse.accessToken;
//vedo se ho il permesso di pubblicazione
in_thread do
use_synth :fm
sleep 2
loop do
28.times do
sample :drum_bass_hard, amp: 0.8
sleep 0.25
play :e2, release: 0.2
sample :elec_cymbal, rate: 12, amp: 0.6
sleep 0.25
@guglielmino
guglielmino / quiz.cs
Created January 2, 2017 17:36
devquiz
public class NewClass {
private string _property { get; set; }
public NewClass(string s){
this._property = s;
}
public static implicit operator NewClass(string s){
return new NewClass(s);
}
#include "mgos.h"
void int_func(int pin, void *arg) {
(void) arg;
LOG(LL_DEBUG, ("Pin pressed %d", pin));
}
enum mgos_app_init_result mgos_app_init(void) {
mgos_gpio_init();
mgos_gpio_set_mode(0, MGOS_GPIO_MODE_INPUT);
void int_func()
{
Serial.write("Button pressed");
}
void setup() {
Serial.begin(115200);
pinMode(0, INPUT_PULLUP);
attachInterrupt(0, int_func, FALLING);