Skip to content

Instantly share code, notes, and snippets.

@wlads
wlads / Capybara.md
Created August 16, 2024 20:46 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@wlads
wlads / how-to-setup-verified-commits.md
Created January 1, 2024 21:05 — forked from Beneboe/how-to-setup-verified-commits.md
How to Setup Verified Commits on Github
@wlads
wlads / check_ruby_debug.sh
Last active February 21, 2023 17:49
[sh] Check if a ruby gem is installed
# gem list -i -e 'debug' -v '>= 1.0.0'
# -i returns true / false
# -e exact match (avoid partial match), could also be a regex e.g. '^debug$'
# -v specify gem version (may also use pessimistic version)
function check_ruby_debug() {
debug_gem_installed=$(gem list -i -e "debug" -v ">= 1.0.0")
if [[ $debug_gem_installed = "false" ]]; then
echo -e "Ruby's debug gem not installed!"
echo -e "run: gem install debug"
@wlads
wlads / graphic_card_switch_control.sh
Created June 5, 2021 22:10 — forked from ccqpein/graphic_card_switch_control.sh
macOS 10.14 use pmset to control graphic card switch.
# I find this https://discussions.apple.com/thread/8160651
# but it not match my 2018 version MacBook with macos 10.14
#
# On my local, gpuswitch value is
# 0 -> does not use dedicated graphics
# 1 -> use dedicated graphics
# 2 -> switch automaticly (I guess), because 2 is default value when "automatic graphics switching" selected
# in energy in preference.
# check settings depended on charger/battery
@wlads
wlads / whatFilesHaveIShared.gs
Created November 19, 2020 03:30 — forked from danjargold/whatFilesHaveIShared.gs
Google script to list (on a Google Sheet) all files shared in your google drive, including all viewers, editors, and sharing permissions. Credit goes to @woodwardtw (https://gist.github.com/woodwardtw/22a199ecca73ff15a0eb) as this is an improvement on his code which only assesses a single folder and one level of sub-folders down.
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
//var folder = DriveApp.getFolderById("INSERT_YOUR_FILE_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
//getLooseFiles(folder, sheet);
//getSubFolders(folder, sheet);
//instead of getting folder by ID rather get all folders and cycle through each. Note this will miss loose files in parent directory.
var folder = DriveApp.getFolders()
@wlads
wlads / README.md
Created July 15, 2020 18:25 — forked from kiedtl/README.md
[Dunnet Guide] A guide for those who struggle with the game Dunnet on Emacs. #game

Dunnet Guide

First, you start with this command in CMD / Bash--

emacs -batch -l dunnet

--and then you get this prompt.

@wlads
wlads / changeJDK.bash
Created July 14, 2020 02:32 — forked from trmaphi/changeJDK.bash
[Change system wide java version on Mac OS] Inspire by a stackoverflow answer https://stackoverflow.com/a/44169445/6730571 #bash #mac
#!/usr/bin/env bash
JDKS_DIR="/Library/Java/JavaVirtualMachines"
JDKS=( $(ls ${JDKS_DIR}) )
JDKS_STATES=()
# Map state of JDK
for (( i = 0; i < ${#JDKS[@]}; i++ )); do
if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then
JDKS_STATES[${i}]=enable

Technical details for https://stackoverflow.com/a/44169445/6730571

Details of investigation:

On a base system, /usr/bin/java is a symlink that points to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, which is an Apple wrapper tool that locates and executes the actual java.

(Do not touch anything in those 2 system directories. It should actually be impossible due to "System Integrity Protection" anyway.)

If you don't have Java installed, attempting to execute java will open a dialog that invites you to install it.

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@wlads
wlads / ffmpeg.md
Created August 14, 2017 01:27 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz: