Skip to content

Instantly share code, notes, and snippets.

View lattice0's full-sized avatar
🦀

Lattice 0 lattice0

🦀
View GitHub Profile
@lattice0
lattice0 / primes.py
Created June 19, 2014 02:40
Sieve of Eratosthenes - Python Implementation
#PRIMES - 08/06/2013 - LAST EDIT: 09/09/2013
#lucaszanella.com - Primes v1.1
#this is a fast implementation, just for fun. Not the best implementation, but...
#methods:
#var = primes.create()
#--var.generate(max) - generate primes up to 'max' (return: list)
#--var.count(start, end) - count number of primes from 'start' to 'end' (return: int)
@lattice0
lattice0 / tcpforward.sh
Created November 10, 2016 22:54
TCP tunnel for bot development, forwards TLS connections on port 443 to my home at port 8443, uses tlstunnel
/home/lucas/tcptunnel/tcptunnel --local-port=443 --remote-port=8443 --remote-host=mac.lucaszanella.com --stay-alive
@lattice0
lattice0 / docker+nginx+php
Created January 26, 2017 07:03
docker compose for nginx and php
//Experimental nginx and php docker composer
docker-compose.yml:
web:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
@lattice0
lattice0 / python3-serial-echo
Created March 5, 2017 11:50
Echoes what is received in serial
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while 1:
serial_line = ser.readline()
print(str(serial_line).replace('\n', ''))
ser.close()
@lattice0
lattice0 / join_pdf_scanned
Created May 21, 2017 03:43
Script that joins photos from scanned book that gets 2 pages scanned at the same time
import os
def pick2(n):
pages.append(a[n])
pages.append(b[n])
def concatenate_list_data(list):
result= ''
for element in list:
@lattice0
lattice0 / gist:690a0ef2119bbdee65ab47083cc20d0c
Created July 20, 2017 18:11
SSH with socks and port fowarding
ssh -p 2324 -i privatekey -L 8080:192.168.1.1:80 -C -q -D 1234 user@host
@lattice0
lattice0 / gist:806c09c3e15c457048ebb59d27d40edb
Last active November 10, 2017 03:17
verify sha from usb iso image
https://unix.stackexchange.com/a/244379
dd if=/dev/sdb bs=4096 count=$(($(stat -c '%s' the.iso) / 4096)) | sha256sum
@lattice0
lattice0 / nginxdocker.sh
Created November 30, 2017 00:07
docker nginx host downloads folder
docker run --name nginx --rm -p 8080:80 -v /home/lz/Downloads:/usr/share/nginx/html:ro -d nginx
@lattice0
lattice0 / nginx_docker_file_hoster.sh
Last active January 10, 2018 03:53
Nginx temporary file host
#Work in progress... Didnt finish this script yet
#With sudo:
sudo docker run --name nginx --rm -p 8080:80 -v /home/lz/Downloads:/usr/share/nginx/html:ro -d --entrypoint sed nginx '/location \/ {/a autoindex on;' /etc/nginx/conf.d/default.conf && sudo docker exec -ti nginx "nginx -g daemon off"
sudo docker run --name nginx --rm -p 8080:80 -v /home/lz/Downloads:/usr/share/nginx/html:ro -ti -d --entrypoint sed nginx '/location \/ {/a autoindex on;' /etc/nginx/conf.d/default.conf && sudo docker exec -ti nginx "nginx -g daemon off"
#Without sudo:
@lattice0
lattice0 / gist:2fd284e418562ab1fd6d8fd3574246f5
Created January 22, 2018 01:55
Linux fixes in my computer
Fixes mouse problem in new VMs on virt-manager
sudo virt-xml $vmname --add-device --input tablet