Skip to content

Instantly share code, notes, and snippets.

View blockarchitech's full-sized avatar

blockarchitech blockarchitech

View GitHub Profile
@blockarchitech
blockarchitech / csvtojson.js
Created January 31, 2024 20:12
Walmart CSV to JSON converter for node
// walmart csv to json converter
const fs = require('fs');
const csv_to_json = (csv_file) => {
// get headers
let headers = [];
let data = [];
let lines = csv_file.split('\n');
headers = lines[0].split(',');
@blockarchitech
blockarchitech / auth.js
Created December 28, 2023 18:32
Express discord auth
//
// auth
//
const fetch = require('node-fetch');
const jwt = require('jsonwebtoken');
const { v4: uuidv4 } = require('uuid');
const URLSearchParams = require('url').URLSearchParams;
require('dotenv').config();
const {
@blockarchitech
blockarchitech / index.js
Created July 30, 2023 21:48
discord oauth
//
const express = require("express");
const session = require("express-session");
const fetch = require("node-fetch");
class AuthObject extends Object {
constructor(req, res) {
this.req = req;
this.session = res.session;
@blockarchitech
blockarchitech / GitHub.js
Created May 21, 2023 00:39
web OAuth Provider Examples
if (req.session.provider === "github") {
// get user info from github
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.github.com/user");
xhr.setRequestHeader("Authorization", "token " + req.session.accessToken);
xhr.setRequestHeader("Accept", "application/json");
xhr.addEventListener("load", function () {
// The response will contain the user's profile information.
var response = JSON.parse(this.responseText);
// Send the user's profile information to the browser.

Sure, here is a poem about the Rebble Hackathon:

The Rebble Hackathon

A weekend of coding and fun, For all those who love the Pebble watch. Come and join us, and build something new, That will make the Pebble community proud.

We have developers of all skill levels,

@blockarchitech
blockarchitech / explanation.md
Last active May 5, 2023 17:30
svg2pdc Trace

svg2pdc new edition trace

Using python's trace module, and running the following:

$ python3 -m trace --trace original_svg2pdc.py meowmeow.svg > trace.txt

The following output was generated. What I don't understand is that it just stops, and doesn't write any files.

@blockarchitech
blockarchitech / main.py
Created February 19, 2023 20:54
Find .jpg files in a text file
# find .jpg files in a text file
import re
with open('output.txt', 'r') as f:
page = f.read()
regex = re.compile(r'[\w-]+\.jpg')
with open('output2.txt', 'w') as f:
for match in regex.findall(page):
print(match)
f.write(match + '\n')
@blockarchitech
blockarchitech / main.py
Created February 18, 2023 16:04
Simple 16-Digit CC validator.
# Validate Credit Cards using *math*! (everyone's favourite!)
def validate_cc_number(cc_number: int):
# check if card is 16 digits
if len(str(cc_number)) != 16:
return False
# double every other digit (starting with the 1st)
# and add them to a list
doubled = []
for i, digit in enumerate(str(cc_number)):
@blockarchitech
blockarchitech / atem.applescript
Created August 12, 2022 21:22
Random thing to control ATEM Software Control via AppleScript.
tell application "System Events" to tell menu bar 1 of application process "ATEM Software Control"
click menu item "ProPresenter" of menu "Aux1" of menu bar item "Aux1"
click menu item "ProPresenter" of menu "Aux2" of menu bar item "Aux2"
click menu item "ProPresenter" of menu "Aux3" of menu bar item "Aux3"
end tell
@blockarchitech
blockarchitech / bubblesort.c
Created June 11, 2022 19:49
Stupid bubble sort in C
// bubble sort in c
// it probably runs like trash, but it works for me
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void print_array(int *array, int size);
void bubble_sort(int *array, int size);
void reverse_sort(int *array, int size);