Skip to content

Instantly share code, notes, and snippets.

@silgon
silgon / xvfb.md
Created April 2, 2019 13:04
display
@silgon
silgon / print_py.tex
Created May 21, 2018 13:33
create pdf python code with latex
\documentclass{article}
\usepackage{listings}
\input{listings-python.prf} % defines the python-idle-code style
\usepackage{textcomp} % Needed for straight quotes
\lstset{
basicstyle=\normalsize\ttfamily, % size of the fonts for the code
language={Python},style={python-idle-code},
showstringspaces=false,
@silgon
silgon / tor_renew_ip.txt
Created April 12, 2018 14:33
Tor renew ip
sudo vi /etc/tor/torrc
#ControlPort 9051
ControlPort 9051
#CookieAuthentication 1
CookieAuthentication 0
sudo service tor restart
echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
@silgon
silgon / mongo_aggregation_unwind.js
Created March 20, 2018 14:04
mongo aggregation unwind example
db.t4.insert({
"_id" : ObjectId("512e28984815cbfcb21646a7"),
"list" : [
{
"a" : ISODate("2012-12-19T06:01:17.171Z"),
"b" : 5
},
{
"a" : ISODate("2013-12-19T06:01:17.171Z"),
"b" : 5
@silgon
silgon / bluetooth.md
Created March 14, 2018 09:25
Some info about bluetooth with linux
@silgon
silgon / time_check.py
Last active January 10, 2018 10:35
Time check with server and local with http
import time
# from dateutil import parser
import requests
import pandas as pd
url = 'http://google.com'
try:
response = requests.get(url)
except Exception:
@silgon
silgon / client.py
Last active June 25, 2022 03:24
ZeroMQ interprocess communication server/client REP/REQ
import zmq
import sys
context = zmq.Context()
print "Connecting to server..."
socket = context.socket(zmq.REQ)
socket.connect ("ipc://test_hello")
@silgon
silgon / frequency_prediction.py
Last active February 16, 2018 22:56
Frequency Prediction
# code to solve https://stackoverflow.com/q/47932589/2237916
import numpy as np
import tflearn
from random import shuffle
# parameters
n_input=100
n_train=2000
n_test = 500
# generate data
@silgon
silgon / pinger.sh
Created November 15, 2017 16:17
this script is a workaround for cronjob (because my router sometimes fails to interconnect my computers)
#! /bin/bash
# this script is a workaround for cronjob (because my router sometimes fails to interconnect my computers)
ips=( "192.168.0.1" "192.168.0.2" "192.168.0.3" )
for i in "${ips[@]}"; do
:
ping -c1 -W5 $i >/dev/null && echo $i' up' || echo $i' down'
done
@silgon
silgon / wifi_reconnect.sh
Created November 12, 2017 09:59
Reconnect Raspberry Pi wifi when no connection appears
#! /bin/bash
# This code verify that the computer has an ip. When this is not true
# Cron command
# */5 * * * * /my/path/wifi_reconnect
# ip addr show wlan0 |awk -F ":" '/inet addr/{split($2,a," ");print a[1]}'
IP=$(ifconfig wlan0 | awk '$1 == "inet" {print $2}')
if [ -z $IP ]; then
# wait for 10 seconds and ask again for your ip