Skip to content

Instantly share code, notes, and snippets.

@grizmio
grizmio / gist:bc752dd070652f21266b
Created November 17, 2015 19:53
Patch to make Adafruit's ADC python libraries works with ubuntu xenial, kernel 4
diff --git a/source/c_adc.c b/source/c_adc.c
index e0c754c..5269407 100644
--- a/source/c_adc.c
+++ b/source/c_adc.c
@@ -30,29 +30,28 @@ SOFTWARE.
#include "c_adc.h"
#include "common.h"
-char adc_prefix_dir[40];
+char adc_prefix_dir[49];

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@grizmio
grizmio / gist:597471ac23cd033aec610ab5a2eda1fe
Last active August 9, 2017 17:47
Easily remove a line from ~/.ssh/known_hosts on a MAC
http://blog.grizmio.cl/post/157828022813/easy-fast-bash-removeline
On a MAC sed needs -i '' on a Linux box it won´'t.
This is the most annoying message you could read in a ssh hurry:
baz:foo grizmio$ ssh root@192.168.1.2
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
@grizmio
grizmio / miyagi.py
Created October 24, 2017 02:05
a function for python2.7 agi using pyst2, it dials an extension with pjsip and get the result status. Useful in a simple ivr
#!/bin/python2.7
# python2.7 agi using pyst2
# A function to dial an extension with pjsip and get the result status
from asterisk.agi import * # pyst2
def dial_pjsip(anexo=''):
"""
@grizmio
grizmio / JavaApplication4.java
Created June 26, 2018 17:46
Java: Tuple, Greatest Common Divisor and least Common Multiples exercises
package javaapplication4;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author grizmio
*/
public class JavaApplication4 {
@grizmio
grizmio / ESP8266WiFiAP.cpp and ESP8266WiFiAP.h
Last active June 28, 2018 20:37
Incomplete ugly hack to allow ESP8266 to not send gateway in the dhcp. Doesn't allow to send arbitrary gateways
Serial.println(
WiFi.softAPConfig(ip, gateway, subnet, nullptr) ? "Ready" : "Failed!"); // se llamo desde alguna libreria
Serial.println(
WiFi.softAPConfig(ip, gateway, subnet, INADDR_NONE) ? "Ready" : "Failed!"); // no se enviara el gateway
IPAddress dhcp_gateway(1, 2, 3, 4); // o cualquier otra ip
Serial.println(
WiFi.softAPConfig(ip, gateway, subnet, dhcp_gateway) ? "Ready" : "Failed!"); // se enviara la ip del esp8266 como gateway
@grizmio
grizmio / esp32_temperatura_humedad.ino
Created September 14, 2018 15:23
ESP32: Subir datos a thinger.io usando mejor ssid
#include <DHTesp.h>
#include <WiFiClientSecure.h>
#include <ThingerESP32.h>
#define TO_SECONDS 1000 * 1000
#define USERNAME "usuario"
#define DEVICE_ID "dispositivo"
#define DEVICE_CREDENTIAL "contrasenia"
#define DEEPSLEEP_SECONDS 30
#define SENSOR_PIN 19
@grizmio
grizmio / gist:ed689558a1fa8fd879d8e70c69da4c2f
Created April 13, 2020 16:59
Example to wait for postgres container before start another container using docker-compose.yml
# Credits to: https://github.com/peter-evans
# Extracted from: https://github.com/peter-evans/docker-compose-healthcheck/blob/master/docker-compose.yml
# TL;DR;
version: "2.2"
services:
foo:
image: an_image:tag
networks:
@grizmio
grizmio / foo.py
Created July 21, 2020 03:01
pg8000 cursor results as dictionary
import pg8000
# thanks to: Sucas Venior https://stackoverflow.com/questions/58658690/retrieve-query-results-as-dict-in-sqlalchemy
def rows_as_dicts(cursor):
"""convert tuple result to dict with cursor"""
col_names = [i[0].decode() for i in cursor.description]
for row in cursor:
x = dict(zip(col_names, row))
yield x
@grizmio
grizmio / gist:5f4b330ea30599a3327f1bea29d0cb02
Created September 22, 2020 17:21
Symfony, Webencore, yarn, /public/build to just /public
'cause Amnesia.
webpack.config.js:
.setOutputPath('public/')
// public path used by the web server to access the output path
.setPublicPath('/')
assets.yaml:
json_manifest_path: '%kernel.project_dir%/public/manifest.json'