Skip to content

Instantly share code, notes, and snippets.

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 Jun 5, 2021
Check FlowCrypt repos for outdated versions of GitHub Action
View emails_updated.py
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
Teaching Fatima fundamental file operations in Python
View cp.py
# 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
ugly Python one-liner
View secure_algs.py
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 Apr 22, 2021
Acquire Fashion MNIST and verify that images + labels work
View fmnist.rs
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 Mar 28, 2021
Building this blog's RSS feed in Rust
View blog_rss_rust.md

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 Mar 28, 2021
RSS feed of blog post Gists
View gistblog->rss.rs
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 Mar 2, 2021
Group by chipset object problem
View groupByChipset.js
//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 Feb 21, 2021
Create pie chart from Clockify
View clock.py
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 Feb 2, 2021
Solution to cassidoo newsletter stock thing
View dequeue_stocks.py
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 Jan 18, 2021
Move and slice Godot script for Pancho
View move_icon.gd
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"):