Skip to content

Instantly share code, notes, and snippets.

View devedetti's full-sized avatar
🐍

Ignacio Benedetti devedetti

🐍
  • Argentina
  • 22:28 (UTC -03:00)
View GitHub Profile
#!/bin/sh
CURRENT_IP=/tmp/current_ip
ASSIGNED_IP=/tmp/assigned_ip
test -e $ASSIGNED_IP || touch $ASSIGNED_IP
curl http://ip.init.gdn:8989/txt -s -o $CURRENT_IP
cmp $CURRENT_IP $ASSIGNED_IP -s || (curl https://freedns.afraid.org/dynamic/update.php?__HASH_HERE__ && cp $CURRENT_IP $ASSIGNED_IP && echo "IP updated $(cat $CURRENT_IP)")
package main
import (
// "encoding/json"
"context"
"fmt"
"net/http"
"os"
"os/signal"
"strconv"
package main
import (
// "encoding/json"
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
$ cat .local/share/xorg/Xorg.0.log
[ 41.701]
X.Org X Server 1.19.3
Release Date: 2017-03-15
[ 41.701] X Protocol Version 11, Revision 0
[ 41.701] Build Operating System: Linux 4.9.11-1-ARCH x86_64
[ 41.702] Current Operating System: Linux sache 4.11.7-1-ARCH #1 SMP PREEMPT Sat Jun 24 09:07:09 CEST 2017 x86_64
[ 41.702] Kernel command line: initrd=\initramfs-linux.img cryptdevice=/dev/sda4:disco root=/dev/mapper/disco rw
[ 41.702] Build Date: 07 April 2017 05:42:48PM
[ 41.702]
func download_file(destination string, url string) error {
fmt.Println("%s -> %s\n", url, destination)
res, err := http.Get(url)
if err != nil {
log.Println(err)
return errors.New("Can't fetch data from URL")
}
defer res.Body.Close()
@devedetti
devedetti / gist:8a33ca44a3d57df4fa634d8008156474
Created January 13, 2017 01:59
Traffic Shaping on EdgeMax
set traffic-policy shaper WorldIn description "Download"
set traffic-policy shaper WorldIn bandwidth 9600kbit
set traffic-policy shaper WorldIn class 10 description "interactive"
set traffic-policy shaper WorldIn class 10 bandwidth 20%
set traffic-policy shaper WorldIn class 10 ceiling 100%
set traffic-policy shaper WorldIn class 10 match dns ip destination port 53
set traffic-policy shaper WorldIn class 10 match ssh ip destination port 22
set traffic-policy shaper WorldIn class 10 match icmp
@devedetti
devedetti / pila.py
Last active September 27, 2016 14:01
coso loco
class Pila(object):
def __init__(self):
self._valores = []
self._maximos = []
def push(self, x):
self._valores.append(x)
ultimo_maximo = self._maximos.pop()
if x >= ultimo_maximo:
@devedetti
devedetti / test_obd.py
Last active July 23, 2016 04:02
An OBD 16x2 Display
import curses
from time import sleep
from random import randint
myscreen = curses.initscr()
MAX_RPM = 6500
EMPTY = chr(9617)
FULL = chr(9619)
SPEED = ((0, 0), (1,20), (21,40), (35, 60), (50, 90), (60, 145))
@devedetti
devedetti / load.py
Created November 18, 2015 21:53
pa los pibes
from random import randint
import time
from django.db import transaction
from mobile.models import Mobile, Phone, Handy, Tablet, MobileNetwork
from asset.models import Asset
ROWS = 1000
@transaction.atomic
var Route = function(data) {
this.id = data.id;
this.waypoints = data.waypoints;
this._L_LatLng_list;
this._L_Polyline_obj;
};
Route.prototype._fill_L_LatLng = function() {