Skip to content

Instantly share code, notes, and snippets.

View Hamatti's full-sized avatar

Juhis Hamatti

View GitHub Profile
Hamatti /
Created January 16, 2014 00:31
Added some alias stuff to display git branch description everytime I do git status (or gs as it's aliased for me). That helps me keep on track with branches that are named like issue-[nro] or fix-[nro].
function parse_git_branch_name {
git rev-parse --abbrev-ref HEAD
function parse_git_description {
git config branch.$(parse_git_branch_name).description
alias gs='echo $(parse_git_branch_name): $(parse_git_description) && git status'
class A(object):
def __init__(self, key, value):
self.key = key
self.value = value
def double_value(self):
return self.value * 2
Hamatti / file.txt
Created September 9, 2014 02:05
Example file for Beauty of the Pipe blog post
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris aliquet metus non nunc scelerisque pretium. Nunc eu lobortis neque. Praesent vehicula feugiat consectetur. Morbi sit amet sapien in odio faucibus tristique eget quis leo. In auctor arcu ac venenatis aliquet. Sed imperdiet elementum mauris, nec semper justo vestibulum at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend non ante at iaculis. Suspendisse at magna metus. Duis sit amet est enim. Integer sem lorem, varius sed erat et, cursus placerat nunc. Donec egestas eros sollicitudin neque suscipit, eu porttitor est dignissim. In erat quam, tincidunt et molestie at, condimentum ut velit.
Fusce tempor dolor augue, ut tincidunt ligula laoreet et. In placerat, justo in pharetra molestie, erat justo suscipit lorem, non vestibulum tellus magna tincidunt mauris. Aliquam erat volutpat. Suspendisse potenti. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec in nisi gravida, mollis est sit amet, condimentum mi. Duis
Hamatti / bbpr-bookmarklet.js
Last active August 29, 2015 14:06
A JS Bookmarklet to show difference in lines of codes for a BitBucket pull request
javascript:(function(){alert(([]'.lines-added, .lines-removed')).reduce(function (a, el){return a + Number(el.innerHTML);},0)+' loc').replace(/^(?!-)/, '+'))})()
Hamatti /
Created March 7, 2020 16:00
Asus ZenScreen rotation aliases
# You can find out your display id with displayplacer list
# Find displayplacer at
alias asusportrait='displayplacer "id:[your_display_id] degree:90 origin:(1920, 0)"'
alias asuslandscape='displayplacer "id:[your_display_id] degree:0 origin:(1920, 0)"'
Hamatti / on24-bookmarklet.js
Created November 9, 2020 18:01
A bookmarklet to add keyboard / presentation clicker support to webinar platform
* @author Juha-Matti Santala / @hamatti
* This code is a bookmarklet that adds support to's presentator view for arrow right/left and page down/up keys
* to switch slides.
* If your presentation clicker sends different keys to the computer when clicking next/prev, you can adjust the code by
* changing the if clauses
Hamatti / areena.js
Created December 6, 2020 15:32
Bookmarklet for removing YLE Areena's live chat
// This bookmarklet is for removing the live chat from YLE Areena
// Copy-paste the line below into the URL field of a new bookmark
javascript:(function() { document.getElementById('yle-livefeed').remove() })()
Hamatti /
Created March 11, 2021 10:26
Python pattern matching for Pokemon cards. Works on Python 3.10a6
class Card:
def __init__(self, id, name, supertype, subtype): = id = name
self.supertype = supertype
self.subtype = subtype
charizard = Card('ex3-100', 'Charizard', 'Pokemon', 'Stage 2')
lapras = Card('ex3-103', 'Lapras', 'Pokemon', 'Basic')
muscle_band = Card('xy1-121', 'Muscle Band', 'Trainer', 'Item')
Hamatti /
Last active March 11, 2021 11:46
Nested pattern matching in Python 3.10a6
class Card:
def __init__(self, id, name, supertype, subtype): = id = name
self.supertype = supertype
self.subtype = subtype
def play_card(card):
match card:
Hamatti / bot.js
Last active August 2, 2021 14:45
Very simple Discord bot skeleton
const Discord = require('discord.js');
const cron = require('cron');
const client = new Discord.Client();
const job = new cron.CronJob("00 00 10 * * *", () => {
client.channels.cache.get("[channel id]").send("Tick tock");