Skip to content

Instantly share code, notes, and snippets.

#require "plc_engine/daemons/plc_reading_engine"
#require "plc_engine/daemons/plc_writing_engine"
require 'colorize'
require 'rmodbus'
ip="10.0.0.2"
sl1 = ModBus::TCPClient.new(ip).with_slave(1)
sl2 = ModBus::TCPClient.new(ip).with_slave(1)
Thread.new do
require 'colorize'
require 'rmodbus'
require 'timers'
ip="10.0.0.2"
sl1 = ModBus::TCPClient.new(ip).with_slave(1)
timers = Timers::Group.new
now_and_every_five_seconds = timers.now_and_every(0.001) {
begin
sl1.holding_registers[0..1000]; puts "read #{Time.now.to_i}".green
rescue Exception =>e
pg_dump --host localhost --username "postgres" --format custom --no-privileges --file "/tmp/scada_bys_o239_14_11_2017.backup" "scada_bys" -W
pg_dump --host localhost --username "postgres" --format custom --no-privileges --file "/tmp/scada_bys_o239_14_11_2017.backup" "scada_bys" -W
@cpfarher
cpfarher / gist:cf8e84a447960ee346a3d6351c0225fa
Created December 13, 2017 18:33
Conexión a puerto serial con ruby serialport gem y simulación de puerto en linux
===================== Documentación ================================
Gema serialport: http://www.rubydoc.info/gems/serialport/SerialPort
IO: http://www.rubydoc.info/stdlib/core/IO
===================== Documentación ================================
1- Simulación puerto serial en linux:
sudo apt-get install socat
#en una consola:
socat -d -d pty,raw,mode=777 pty,raw,mode=777
2017/12/13 14:19:54 socat[3641] N PTY is /dev/pts/**21**
2017/12/13 14:19:54 socat[3641] N PTY is /dev/pts/**22**
@cpfarher
cpfarher / Create_a_hotspot.md
Created September 14, 2017 20:28 — forked from vfdev-5/Create_a_hotspot.md
Raspberry Pi - Ubuntu 16.04 Mate - Wifi automatic connection and static IP in terminal
sudo nmcli dev wifi hotspot ifname wlan0 con-name "my-hotspot" ssid "my-hotspot" password "My HotsPoT Strong Password"

More info here

@cpfarher
cpfarher / deployment-tool-ansible-puppet-chef-salt.md
Created August 23, 2017 12:17 — forked from jaceklaskowski/deployment-tool-ansible-puppet-chef-salt.md
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

@cpfarher
cpfarher / 01-Notas.md
Last active August 29, 2015 14:25 — forked from mariochavez/01-Notas.md
Usando Docker con Rails

Usando Docker con Rails para hacer deploy a Producción

Instalar Docker

Hay que seguir las notas en https://docs.docker.com/installation/ para el sistema operativo que esten ejecutando.

Utilizando un contenedor para Postgresql

Vamos a utilizar un container ya listo para trabajar con Postgresql. El siguiente comando se encarga de descargar el container y de ejecutarlo. Si es necesario cambiar el valor de las variables POSTGRES_PASSWORD y POSTGRES_USER a unos más adecuados

$ docker run --name db -e POSTGRES_PASSWORD=manager -e POSTGRES_USER=rails -d postgres
require 'timers'
timers_scan = Timers::Group.new
scan=[3.0]
scan_started=[]
sleep_time=4.0
last_time=Time.now.to_f
loop {
@cpfarher
cpfarher / designer.html
Last active August 29, 2015 14:11
designer
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-ripple/paper-ripple.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../core-menu-button/core-menu-button.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">