Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@mislav
mislav / bashrc
Last active December 12, 2023 02:25
Basic vimrc and tmux config for servers
PS1='\[\033[31m\]\w\[\033[0m\] $ '
export EDITOR=vim
alias st='git status -sb'
@mislav
mislav / workflows-automerge.yml
Last active December 5, 2023 02:41
Using GitHub CLI from GitHub Actions
name: Auto-merge
on:
pull_request:
types: [opened]
jobs:
automerge:
runs-on: ubuntu-latest
@mislav
mislav / star-trek-all.tsv
Last active November 1, 2023 03:11
List of Star Trek: The Original Series episodes ranked by their meta-score aggregated from several sites
S-EP episode title score
1-01 The Man Trap -33
1-02 Charlie X 26
1-03 Where No Man Has Gone Before 34
1-04 The Naked Time 64
1-05 The Enemy Within 30
1-06 Mudd's Women -31
1-07 What Are Little Girls Made Of? -1
1-08 Miri -30
1-09 Dagger of the Mind 8
@mislav
mislav / setTimeout.js
Last active September 23, 2023 09:51
Overwrite setTimeout so it optionally accepts the delay as 1st argument
(function(){
var _ = window.setTimeout
window.setTimeout = function(delay, fn) {
return (typeof delay == "number") ? _(fn, delay) : _(delay, fn)
}
})()
@mislav
mislav / OpenSSL fix.md
Last active June 8, 2023 07:48
Fix OpenSSL certificate errors on Ruby 2.0

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.

@mislav
mislav / spotify-remote-patch.sh
Last active May 4, 2023 11:09
Patch installer for OS X `rcd` daemon to make headset remote buttons start/stop Spotify instead of iTunes. The pause/resume functionality still doesn't work unless iTunes is running in the background, for some inexplicable reason.
#!/bin/bash
# Run once to patch `rcd` daemon after creating a backup.
# Run again to restore the backup and revert back to original functionality.
set -eu
if [ "$USER" != "root" ]; then
exec sudo "$0" "$@"
fi
rcd="/System/Library/CoreServices/rcd.app/Contents/MacOS/rcd"
# you must also upload the public key as signing key to https://github.com/settings/keys
git config --global user.signingkey '~/.ssh/id_rsa'
git config --global commit.gpgsign true
git config --global gpg.format ssh
# (optional) this file enables `git log --show-signature` and contains email addresses associated with public keys
git config --global gpg.ssh.allowedsignersfile '~/.ssh/git-signers'
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@mislav
mislav / unifi-controller-cert.sh
Last active May 20, 2022 11:42
Figuring how to assign your own SSL certificate to be used by the Unifi Controller web interface
hostname="MYHOST" # set this to where the Unifi Controller is served from
root_ca="rootCA.pem"
root_ca_key="rootCA.key"
cert="unifi.pem"
cert_key="unifi.key"
# these don't really matter
csr="unifi.csr"
pfx_password="whatever"
@mislav
mislav / bash_profile.sh
Created January 24, 2014 17:48
Simple bash prompt that shows current git branch (if any) and colors the dollar sign in red if the last command exited with a nonzero status.
_git_prompt() {
local ref="$(command git symbolic-ref -q HEAD 2>/dev/null)"
if [ -n "$ref" ]; then
echo " (${ref#refs/heads/})"
fi
}
_failed_status() {
[ "$PIPESTATUS" -ne 0 ] && printf "$"
}