Skip to content

Instantly share code, notes, and snippets.

View alexanderankin's full-sized avatar

David Ankin alexanderankin

View GitHub Profile
#!/usr/bin/expect
# set timeout 120 # debugging
foreach {
name
email
} $argv break
# Check if the variable is set
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@alexanderankin
alexanderankin / fetch.py
Created February 20, 2024 02:22
fetch.py
import urllib.request
def fetch(request: urllib.request.Request):
with urllib.request.urlopen(request) as response:
response_body = response.read().decode('utf-8')
if 200 < response.getcode() >= 400:
raise Exception(f"HTTP Error: {response.getcode()} - {response.reason}")
return response_body
/**
* @param { import('knex').Knex } knex
* @returns { Promise<void> }
*/
export async function up(knex) {
await knex.schema.createTable('citation', t => {
t.increments();
t.string('name', 255).notNullable().unique();
t.text('description').nullable()
t.timestamps();

create a kubernetes cluster

(a work in progress)

create droplets

curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer '$TOKEN'' \
    -d '{"names":["k8s-droplet"],
@alexanderankin
alexanderankin / react-hook-form-latest.malware.js
Created December 24, 2023 01:57
PSA - npm malware analysis
// the react-hook-form-latest package is malware
// https://www.npmjs.com/package/react-hook-form-latest/v/37.3.6?activeTab=code
var require = function(moduleName) {
console.log('requiring', moduleName);
return new Proxy({ moduleName }, {
get(target, prop, receiver) {
console.log('getting field', prop, 'from target', target)
switch(target.moduleName) {
@alexanderankin
alexanderankin / .bash_completion
Last active December 11, 2023 15:36
/usr/share/bash-completion/completions/ssh (mv ssh ./.config/bash_completion.d/ ; echo '. ~/.bash_completion' >> .bashrc)
# -*- shell-script -*-
#
# bash_completion - programmable completion functions for bash 4.2+
#
# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
# © 2009-2020, Bash Completion Maintainers
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
@alexanderankin
alexanderankin / ignore_properties.py
Last active February 14, 2024 10:04
omits extra fields in python dataclasses like `@JsonIgnoreProperties(ignoreUnknown = true)`
from dataclasses import fields
from typing import TypeVar, Type
IPT = TypeVar('IPT')
def ignore_properties(cls: Type[IPT], dict_: any) -> IPT:
"""omits extra fields like @JsonIgnoreProperties(ignoreUnknown = true)"""
if isinstance(dict_, cls): return dict_ # noqa
class_fields = {f.name for f in fields(cls)}