Pages

Saturday, January 27, 2024

js for tabular data processing

uses for 2d arrays and nested loops

to work with a csv in vim you could create objects by doing some find and replace substitutions.

tsv

it may or may not be a good idea to swap commas for tabs for this operation.

  • tabs are less common
    they offer consistent field separation
  • prevent splitting values
    wrapping the lines with square brackets
  • facilitate subsequent transformations
replacing commas w tabs
:%s/,/\t,/g
preparing the object

behold the substitution:

:%s/^/\t{ / | %s/$/ },/ | %s/\t/"/g | %s/":/": "/ | %s/,\s*$/,/g
square brackets

this puts square brackets at the start and end which isnt object notation but looks nore like whats in the later examples

:%s/^/[/g
:%s/$/]/g

another way is to use the vim surround plugin VS]
yss] to just do 1 line

summing values

finding sum of columns and rows

const table = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];

// Calculate row sums
for (let i = 0; i < table.length; i++) {
  let rowSum = 0;
  for (let j = 0; j < table[i].length; j++) {
    rowSum += table[i][j];
  }
  console.log(`Sum of row ${i + 1}: ${rowSum}`);
}

// Calculate column sums
for (let j = 0; j < table[0].length; j++) {
  let colSum = 0;
  for (let i = 0; i < table.length; i++) {
    colSum += table[i][j];
  }
  console.log(`Sum of column ${j + 1}: ${colSum}`);
}

filtering data

const data = [
  ['John', 25, 'Developer'],
  ['Jane', 30, 'Designer'],
  ['Bob', 35, 'Manager']
];

// Filter employees older than 25
const filteredData = [];
for (let i = 0; i < data.length; i++) {
  if (data[i][1] > 25) {
    filteredData.push(data[i]);
  }
}
console.log(filteredData);

Friday, January 26, 2024

using vim diff

 use the hyphen d to open 2 files in diff mode

vim -d file1.txt file2.txt

use ]c [c to move between the changes

ctrl w w to scroll through changes

:diffoff to turn off diff

Thursday, January 25, 2024

Tuesday, January 16, 2024

simple org tables

 simple org table addition


| item      | price |

|-----------+-------|

| hotdog    |     1 |

| hamburger |     1 |

| total     |     2 |

#+TBLFM: @4$2=vsum(@2$2..@3$2)


- control c * to re-evaluate

- control c = to enter a formula


rant about daws

ranting about daws

Fl studios piano roll is the best. its all you need its perfect. just stop here.

reason

its uneccesarily complex it looks impressive and in the right hands can create great results. The midi recording worked better than fl though and you could do audio tracking. I got a lot of great use out of it but it pissed me off motivated me to look for alternatives, in that way im greatful Ive learned a lot. I still use it though begrudgingly. Ive got strong opinions about it but I also realize its stupid. I should focus more on making good music instead of nitpicking on the software but theres just some things that bug me to no end.

Im pretty sure going this deep into daws is a mental illness where the cure is to just go offline and touch grass but since im already here il continue because I kind of just want to get it out. all of the software is good in good hands and its just my opinion its not worth getting worked up about. its definately not worth stressing over.

reaper is amazing

  • you can edit video in it
  • superior to protools
  • too customizable its dangerous

ios trackers compared

tracker sunvox vividtracker deflemask squarebeat
pros good shortcuts, has midi out, great tool for making chords usable touch navigation, nice lofi grit fm synthesis is really good. touch interface, auv3 support
cons built in insts suck, no auv3 support, wish patterns locked to a grid and sucks when you drag them and they get misaligned 1 octave range, menu divey, cant deal with xm insts hi-fi sounds. importing sounds is a huge hassle, not keyboardy enough, ui is horrible no keyboard support, cant easily do chords

Trackers on a computer

Tracker Milkytracker Renoise fasttracker 2 schism tracker
pros runs on everything supports sfz, can run on raspberry pi! can customize keyboard shortcuts. runs on dos, can switch sounds with numpad, classic key commands, beautiful ui can run on raspberry pi zero, lovely 100% keyboard based flow is a joy. secret fm synth
cons no vsts (whatever its really good still) can't remap key shortcuts, probably have to reconfigure your system shortcuts to get the most out of it. on mac no insert key on mac (alt bkspce on new version ) cmd left right clash with linux/ mac spaces although theres a piano roll plugin your better off just learning to track because its nothing like FLs piano roll super glitchy(maybe its gotten better idk been a while) doesnt run so great on raspi 3b unless in dosbian. retropie its small idk how to fix that sounds kind of lofi but the same files can be opened in milkytracker and sound fine? you can chop samples it it but its rocket science i always forget how/ its easier to just use reaper (no need to be a historial reenacter)

newfangled js

things I've come across in the wild lately in js land im adding to my bag of tricks

  1. Arrow Functions vs. Traditional Functions:

    • Arrow Functions (New):
      const add = (a, b) => a + b;
      
    • Traditional Functions (Old):
      const add = function(a, b) {
        return a + b;
      };
      
    • Comparison:
      Arrow functions are more concise, especially for simple one-liner functions. They also have a lexical this and no binding of their own this, making them useful for certain scenarios.
  2. Destructuring Assignment vs. Traditional Assignment:

    • Destructuring Assignment (New):
      const [first, second] = [1, 2];
      
    • Traditional Assignment (Old):
      const first = arr[0];
      const second = arr[1];
      
    • Comparison:
      Destructuring is more concise and expressive when extracting values from arrays or objects. It reduces the need for multiple lines of assignment statements.
  3. Template Literals vs. String Concatenation:

    • Template Literals (New):
      const greeting = `Hello, ${name}!`;
      
    • String Concatenation (Old):
      const greeting = "Hello, " + name + "!";
      
    • Comparison:
      Template literals provide a cleaner and more readable way to concatenate strings, especially when including variables or expressions within the string.
  4. Default Parameters vs. Manual Default Values:

    • Default Parameters (New):
      function greet(name = "Guest") { /* ... */ }
      
    • Manual Default Values (Old):
      function greet(name) {
        name = name || "Guest";
        // ...
      }
      
    • Comparison:
      Default parameters offer a more explicit and less error-prone way to define default values for function parameters.
  5. Spread Syntax vs. Concatenation:

    • Spread Syntax (New):
      const arr2 = [...arr1, 4, 5];
      
    • Concatenation (Old):
      const arr2 = arr1.concat([4, 5]);
      
    • Comparison:
      Spread syntax is concise and provides a more visually appealing way to merge arrays or objects.
  6. Object Literal Enhancements vs. Traditional Object Creation:

    • Object Literal Enhancements (New):
      const point = { x, y, draw() { /* method implementation */ } };
      
    • Traditional Object Creation (Old):
      const point = {
        x: x,
        y: y,
        draw: function() { /* method implementation */ }
      };
      
    • Comparison:
      Object literal enhancements reduce redundancy and make the syntax more concise for defining properties and methods.
  7. Promises/Async-Await vs. Callbacks:

    • Promises/Async-Await (New):
      async function fetchData() {
        const data = await fetchDataFromAPI();
        console.log(data);
      }
      
    • Callbacks (Old):
      fetchDataFromAPI(function(data) {
        console.log(data);
      });
      
    • Comparison:
      Promises and async-await provide a more structured and readable way to handle asynchronous operations compared to nested callbacks.

Monday, January 15, 2024

life hack

  • take the lightbulb out of your room
    that way you just go in there to pass out.
  • after every pomodoro do 20 push ups. the idea is to just keep your blood flowing throughout the day. dabbled with setting an alarm every half hour but it gets really annoying. give it a try for a day see how you feel starting at 5 am it’s kind of rough

Friday, January 12, 2024

tables: dhruvasagar/vim-table-mode

leader tt = tablize

leader tm = enable table mode

leader tdd = del row

leader tdc = del col

leader tic = ins col

leader tfa = forumula


== NAVIGATE TABLES ==


from within tables

] + pipe move right

} + pipe move down


== godlygeek/tabular ==

its like prettify

visual select + :Tabularize /= 

:Tab /:\zs this is a positive lookbehind regex to grab whitespace

will align everything to the equal sign


http://vimcasts.org/episodes/aligning-text-with-tabular-vim/


Thursday, January 11, 2024

16:9

im finally putting a stop to all thiss nonsense.

Ive been making videos in landscape mode for way too long.

---

the fix!

---


- in reaper: in render settings change 1080x1920 

swap those around the default is the other way around.

- in OBS > settings video output choose 1080x1920


== 16:9 images on mac ==

vertical size for the memes

some px resolutions i like for web.

540x960

270x480

pinta? paintbrush? I havent used my computer in a few days and forget everything. what was that one on mac that was like ms paint?

im going with pinta. to zoom in and out:

- shift drag

- flip horizontally by dragging to edges

- ctrl drag to free scale

- right click drag to rotate

Thursday, January 4, 2024

alias for icloud beorg directory

Icloud files on mac are stored in /library/mobile/ but its cool you can make a shortcut to cd into the beorg directory on Icloud. it makes it easier to keep everything in sync. im using syncthing for syncing between raspberry pi and linux mint. that way all the org files stay up to date. mobius on ios to sync has an IAP for linking outside the sandboxed app storage to external folders. its cool but I couldn't get it to work on my other ios devices. its a little annoying having to sync everything to that one, but its a heck of a lot easier than trying to get everything to work with syncthing.

Zathura on mac

I like Zathura on linux mint for opening pdfs because it can navigate with vim bindings. I was having trouble with installing it on mac with homebrew. You think it would be one command like brew install zathura, but you also need mupdf and poppler.

after I got it installed it i couldn't just search for it in the apps to run it Its installed in the homebrew area for some reason I never became aquainted with the file path. Even though i could easily look it up and remember where it saves I for some reason instead choose to forget it. maybe writing about it will help me remember?

my workaround

I made a fzf one liner to search for stuff and open it


find /Users/bweew/Documents -type f -iname '*Jon Duckett*' | fzf | xargs -I {} zathura "{}"

Alfred

I Installed Alfred on my mac

CMD SPACE
-------------
annoyed how spotlight kept looking on the web for stuff instead of locally.
shift tab to finder + CMD F
-------------
ehhh that works but i miss rofi on linux.
- saw ali abdaal mention it helps keep his fingers on the keys.
decided to see what all the fuss was about finally.
- installing another app to do something that should already just work sucks but I was in an experimental try new things type of mood.
IM LIKIN IT SO FAR
ALT SPACE = brings up alfred
--------------
had to enable permissions and index the file system then restart it to get it to work but im happy with it now

Tuesday, January 2, 2024

how to fix yaml view in obsidian

kept bugging me when I was trying to enter in yaml in plain text but it kept forcing me to use a stupid property entry form.I WANT MY PLAIN TEXT TO BE PLAIN LEAVE IT ALONE!

heres the fix


settings > editor > display heading > properties in document > source option

Monday, January 1, 2024

close all apps with siri on mac

ever since discovering how great siri is ive been making shortcuts for everything.
I asked siri to close apps but it said that finder doesn't integrate yet. well theres ways..

made a shortcut called "close apps" so when i tell siri it runs the shortcut.

Its just running a shell script that pkills a bunch of apps i probably have running. it looks like this:

pkill Obsidian
pkill Chrome
pkill kitty
pkill Quick
pkill Preview
pkill Tomito
pkill firefox
pkill Safari
pkill MWeb
pkill TextEdit
pkill Textastic
pkill FL studio
pkill REAPER
pkill MilkyTracker
pkill Brave
pkill Hosting AU
pkill Terminal
pkill Collectioins
pkill iTerm
pkill Calculator
pkill Audacity
pkill App Store
pkill MacVim
pkill Mail
pkill Pinta
pkill koala
pkill Notes
pkill LibreOffice
pkill calibre
pkill Shortcuts

the globe key rules

remapping r cmd to be globe key opens up new possibilities on mac. I'm going to add it to my bag of tricks along side remapping caps lock to escape with Karabiner for a better time using vim. what made me see the value in this is using full keyboard control on the ipad. I tried enabling it once and found that often keyboard shortcuts would be stolen from other apps making it frustrating to use. being able to toggle it on and off with control opt cmd p is essential to getting this to work.

VIM THINGS I LEARNED TODAY:

  • gq slaps some line-breaks into your long run on sentance making it easier to edit. no need to mess with gj and gk to traverse a cumbersome block.
  • '' (2 single quotes) in normal mode jump you to the last place you were at.
  • :set nospel = turn off spellcheck
  • ~ (tilde) swap case under letter
  • option esc = speak selected text on mac