Skip to content

Instantly share code, notes, and snippets.

@1328
1328 / x.py
Last active February 5, 2019 16:15
notes.py
from collections import defaultdict
import csv
csv.field_size_limit(999999999)
def get_csv(filename):
# get data from csv
# don't use built ins, like input, as variable names
with open('filename', 'r') as file_handle:
reader = csv.reader(file_handle, delimiter='|')
@1328
1328 / disco.py
Created May 14, 2018 12:05
Mock up for disco adventure
class Message():
'''mockup for discord message'''
def __init__(self, user, incoming):
self.user = user
self.incoming = incoming
def send_message(self, what):
print('{}: {}'.format(self.user, what))
@1328
1328 / weap.py
Created April 12, 2018 15:02
weapon grabber
import requests
from bs4 import BeautifulSoup
import sqlite3
import sys
import time
GROUPS = {
'Grenade':(52,55),
'Other':(55,56),
@1328
1328 / parse_keybag.py
Last active February 5, 2020 13:12 — forked from geekman/parse_keybag.py
extract & parse the BackupKeyBag from an iTunes Backup
from __future__ import print_function
# updated to work with py3 using only standard lib modules
# unsure if it will work with py2 still...
import plistlib
import struct
import sys
from binascii import hexlify
@1328
1328 / x.py
Created August 8, 2016 15:23
RSP
from __future__ import print_function
from builtins import input
#!/bin/py
#Python 2.7.6
"""A text-based Python 2.7.6 implementation of the game Rock-Paper-Scissors.
Game play:
* each round, both players select from: rock, paper, or scissors
* rock beats scissors, scissors beats paper, paper beats rock
@1328
1328 / dll.py
Created April 12, 2016 17:18
doublelinkedlist
class Node(object):
"""The class the handles the Node objects"""
def __init__(self, data=None, prev=None, next=None):
self.data = data
self.prev = prev
self.next = next
def __str__(self):
return "Node[Data = %s]" % (self.data,)
@1328
1328 / cars.py
Created April 11, 2016 17:08
cars
import numpy as np
from itertools import product
from random import shuffle,random
def blank_road(**args):
lanes, cells = args['lanes'], args['cells']
return np.zeros((lanes, cells))
@1328
1328 / x.py
Created February 3, 2016 15:15
mockup v2
import time
# initialize an events dictionary that will later be populated with different
# functions to be called as events are identified by poll
global EVENTS
def poll(state):
@1328
1328 / x.py
Created February 1, 2016 16:38
mockup of command controller
import time
# create a dictionary
state = {
'start': time.time(),
'countdown': 5,
'clock': 5,
'ok': True,
'boosters': 'off',
@1328
1328 / x.py
Created January 15, 2016 22:11
comm
#!/usr/bin/env python
"""
merge a config change and commit it.
Requires config.cfg with your config snippet inside at root directory.
"""
from napalm import get_network_driver
from jnpr.junos.exception import ConnectAuthError
from iptools import ipv4
import os