Skip to content

Instantly share code, notes, and snippets.

View tapionx's full-sized avatar

Riccardo Serafini tapionx

View GitHub Profile
int id;
/* Faccio puntare le aree delle altre CPU all'array dichiarato */
for(id=0;id<NUM_CPU;id++){
if (id == 0){
/* Refer to the Rom Reserved Frame */
pnew_old_areas[id][OLD_SYSBP] = (state_t *)SYSBK_OLDAREA;
pnew_old_areas[id][NEW_SYSBP] = (state_t *)SYSBK_NEWAREA;
pnew_old_areas[id][OLD_TRAP] = (state_t *)PGMTRAP_OLDAREA;
pnew_old_areas[id][NEW_TRAP] = (state_t *)PGMTRAP_NEWAREA;
pnew_old_areas[id][OLD_TLB] = (state_t *)TLB_OLDAREA;
@tapionx
tapionx / router
Created February 25, 2014 15:03
router
#!/bin/bash
if [ "`id -u`" -eq 0 ]; then
if [ "$2" ]; then
INIF=$1
OUTIF=$2
iptables --table nat -I POSTROUTING 1 --out-interface $OUTIF -j MASQUERADE
iptables -I FORWARD 1 --in-interface $INIF -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
else

Keybase proof

I hereby claim:

  • I am tapionx on github.
  • I am tapion (https://keybase.io/tapion) on keybase.
  • I have a public key ASAZh5EpqWHE10BQAwYTidvFsLIiInhVvD1Rv7ukP6SP4wo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am tapionx on github.
  • I am tapion (https://keybase.io/tapion) on keybase.
  • I have a public key ASAZh5EpqWHE10BQAwYTidvFsLIiInhVvD1Rv7ukP6SP4wo

To claim this, I am signing this object:

@tapionx
tapionx / scrape_email_eurodeputies.py
Last active July 5, 2018 08:57
scrape email addresses for all the italian euro-deputies (https://changecopyright.org/it)
# requirements: pip install requests-html
import json
from requests_html import HTMLSession
import requests
desired_country_code = 'IT'
session = HTMLSession()
@tapionx
tapionx / purge_docker.sh
Created July 17, 2018 09:54
clean all Docker things
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q); docker volume rm $(docker volume ls -q)
@tapionx
tapionx / vpn.conf
Last active October 8, 2019 07:16
wireguard server ansible playbook (debian 10)
[Interface]
Address = 10.8.0.1/24
PrivateKey = XXXXXXXXXX
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 51821
[Peer]
PublicKey = XXXXXXXXXX
AllowedIPs = 10.8.0.2/24
@tapionx
tapionx / 1.py
Created December 1, 2019 16:08
Advent of Code 2019 #1 solution
with open('1_input.txt', 'r') as f:
input_data = f.readlines()
def fuel_requirement(mass):
fuel_needed = (mass / 3) - 2
while fuel_needed > 0:
fuel_needed += (fuel_needed / 3) - 2
print(fuel_requirement(14))
print(fuel_requirement(1969))
print(fuel_requirement(100756))
fuel_sum = 0
@tapionx
tapionx / 2.py
Created December 1, 2019 16:09
Advent of Code 2019 #2 solution
with open('1_input.txt', 'r') as f:
input_data = f.readlines()
def fuel_requirement(mass):
fuel_needed = (mass / 3) - 2
if fuel_needed > 0:
return fuel_needed + fuel_requirement(fuel_needed)
else:
return 0
print(fuel_requirement(14))
print(fuel_requirement(1969))
@tapionx
tapionx / advent_of_code_3.py
Created December 2, 2019 10:51
Advent of Code 2019 #3
with open('2_input.txt', 'r') as f:
input_program = [int(x) for x in f.read().strip().split(',')]
input_program[1] = 12
input_program[2] = 2
def execute_intcode(input_program):
program_counter = 0
while program_counter < len(input_program) and input_program[program_counter] != 99:
#print(program_counter, input_program[program_counter])
opcode = input_program[program_counter]
input1_address = input_program[program_counter + 1]