This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import web | |
web.config.debug = False | |
from web import database | |
BASEPATH = "/home/user/Scans" | |
DIR = "/var/lib/pybssort/" | |
DB_NAME = os.path.join(DIR, "pybssort.db") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#NAT script from !!!!!!!!!!!!!!!, modified by CRImier | |
# Exit status 0 if operation is correct | |
# Exit status 1 if trying to use last interface used when running for the first time | |
# Exit status 2 if interface doesn't exist | |
EIF='' | |
IIF='eth0' | |
PATH=/usr/sbin:/sbin:/bin:/usr/bin | |
LOGFILE=/etc/nat-if.conf | |
touch $LOGFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
directory_name = "playlist/" | |
playlist_name = "playlist.m3u" | |
f = open(playlist_name, "r") | |
files = [] | |
for line in f: | |
line = line.strip().strip("\n").strip("\r") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
class LCDI2C4Bit { | |
public: | |
LCDI2C4Bit(int devI2CAddress, int num_lines, int lcdwidth); | |
void commandWrite(int command); | |
void init(); | |
void print(int value); | |
void printIn(char value[]); | |
void clear(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
f = open("statement.csv", "r", encoding="iso8859_13") | |
#def reencode(file): | |
# for line in file: | |
# yield line.decode('iso8859_13').encode('utf-8') | |
r = csv.reader(f, delimiter=";", quotechar='"') | |
l = [line for line in r] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code is available on 192.168.88. :8000 (you can download it using your web browser) | |
# All examples are written to work on Python 3 | |
######################################################### | |
# Basic syntax, "while" and "if" | |
######################################################### | |
# REPL works well as a simple calculator | |
2+2*2 | |
# Answer: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This code works with both 24c02 and 24c16 (though you'll want to also iterate through addresses for using a 24c16 fully):""" | |
from smbus import SMBus | |
from math import ceil | |
def write_to_eeprom(bus, address, data, bs=16): | |
""" | |
Writes to an EEPROM. Only supports starting from 0x00, for now. | |
(to add other start addresses, you'll want to improve the block splitting mechanism) | |
Will raise an IOError with e.errno=121 if the EEPROM is write-protected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hexdump(data=None, col_width=16): | |
#This function follows the i2cdump output format, as it's the most readable out there | |
if data is None: data = d | |
# character conversion function | |
conv = lambda x: chr(x) if x in range(0x20, 0x7f) else '.' | |
# getting row count | |
row_count = ceil(len(data)/col_width) | |
max_row_num_len_hex = len(hex(row_count)[2:]) | |
# first line - header | |
hex_digits = [hex(i)[2:] for i in range(16)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#try this one !/usr/bin/sudo /usr/bin/python3 | |
from evdev import InputDevice, list_devices, categorize, ecodes | |
from time import sleep | |
import threading | |
def listen_for_events(dev): | |
for event in dev.read_loop(): | |
if event.type != ecodes.SYN_REPORT: # an attempt to filter out syn reports to work around a specific screwy touchpad | |
print (dev.name, ": ", str(categorize(event))) |
OlderNewer