Skip to content

Instantly share code, notes, and snippets.

View alexanderankin's full-sized avatar

David Ankin alexanderankin

View GitHub Profile
plugins {
id 'conventions'
}
// server file is ~/Downloads/server.jar exists and contains version.json
def serverFile = file(System.getProperty('user.home')).toPath().resolve('Downloads').resolve('server.jar').toFile().with {
(it.exists() && !zipTree(it).matching { include 'version.json' }.isEmpty()) ? it : null
}
if (serverFile.exists()) {
import { CSSProperties, useEffect, useRef, useState } from 'react'
import './App.css'
import { useLocalStorage } from '@uidotdev/usehooks';
function App() {
// noinspection JSUnusedLocalSymbols
// @ts-ignore
const [count, setCount] = useState(0)
return (
#!/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) {