Skip to content

Instantly share code, notes, and snippets.

View monorkin's full-sized avatar
👻
Boo!

Stanko Krtalić monorkin

👻
Boo!
View GitHub Profile
-- Replace with your SQL Query
SELECT
a1.first_name || ' ' || a1.last_name AS first_actor,
a2.first_name || ' ' || a2.last_name AS second_actor,
film.title AS title
FROM film
JOIN film_actor AS fa1 ON fa1.film_id = film.film_id
JOIN film_actor AS fa2 ON fa2.film_id = film.film_id
AND fa1.actor_id <> fa2.actor_id
JOIN actor AS a1 ON fa1.actor_id = a1.actor_id
-- Replace with your SQL query
SELECT
to_date(a.date::text, 'YYYY-MM-DD') AS date,
a.count AS count,
to_char(
(count::float / lag(count) over (order by date) - 1) * 100,
'FM999999999.0%'
) AS percent_growth
FROM (
SELECT
# return the array containing the tree levels, from root to last level.
def tree_by_levels(node)
return [] unless node
unpacked_tree = {}
breadth_first_search(node, unpacked_tree)
unpacked_tree.values.flatten
end
def breadth_first_search(node, hash = {}, depth = 0)
return unless node
def justify(text, width)
return if text.nil? || width.nil? || width.negative?
words = text.split(' ')
rows = group_words_into_rows(words, width)
rows = pad_rows(rows, width)
rows.map(&:join).join("\n")
end
def group_words_into_rows(words, width)
@monorkin
monorkin / data.csv
Created August 29, 2018 18:16
Data gathered for the "Licensing software" article
language agpl-3.0 apache-2.0 artistic-2.0 bsd-2-clause bsd-3-clause cc0-1.0 epl-1.0 gpl-2.0 gpl-3.0 isc lgpl-2.1 lgpl-3.0 mit mpl-2.0 unlicensed
Ruby 4513 42208 266 5463 13744 1682 533 20153 14975 797 1155 1617 269015 1878 2247
Rust 162 3188 21 328 714 83 8 665 1317 126 105 137 8108 492 297
C 3060 30281 468 8949 23247 996 802 71930 51125 1637 9981 6433 84365 1574 3057
Python 14102 79036 588 14517 46448 3891 1113 75928 82760 2503 5983 7923 209152 3630 6285
PHP 6205 29648 283 3141 23837 924 243 70814 36439 562 2209 4256 163556 1069 2306
C++ 3161 28707 387 7450 21009 909 584 64061 51985 877 8104 7311 83737 1599 3044
Java 4060 149147 550 3809 12911 1303 5360 32128 46739 609 4164 7993 98623 1753 3998
Kotlin 60 2722 12 51 139 21 14 141 597 26 13 60 2143 84 49
Elixir 76 740 18 126 363 13 9 496 328 93 34 70 4328 82 89

Keybase proof

I hereby claim:

  • I am monorkin on github.
  • I am monorkin (https://keybase.io/monorkin) on keybase.
  • I have a public key ASDDUMYqWMcsxPpKftv97h-jN911JPqFYX-8MZmToeu3dgo

To claim this, I am signing this object:

SELECT licenses.license AS license, COUNT(licenses.repo_name) AS count
FROM [bigquery-public-data:github_repos.licenses] AS licenses
JOIN [bigquery-public-data:github_repos.languages] AS languages ON licenses.repo_name = languages.repo_name
WHERE languages.language.name = '<language name>'
GROUP BY license
@monorkin
monorkin / iterm_theme_to_alacritty.rb
Created May 11, 2018 08:54
Script that converts iTerm themes to Alacritty
#!/usr/bin/env ruby
# frozen_string_literal: true
# USAGE:
# curl https://gist.github.com/stankec/.../iterm_theme_to_alacritty.rb > iterm_theme_to_alacritty.rb
# chmod +x iterm_theme_to_alacritty.rb
# ./iterm_theme_to_alacritty.rb path/to/your/theme.itermcolors
#
# This will output the config to the terminal
#

Keybase proof

I hereby claim:

  • I am stankec on github.
  • I am monorkin (https://keybase.io/monorkin) on keybase.
  • I have a public key ASDDUMYqWMcsxPpKftv97h-jN911JPqFYX-8MZmToeu3dgo

To claim this, I am signing this object:

@monorkin
monorkin / arduino-com
Last active January 12, 2017 13:37
Simple script for sending and reading serial data from your Arduino on *nix systems
#!/bin/bash
# Configuration
DEVICE=/dev/ttyACM0
BAUD=9600
SEND=""
FOLLOW=0
RECEIVE=0
HELP=0