Skip to content

Instantly share code, notes, and snippets.

View isakb's full-sized avatar
💭
I may be slow to respond.

Isak Bakken isakb

💭
I may be slow to respond.
View GitHub Profile
@isakb
isakb / download_all_as_zipfile.js
Last active February 6, 2025 15:14
Bulk download PDFs from ETrade
// For https://us.etrade.com/etx/sp/stockplan/#/myAccount/stockPlanConfirmations
// NOTE! The ETrade website has been updated, this script no longer works, as of Feb 6, 2025.
0&&(async()=>{let $=new TextEncoder,e=$$("td[data-content=Confirmation] > a").map(($,e)=>({url:$.href,name:`file_${e+1}.pdf`})),f=async({url:$,name:e})=>{let f=await fetch($);if(!f.ok)throw Error(`Failed to fetch: ${$}`);let x=new Uint8Array(await f.arrayBuffer());return{name:e,fileData:x}},x=async e=>{let x=[],l=0,t=[],n=await Promise.all(e.map(f));for(let{name:h,fileData:a}of n){let i=$.encode(h),g=[80,75,3,4,20,0,0,0,0,0,0,0,0,0,...[,,,,].fill(0),255&a.length,a.length>>8&255,a.length>>16&255,a.length>>24&255,255&a.length,a.length>>8&255,a.length>>16&255,a.length>>24&255,255&i.length,i.length>>8&255,0,0];x.push(new Uint8Array(g)),x.push(i),x.push(a),t.push({offset:l,fileNameBytes:i,fileHeader:g,fileSize:a.length}),l+=g.length+i.length+a.length}let o=[],r=0;for(let{offset:p,fileNameBytes:c,fileHeader:s,fileSize:d}of t){let u=[80,75,1,
import json
import os
import xml.etree.ElementTree as ET
import requests
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
@isakb
isakb / is_even.py
Created June 22, 2024 18:22
Enterprise version of is_even
# Enterprise version of is_even.
# (Don't use this in a startup.)
#
# python is_even.py 1
# False
# python is_even.py 2
# True
# python is_even.py 101
# False
# python is_even.py 1
@isakb
isakb / lolcode.lolcode
Created December 19, 2015 15:06
Hackerrank Project Euler Problem 1
HAI 1.3
BTW THIS IS LOLCODE
BTW IT IS GOOD TO SUMMARIZE NUMBERS
HOW IZ I SUMMARIZE YR NUMBER
I HAS A SOLUSHUN ITZ 0
I HAS A VAR ITZ A NUMBR
I HAS A SECRET ITZ A NUMBR
@isakb
isakb / code.coffee
Created June 7, 2014 21:05
Download JavaScript array as Excel CSV for any version of Excel
# See http://jsfiddle.net/isak_b/hp6fj/ for live demo.
asUtf16 = (str) ->
buffer = new ArrayBuffer(str.length * 2)
bufferView = new Uint16Array(buffer)
bufferView[0] = 0xfeff
for i in [0..str.length]
val = str.charCodeAt(i)
bufferView[i + 1] = val
bufferView
@isakb
isakb / instructions
Created March 1, 2014 01:17
google translate is a beatbox
1. Open http://translate.google.com/#ja/en/gh%20bchtk%20pv%20zk%20pv%20pv%20zk%20pv%20zk%20kz%20kh%20pv%20zk%20pv%20zk%20bchkt%20zk%20pzk%20pzk%20kkkkkk%20bsch%0Abchtk%20zk%20kppp%20bsch%20sss%20gh.
2. Press the left speaker button to listen.
3. Record output with:
parec --format=s16le --device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | oggenc --raw --quiet -o dump.ogg -
@isakb
isakb / install_ni_prefix.sh
Last active July 2, 2018 12:52
Create "ni" prefix to disable internet access for specific commands
#!/bin/bash
# Install "ni" prefix for executing scripts without allowing internet access.
# Tested on Ubuntu 13.04.
# Example:
# $ ni ping google.com
# ping: unknown host google.com
#
# $ ping google.com
# PING google.com (173.194.40.229) 56(84) bytes of data.
# 64 bytes from arn02s06-in-f5.1e100.net (173.194.40.229): icmp_req=1 ttl=59 time=1.41 ms
@isakb
isakb / doge_js_console.html
Created February 13, 2014 23:48
Console override, doge_js style. For Chrome and Firebug.
<script>
(function(){
console.log('%c very console',
'color: blue; font-size: 24px; font-family: "Comic Sans MS"');
console.log('%c such script',
'color: green; font-size: 18px; font-family: "Comic Sans MS"');
Object.defineProperty(console, '_commandLineAPI', {
@isakb
isakb / gist:6580890
Created September 16, 2013 13:46
Convert a whole JS project to CoffeeScript (first step)
for f in `find . -name '*.js'`; do js2coffee $f > ${f%%js}coffee && rm $f; done
@isakb
isakb / watchish
Created February 15, 2013 17:02
Simple watch variant
#!/bin/bash
# A variant of watch, with smarter color support etc.
[[ $SLEEP ]] || SLEEP=2
cmd=$*
prev_output=""
while true ; do
output="$( $cmd 3>&1 2>&3 )"