Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Beyarz / ??.js
Last active May 24, 2023 15:12
Javascript tips, tricks & shorthands
// Javascript nullish coalescing operator
// Is set to 0
let x = 0 ?? "hello"
// Is set to goodbye
let y = undefined ?? "goodbye"
// Is set to hello
let z = null ?? "hello"
@Beyarz
Beyarz / dig.md
Created August 4, 2022 13:53
dig dns lookup

Dig dns query

Query using local config

dig feber.se

Query using chosen resolver

dig @1.1.1.1 feber.se

@Beyarz
Beyarz / pictures.rb
Created July 15, 2022 12:45
Get all images from directory
pictures = Proc.new { |file| file.match(/(png|jpeg|jpg)/) }
Dir.entries('.').select &pictures
=> ["image1.png", "image2.png", "pic.jpg", "picture.jpeg"]
@Beyarz
Beyarz / &.rb
Last active May 30, 2023 20:35
Ruby shorthands shortcut
# &, optional chainig
[1,2,3,4,5,6][5]&.to_s
=> "6"
[1,2,3,4,5,6][6]&.to_s
=> nil
# &, map shorthand notation
to_s = Proc.new { |x| x.to_s }
=> #<Proc:0x00000001065bdef0 (irb):8>
[1,2,3].map &to_s
@Beyarz
Beyarz / run.sh
Created June 12, 2022 18:47
Githubs superlinter
docker run -e RUN_LOCAL=true -v $PWD:/tmp/lint github/super-linter
@Beyarz
Beyarz / yabairc
Created June 3, 2022 13:46
.config/yabai/yabairc
#!/usr/bin/env sh
# global settings
yabai -m config mouse_follows_focus off
yabai -m config focus_follows_mouse off
yabai -m config window_origin_display default
yabai -m config window_placement second_child
yabai -m config window_topmost off
yabai -m config window_shadow on
yabai -m config window_opacity off
@Beyarz
Beyarz / skhdrc
Created June 3, 2022 12:33
.config/skhd/skhdrc
# fn - hjkl > arrow keys
fn - k: skhd -k up
fn - h: skhd -k left
fn - l: skhd -k right
fn - j: skhd -k down
# Terminal
# cmd + t
# Firefox
@Beyarz
Beyarz / netstat.sh
Last active May 9, 2022 20:25
netstat open ports
# See open ports
netstat -ant | grep LISTEN
@Beyarz
Beyarz / devurls.js
Last active April 23, 2022 12:07
devurls.com filter by day
// ==UserScript==
// @name Filter
// @version 1.0
// @description Filter by day
// @author You
// @match https://devurls.com
// @icon https://www.google.com/s2/favicons?sz=64&domain=devurls.com
// @grant none
// ==/UserScript==
@Beyarz
Beyarz / dashboard.rb
Created March 27, 2022 21:16
Live updates from sinatra server via hotwired stimulus
# frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'date'
require 'sinatra'
require 'sinatra/reloader' if development?
set :port, 3020
set :bind, '0.0.0.0'