Skip to content

Instantly share code, notes, and snippets.

View matiaskorhonen's full-sized avatar

Matias Korhonen matiaskorhonen

View GitHub Profile
@matiaskorhonen
matiaskorhonen / link_to_with_confirm.rb
Created December 5, 2011 21:20
Prettier Rails confirmation dialogs
@matiaskorhonen
matiaskorhonen / crouton-to-mela.rb
Last active August 24, 2022 01:24
A rough Crouton (https://crouton.app) to Mela (https://mela.recipes) recipe converter. The imported recipes may require some clean-up…
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "tty-logger", "~> 0.6"
gem "pry"
gem "dotiw"
#EXTM3U
#EXTINF:0,Yle 1
http://yletv-lh.akamaihd.net/i/yletv1hls_1@103188/index_1_av-b.m3u8
#EXTINF:0,Yle 2
http://yletv-lh.akamaihd.net/i/yletv2hls_1@103189/index_1_av-b.m3u8
#EXTINF:0,Yle Teema
http://yletv-lh.akamaihd.net/i/yleteemahls_1@103187/index_1_av-b.m3u8
#EXTINF:0,Yle Fem (suomi)
http://yletv-lh.akamaihd.net/i/ylefemfihls_1@103185/index_1_av-b.m3u8
#EXTINF:0,Yle Fem (ruotsi)
@matiaskorhonen
matiaskorhonen / uusimaa.geojson
Last active November 20, 2021 11:46
Uusimaa postcode areas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matiaskorhonen
matiaskorhonen / postgresapp_unix_socket.md
Last active June 15, 2021 21:37 — forked from iamvery/postgresapp_unix_socket.md
Setup Postgres.app to allow connections via unix sockets

These are instructions to setup Postgres.app to allow connections over unix sockets. These instructions were written for macOS Sierra (10.12) and Postgres.app 9.6.0

  1. Run Postgres.app once so that the configuration is initialized in ~/Library/Application Support/Postgres/var-9.6/
  2. Quit Postgres.app
  3. Open ~/Library/Application Support/Postgres/var-9.6/postgresql.conf in your favorite text editor
  4. Uncomment the line unix_socket_directories = '/tmp' and change it to unix_socket_directories = '/var/pgsql_socket,/tmp'
  5. Run sudo mkdir -p /var/pgsql_socket
  6. Run sudo chmod 770 /var/pgsql_socket
  7. Run sudo chown root:staff /var/pgsql_socket
@matiaskorhonen
matiaskorhonen / check-certificate.rb
Last active April 19, 2021 21:53
Check an SSL/TLS certificate in Ruby (with SNI support)
# Modified from:
# http://findingscience.com/ruby/ssl/2013/01/13/reading-an-ssl-cert-in-ruby.html
require "socket"
require "openssl"
host = "www.piranhas.co"
tcp_client = TCPSocket.new("www.piranhas.co", 443)
ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)
@matiaskorhonen
matiaskorhonen / statusbarmagic.sh
Created January 28, 2021 10:47
Override the iOS Simulator status bar in all running simulators
function statusbarmagic() {
usage="Usage: statusbarmagic apply|clear|help"
arg="$1"
requirements=( xcrun jq )
missing=0
for c in "${requirements[@]}"
do
if ! command -v "$c" &> /dev/null
then
@matiaskorhonen
matiaskorhonen / librespot.service
Created November 20, 2020 15:02
Librespot (https://github.com/librespot-org/librespot) systemd config (/etc/systemd/system/librespot.service)
[Unit]
Description=Librespot
Requires=network-online.target
After=network-online.target
[Service]
User=nobody
Group=audio
Restart=always
RestartSec=10
@matiaskorhonen
matiaskorhonen / recursive-hashes
Last active November 11, 2020 16:39
Generate SHA256 recursively in a directory tree. Uses the same checksum file format as https://linux.die.net/man/1/sha256sum
#!/usr/bin/env ruby
require "digest"
require "find"
require "optparse"
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: recursive-hashes [options]"
@matiaskorhonen
matiaskorhonen / ics.md
Created November 20, 2019 12:35
Add iCalendar/ICS feed to Google calendar

Link to add a iCalendar feed to Google Calendar

https://www.google.com/calendar/render?cid=http://example.org/index.ics

Note: cid must be a plain HTTP URL even if the feed is actually served over HTTPS

Source: https://stackoverflow.com/a/1479310