Skip to content

Instantly share code, notes, and snippets.

@madacol
madacol / nlsh.zsh
Created October 8, 2023 16:32
zsh script, that ask `llm` for a shell command, and puts it in the edit buffer, ready to execute or edit
#!/bin/zsh
echo "$@" \
| llm -s 'Your task is to output oneliner shell commands.
Always answer with a single line shell command, or a multiline using code blocks' \
| tee /dev/shm/nlsh_stdout
extracted_command=$(sed -n '/^[ \t]*```/,/^[ \t]*```/{//!p}' /dev/shm/nlsh_stdout)
# If the command is empty, get the last line of the output
@madacol
madacol / chatGPT to markdown.js
Last active May 31, 2023 16:45
Converts chatGPT conversations to markdown, you can even use it as a bookmarklet. Adapted from this one https://www.reddit.com/r/ChatGPT/comments/11h50jl/chatgpt_conversation_to_markdown_bookmarklet/
javascript: (function () {
var odd = document.querySelectorAll(".group.w-full:nth-child(odd) .items-start");
var even = document.querySelectorAll(".group.w-full:nth-child(even)");
if (odd.length === 0 || even.length === 0) {
alert("Failed to find expected html elements.\nIs this a chat.openai.com/chat/ page?");
return;
}
if (odd.length != even.length) {
alert("count mismatch");
@madacol
madacol / spreadsheet.html
Last active March 22, 2022 07:42
Simple javascript spreadsheet
<!DOCTYPE html>
<html>
<head>
<script>
/**
* This is a modified version of the spreadsheet below ↓ to allow editing while receiving realtime changes
* https://github.com/xem/sheet/blob/gh-pages/full-commented.html
*/
// Sheet!
<?xml version="1.0" encoding="UTF-8"?>
<gamecontroller configversion="19" appversion="2.23">
<!--The SDL name for a joystick is included for informational purposes only.-->
<sdlname>Logitech Dual Action</sdlname>
<!--The GUID for a joystick is included for informational purposes only.-->
<guid>030000006d04000016c2000010010000</guid>
<profilename>main</profilename>
<names/>
<sets>
<set index="1">
@madacol
madacol / padron_reducido_to_SQL.sh
Last active September 16, 2019 16:30
Transform padron reducido to SQL
gzip -c -d ~/Downloads/padron_reducido_ruc.zip | tail -n+2 | iconv -f ISO-8859-1 -t UTF-8//TRANSLIT | sed -E -e "s/'/''/g" -e "s/\|$/')/g" -e "s/^/,('/g" -e "s/([^\\\\])(\\\\\\\\)*\|/\1\2','/g" -e "1~100000 s/^,/;insert into consulta_ruc (idruc, razon_social, estado_contri, domicilio, ubigeo, via, nombre_via, zona, tipo_zona, numero, interior, lote, departamento, mazana, kilometro) values /g" -e "1 s/^;//g" -e "$ s/$/;/g"
@madacol
madacol / Rakefile
Created July 11, 2018 04:31 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)

Keybase proof

I hereby claim:

  • I am madacol on github.
  • I am madacol (https://keybase.io/madacol) on keybase.
  • I have a public key ASDZF2UivLqZk0pRgoJSLei8UOtJ8SD5qWS7Z9c1SrvnFgo

To claim this, I am signing this object:

Moved

Up-to-date version here: https://github.com/madacol/sinkSwitcher


How to use this

Each script is independent from each other.

  • Download whichever you want.
  • Make it executable i.e. chmod +x sinkSwitcher.sh.