Skip to content

Instantly share code, notes, and snippets.

@shaleh
shaleh / import-csv-from-drive-folder.gs
Created October 18, 2024 00:36
How to import a large batch of CSV into a Google spreadsheet with each CSV file being its own separate sheet. The sheet is named after the CSV file it is sourced from.
function convertCSVFilesToSheets() {
var folderId = "DRIVE_FOLDER_ID"; // Replace with the ID of your folder
var spreadsheetId = "SHEET_ID"; // Replace with the ID of your spreadsheet
var folder = DriveApp.getFolderById(folderId);
var files = folder.getFiles();
var spreadsheet = SpreadsheetApp.openById(spreadsheetId);
while (files.hasNext()) {
#!/bin/sh
# Executed from helix using :pipe-to github-browse-file %{dirname} %{filename} %{linenumber}
OPEN_URL_COMMAND=open
DIR_NAME=$1
FILE_NAME=$2
LINE_NUMBER=$3
@shaleh
shaleh / gist:56321754e7a728aa401866f274f453b9
Created December 28, 2022 09:48
Advent of Code 2022 day 10
use std::fs;
use std::str::FromStr;
#[derive(Copy, Clone, Debug)]
enum CpuOpcode {
Noop,
Addx(i64),
}
impl FromStr for CpuOpcode {
@shaleh
shaleh / advent_2022_day3.rs
Created December 3, 2022 17:42
advent of code 2022 day 3
use std::collections::HashSet;
use std::io::{self, BufRead};
use itertools::Itertools;
fn read_input() -> Vec<Vec<char>> {
let stdin = io::stdin();
let handle = stdin.lock();
handle
fn main() {
let input = read_input();
let sum: u64 = input
.iter()
.map(|(shape, outcome)| {
let action = match outcome {
Outcome::Lose => loses_against,
Outcome::Draw => draws_against,
Outcome::Win => wins_against,
};
Debugger entered--Lisp error: (wrong-type-argument (or eieio-object class) nil obj)
signal(wrong-type-argument ((or eieio-object class) nil obj))
eieio-oref(nil children)
(nconc (eieio-oref (eieio-oref section127 'parent) 'children) (list section127))
(eieio-oset (eieio-oref section127 'parent) 'children (nconc (eieio-oref (eieio-oref section127 'parent) 'children) (list section127)))
(if (eq section127 magit-root-section) (let ((magit-section-cache-visibility nil)) (magit-section-show section127)) (eieio-oset (eieio-oref section127 'parent) 'children (nconc (eieio-oref (eieio-oref section127 'parent) 'children) (list section127))))
(catch 'cancel-section (magit-run-section-hook 'magit-status-sections-hook) (run-hooks 'magit-insert-section-hook) (magit-insert-child-count section127) (set-marker-insertion-type (eieio-oref section127 'start) t) (let* ((end (eieio-oset section127 'end (point-marker))) (map (intern (format "magit-%s-section-map" (eieio-oref section127 'type)))) (map (and (boundp map)
@shaleh
shaleh / rustize_emacs.py
Last active November 11, 2018 18:55
Rustize Emacs code, handles lisp_fn and standard C functions
#!/usr/bin/env python
"""
This only ports the 'shell' of the function, not the real code.
But it is a handy start.
To use put this code in your $PATH and then in (r)emacs mark the function as
a region and M-| rustize-emacs. The result can then be copied into a Rust
source file.
TODO: