Skip to content

Instantly share code, notes, and snippets.

View JSeam2's full-sized avatar

Jseam JSeam2

View GitHub Profile
@JSeam2
JSeam2 / crop.py
Created March 19, 2019 15:09
Simple script to crop all files in the current folder
import PIL
from PIL import Image
import os
for x in os.listdir("./"):
try:
img = Image.open(x)
w, h = img.size
new_img = img.crop((100, 100, w-200, h-30))
new_img.save(x)
@JSeam2
JSeam2 / Arduino code
Created December 29, 2018 12:00
simple_demo.ino
/*
* Simple demonstration
* 1) Increase resistance of potentiometer.
* 2) Buzzer increase in loudness
* 3) When we reach max loudness led turns on
*/
// Pins used
const int led = 12;
@JSeam2
JSeam2 / adj_matrix.py
Last active December 24, 2018 04:08
Generate adjacency matrix given edge rule, edge rule = {{v_i, v_j} | i - j === 1 or -1 or 2 or -2 (mod 9)}
"""
gen adjacency matrix
edge rule = {{v_i, v_j} | i - j === 1 or -1 or 2 or -2 (mod 9)}
Format
1 2 3 4 ...
1
2
3
@JSeam2
JSeam2 / server.c
Created December 6, 2018 16:56
Simple C server
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
@JSeam2
JSeam2 / Firebase.py
Created June 23, 2018 19:45
Simple firebase script in python3 for REST interface. Intended for testing purposes, no private key is used.
"""
Simple firebase script without authentication
Only use for debugging or testing purposes
"""
import json
from urllib.request import Request, urlopen, build_opener, HTTPHandler
from urllib.error import URLError, HTTPError
class Firebase():
@JSeam2
JSeam2 / workbookcrack.vb
Created June 6, 2018 02:47
Crack Protected Excel Workbooks
Sub PasswordBreaker()
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
@JSeam2
JSeam2 / calculator_grammar.py
Created March 20, 2018 14:27
Generate Inputs to a calculator according to a specified grammar
import random
# As the grammar doesn't handle divide by 0, such functions cannot be evaluated
# properly
def calculator(input_string):
"""
Input a string with valid grammer to calculate result
We will use the following grammar
@JSeam2
JSeam2 / prob_test.py
Created February 9, 2018 17:59
Using an unbiased 6 sided die What is the probability that you will roll a 4 at least once if you roll six times?
import random
"""
Using an unbiased 6 sided die
What is the probability that you will roll a 4 at
least once if you roll six times?
P(At Least a 4) = P(Total) - P(Not a 4)^6
P(At Least a 4) = 1 - (5/6)^6
@JSeam2
JSeam2 / complex.c
Created February 8, 2018 15:24
Adding Complex Numbers in C
/*
* =====================================================================================
*
* Filename: complex.c
*
* Description: Implementation of program that supports accepting two complex numbers from the user; adding, subtracting, multiplying, and dividing them; reporting each result to the user
*
* Version: 1.0
* Created: 02/08/2018 10:12:01 PM
* Revision: none
@JSeam2
JSeam2 / pdf_edit.py
Created February 1, 2018 18:00
Add file name to the bottom of pdf page using python
"""
Add file name to the bottom of pdf page using python
"""
from PyPDF2 import PdfFileWriter, PdfFileReader
import io
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
import os
import sys