Skip to content

Instantly share code, notes, and snippets.

@jbaranski
jbaranski / shell.sh
Last active September 29, 2024 19:40
MacBook increase display brightness on the command line
# Increase display brightness command
osascript -e 'tell application "System Events"' -e 'key code 144' -e ' end tell'
# Decrease display brightness command
osascript -e 'tell application "System Events"' -e 'key code 145' -e ' end tell'
# zsh solution to turn it all the way up on one command, just run `b` on the cmd line
alias bright="osascript -e 'tell application \"System Events\"' -e 'key code 144' -e ' end tell'"
alias b="repeat 10 { bright }"
@jbaranski
jbaranski / shell.sh
Last active September 10, 2023 14:45
How to fix: "chromedriver" can’t be opened because Apple cannot check it for malicious software.
# How to fix: "chromedriver" can’t be opened because Apple cannot check it for malicious software.
xattr -d com.apple.quarantine /opt/homebrew/bin/chromedriver
@jbaranski
jbaranski / trivia_download.py
Created February 12, 2023 18:26
Download all questions from Open Trivia DB (opentdb.com)
import requests
import json
import time
if __name__ == '__main__':
db = {}
while True:
r = requests.get('https://opentdb.com/api.php?amount=50')
results = r.json()['results']
for result in results:
@jbaranski
jbaranski / ffmpeg_mac_m1_record_cmd_line.md
Last active April 27, 2024 17:31
ffmpeg record screen on Mac M1 chip via command line

ffmpeg record screen on Mac M1 chip via command line

  1. Install ffmpeg.

brew install ffmpeg

  1. Figure out which device to use.

ffmpeg -f avfoundation -list_devices true -i ""

Ouput will look like:

@jbaranski
jbaranski / wordle_game_num_to_date.json
Last active May 14, 2022 23:48
Wordle game number to date map
{
"1": "2021-06-20",
"2": "2021-06-21",
"3": "2021-06-22",
"4": "2021-06-23",
"5": "2021-06-24",
"6": "2021-06-25",
"7": "2021-06-26",
"8": "2021-06-27",
"9": "2021-06-28",
@jbaranski
jbaranski / OracleOpenPort80Centos.md
Created September 26, 2020 02:00
Open Port 80 Oracle Cloud Compute Instance (CentOS)

Open Port 80 Oracle Cloud Compute Instance (CentOS)

FYI This was harder than it needed to be:

  1. Looking at your instance info, find VNIC section, click "Public Subnet".
  2. Click on your security list.
  3. Add a new entry with the following options:
  • "Stateless" = No, "Source" = 0.0.0.0/0, "IP Protocol" = TCP, "Source Port Range" = All, "Destination Port Range" = 80
  1. SSH to your instance.
  2. While SSH'ed in your instance, run command firewall-cmd --permanent --add-service=http.
  3. While SSH'ed in your instance, run command firewall-cmd --reload.
  4. Now start Apache, NGINX, or whatever server you need to on port 80. You can now access from the internet.
@jbaranski
jbaranski / Img2MBTilesWithGDAL.md
Created August 1, 2020 14:52
Convert an image (like JPG or TIF) to MBTiles using GDAL

Here are the steps needed to convert an image (like JPG or TIF) to MBTiles using GDAL:

  1. Download and install GDAL (https://gdal.org/, https://anaconda.org/conda-forge/gdal):

       conda install -c conda-forge gdal
    

    Installing GDAL is kind of a pain in the ass, especially on Windows. I'm assuming you'll be able to work out whatever issues you run into here.

  2. Download example jpg and tif map images we can work with:

@jbaranski
jbaranski / SelfHostOpenStreetMapDocker.md
Created August 1, 2020 14:52
How to self host an Open Street Map server (using Docker)

Here are the steps needed to run a self hosted Open Street Map server (using Docker):

  1. Download desired pbf files (like south-carolina-latest.osm.pbf) from https://download.geofabrik.de or just use the following empty planet below:

    
      <?xml version='1.0' encoding='UTF-8'?>
      <osm version="0.6" generator="osmconvert 0.8.8" timestamp="2019-10-23T20:18:02Z">
        <bounds minlat="42.4276" minlon="1.412368" maxlat="42.65717" maxlon="1.787481"/>
      </osm>
    
@jbaranski
jbaranski / GradleTaskAlias.md
Created August 1, 2020 14:49
Alias a task name in Gradle

The following snippet is how to alias a task name in Gradle:

build.gradle

    // You can now run "gradle alias" and it would be equivalent to running "gradle taskToAlias"
    task alias {
        dependsOn allprojects.collect { proj ->
            proj.tasks.matching {
                it.name == 'taskToAlias'
 }
@jbaranski
jbaranski / NodeJSLocalModule.md
Created August 1, 2020 14:49
Node.js local module

The following package.json snippet is how to reference a local module in your Node.js project:

package.json

{
  ...
  "dependencies": {
    "local-module": "file:./local-module",
    ...
 }