Skip to content

Instantly share code, notes, and snippets.

View seisvelas's full-sized avatar
🦊
const sh = network.pop(shell); sh.write({recipient:'admin'}, 'nice system!');

Xandre V seisvelas

🦊
const sh = network.pop(shell); sh.write({recipient:'admin'}, 'nice system!');
View GitHub Profile
@seisvelas
seisvelas / emails_updated.py
Created June 5, 2021 21:49
Check FlowCrypt repos for outdated versions of GitHub Action
import requests
def has_new_gh_action(repo):
raw_url = f'https://raw.githubusercontent.com/FlowCrypt/{repo}/master/.github/workflows/check-for-emails.yml'
raw_action_request = requests.get(raw_url)
if raw_action_request.status_code != 200:
print(f'error checking repo {repo}, status code {raw_action_request.status_code}')
return False
return 'exemptions' in raw_action_request.text
@seisvelas
seisvelas / cp.py
Created May 31, 2021 04:49
Teaching Fatima fundamental file operations in Python
# Simple version of cp command
import sys
if len(sys.argv) < 3:
raise Exception('too few arguments')
command, source, destination, *rest = sys.argv
with open(source, 'rb') as source_file:
@seisvelas
seisvelas / secure_algs.py
Last active May 8, 2021 10:14
ugly Python one-liner
python3 -c 'with open("secure_sigalgs") as f: print("jdk.tls.server.SignatureSchemes=" + ",".join([i.rstrip() for i in f.readlines()]))'
@seisvelas
seisvelas / fmnist.rs
Created April 22, 2021 06:19
Acquire Fashion MNIST and verify that images + labels work
extern crate cifar_10_loader;
extern crate image;
use cifar_10_loader::CifarDataset;
use std::fs::File;
use std::collections::HashMap;
fn main() {
let mut label_ids = HashMap::new();
label_ids.insert(0, "airplane");
@seisvelas
seisvelas / blog_rss_rust.md
Last active March 28, 2021 23:38
Building this blog's RSS feed in Rust

This is not a static blog. It dynamically loads all of my GitHub Gists that begin with blog_. This presented a challenge as to how I would implement RSS, considering I don't have a backend from which I can build the RSS feed, and I also can't statically generate the feed with each deploy, as a Jekyll blog might do.

Wut do? My boring compromise (for now!) is to make a simple Heroku app that calls the Gist API to grab the blog posts, just like this blog does. Except instead of actually rendering the Gists into a blog, I give an RSS feed!

This should be a pretty fun, byte-sized task. Which makes it perfect for a blog post!

Divying the task into little pieces

This project can be divided into the following tasks:

  1. Set up "Hello, world!" web app on Heroku
@seisvelas
seisvelas / gistblog->rss.rs
Last active March 28, 2021 12:14
RSS feed of blog post Gists
use reqwest::header::USER_AGENT;
use reqwest::header::CONTENT_TYPE;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let res: Vec<serde_json::Value> = client
.get("https://api.github.com/users/seisvelas/gists?page=1&per_page=100")
.header(USER_AGENT, "Xandre's RSS")
.header(CONTENT_TYPE, "application/rss+xml")
@seisvelas
seisvelas / groupByChipset.js
Last active March 2, 2021 00:32
Group by chipset object problem
//Given an array of VIZIO TV models, create a "groupByChipset" function
//that aggregates the model names by their "chipset" field:
//Example input:
const tvs = [
{
"modelName": "VIZIO D24f-F1",
"chipset": "5581"
},
{
"modelName": "VIZIO V405-H9",
@seisvelas
seisvelas / clock.py
Created February 21, 2021 00:33
Create pie chart from Clockify
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from sys import argv
sns.set()
def load_tasks(dataframe):
del dataframe['Project']
del dataframe['Client']
@seisvelas
seisvelas / dequeue_stocks.py
Created February 2, 2021 07:27
Solution to cassidoo newsletter stock thing
def stockQueue(snapshot):
dequeued_snapshot = {
stock['sym']:stock['cost'] for stock in snapshot
}
return [
{
'sym':stock,
'cost': cost
} for stock, cost in dequeued_snapshot.items()
@seisvelas
seisvelas / move_icon.gd
Created January 18, 2021 02:40
Move and slice Godot script for Pancho
extends KinematicBody2D
var motion = Vector2()
func _physics_process(_delta):
motion.y += 10
if Input.is_action_pressed("ui_right"):
motion.x = 200
elif Input.is_action_pressed("ui_left"):