Skip to content

Instantly share code, notes, and snippets.

View prietopa's full-sized avatar

Jose Manuel Prieto prietopa

View GitHub Profile
@prietopa
prietopa / bh1750_relay.py
Created April 11, 2020 18:34
Switch on light when lumens down from 100lx
#!/usr/bin/python
import sys
import time
import smbus
import gpiozero
class BH1750():
""" Implement BH1750 communication. """
@prietopa
prietopa / relay.py
Created April 11, 2020 17:54
Conect a relay to raspberry pi to control a light
#!/usr/bin/python
# from https://gist.githubusercontent.com/johnwargo/ea5edc8516b24e0658784ae116628277/raw/cb9eb3bcb2121b2a67b51a684a88e5f93a0ef4d0/relay-test.py
# A simple Python application for controlling a relay board from a Raspberry Pi
# The application uses the GPIO Zero library (https://gpiozero.readthedocs.io/en/stable/)
# The relay is connected to one of the Pi's GPIO ports, then is defined as an Output device
# in GPIO Zero: https://gpiozero.readthedocs.io/en/stable/api_output.html#outputdevice
import sys
@prietopa
prietopa / sensor_bh1750.py
Created April 10, 2020 16:37
How run BH1750 light sensor with raspberrypi and python
#!/usr/bin/python
#--------------------------------------
# FROM:
# - https://www.raspberrypi-spy.co.uk/2015/03/bh1750fvi-i2c-digital-light-intensity-sensor/
# - https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/lcd_i2c.py
#--------------------------------------
# ___ ___ _ ____
# / _ \/ _ \(_) __/__ __ __
# / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/ /_/___/ .__/\_, /

Keybase proof

I hereby claim:

  • I am prietopa on github.
  • I am prietopa (https://keybase.io/prietopa) on keybase.
  • I have a public key ASB1XPdgLeNLsLOtwGFZRg4F7x0CM3aH1RIlxoFC3FucBQo

To claim this, I am signing this object:

package es.pp.jm.utils;
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class DownloadVideoFromInternet {
// http://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java
@prietopa
prietopa / ListComparator
Last active August 29, 2015 14:13
Compare List easy
public abstract class ListComparator<B> {
/**
* Only compare elements must not change, like id.
*
* @param left
* @param right
* @return
*/
protected abstract boolean isEqualsBeans(B left, B right);
@prietopa
prietopa / AbstractClientInPersistInterceptor
Last active August 29, 2015 14:12
CXF persist/audit client Request/Response
package net.pp.jm.cxf.interceptor.persist.client;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.interceptor.Fault;
@prietopa
prietopa / gist:688698382a958c83eb20
Last active August 29, 2015 14:10
crea una lista de "schemasList" y de "classesToBeBoundList" para la configuracion de Spring
package net.pp.jm.spring.oxm.config.test;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
public class ListDirectoryTest {
@prietopa
prietopa / addProxy(user-pass)
Created November 17, 2014 16:03
add proxy(user-pass) to java execution
public static void addProxy(String user, String pass, String host, String port) {
if(user!= null && pass != null) {
final String authUser = user;
final String authPassword = pass;
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
@prietopa
prietopa / CrudList.java
Created June 1, 2013 08:52
CRUD con List, implementarlo con Collection<?>
package net.josemanuel.prietopalacios.util;
import java.util.ArrayList;
import java.util.List;
public class CrudList<T> {
public List<T> create(){
return new ArrayList<T>();
}