Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Manuel Prieto prietopa

View GitHub Profile
@prietopa
prietopa / bh1750_relay.py
Created Apr 11, 2020
Switch on light when lumens down from 100lx
View bh1750_relay.py
#!/usr/bin/python
import sys
import time
import smbus
import gpiozero
class BH1750():
""" Implement BH1750 communication. """
@prietopa
prietopa / relay.py
Created Apr 11, 2020
Conect a relay to raspberry pi to control a light
View relay.py
#!/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 Apr 10, 2020
How run BH1750 light sensor with raspberrypi and python
View sensor_bh1750.py
#!/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
#--------------------------------------
# ___ ___ _ ____
# / _ \/ _ \(_) __/__ __ __
# / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/ /_/___/ .__/\_, /
View keybase.md

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:

View DownloadVideoFromInternet
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 Aug 29, 2015
Compare List easy
View ListComparator
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 Aug 29, 2015
CXF persist/audit client Request/Response
View AbstractClientInPersistInterceptor
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 Aug 29, 2015
crea una lista de "schemasList" y de "classesToBeBoundList" para la configuracion de Spring
View gist:688698382a958c83eb20
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 Nov 17, 2014
add proxy(user-pass) to java execution
View addProxy(user-pass)
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 Jun 1, 2013
CRUD con List, implementarlo con Collection<?>
View CrudList.java
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>();
}