Skip to content

Instantly share code, notes, and snippets.

View streetturtle's full-sized avatar
:octocat:
Build software people love

streetturtle

:octocat:
Build software people love
View GitHub Profile
@streetturtle
streetturtle / init.lua
Created February 17, 2023 15:01
Hammerspoon snippet to manipulate window position/size with a shortcut
-- GRID
-- hs.window.animationDuration=0.1;
local hotkey = require "hs.hotkey"
local grid = require "hs.grid"
grid.MARGINX = 0
grid.MARGINY = 0
grid.GRIDHEIGHT = 3
grid.GRIDWIDTH = 3
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.org (or in your downloaded distribution).
@streetturtle
streetturtle / DateExtensions.swift
Last active December 24, 2021 02:02
Date Extensions
extension Date {
func getElapsedInterval() -> String {
let interval = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second], from: self, to: Date())
if let year = interval.year, year > 0 {
return "\(year) year\(year == 1 ? "" : "s") ago"
} else if let month = interval.month, month > 0 {
return "\(month) month\(month == 1 ? "" : "s") ago"
@streetturtle
streetturtle / NSColorExtensions.swift
Last active December 24, 2021 01:39
Useful NSColorExtensions
extension NSColor {
/// NSColor initializer accepting hex color string
///
/// ```
/// NSColor(hex: "#BADA55")
/// ```
///
/// - Parameter hex: Hex color string, may include a hash (#) prefix
/// - Returns: an NSColor of given hex color string
@streetturtle
streetturtle / lua-functions.lua
Created October 14, 2020 01:38
Lua helper functions
local function ellipsize(text, length)
return (text:len() > length and length > 0)
and text:sub(0, length - 3) .. '...'
or text
end
--- Converts seconds to "time ago" represenation, like '1 hour ago'
local function to_time_ago(seconds)
local days = seconds / 86400
if days > 1 then
@streetturtle
streetturtle / print-gh-contrib-graph.sh
Last active September 24, 2020 02:21
Prints contribuion graph in terminal for a given user for a given number of days
#!/bin/sh
## Usage: print-gh-contrib-graph username num_of_days
##
## username GitHub username.
## num_of_days Number of days in the past to print graph for.
##
function print_graph {
if [ "$#" -ne 2 ]; then
echo "Expected 2 arguments: username and a number of days"
@streetturtle
streetturtle / fade_on_click.lua
Last active October 20, 2020 15:04
Fade effect of text/image widgets
local fade_widget = wibox.widget {
{
id = 'icon',
image = '/usr/share/icons/Yaru/24x24/apps/org.gnome.PowerStats.png',
widget = wibox.widget.imagebox
},
{
id = 'text',
text = 'Click to fade',
widget = wibox.widget.textbox
@streetturtle
streetturtle / start-a-meeting
Last active March 3, 2023 20:23
Script to start a Google Meet meeting in a default browser and copy the link to the meeting to the clipboard
#!/bin/bash
# Script to start a new Google Meet meeting and copy the link to the clipboard. Supports Google Chrome and Firefox
#
# Prerequisite
# - xclip
# - browser extension to display url of the currently opened page in the window's title
# - Chrome: https://chrome.google.com/webstore/detail/url-in-title/ignpacbgnbnkaiooknalneoeladjnfgb
# In Extension's Options set following:
# - Tab title format: {title} - {protocol}://{hostname}{port}/{path}
#!/bin/bash
LOCKSCREENIMG='/tmp/lockscreen.png'
pgrep i3lock || ffmpeg -loglevel panic -f x11grab -video_size $(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') -y -i :0.0+$1,20 -i /opt/lockscreen/uac-removebg.png -filter_complex "boxblur=9,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -vframes 1 $LOCKSCREENIMG
i3lock -i $LOCKSCREENIMG
@streetturtle
streetturtle / blur-screenshot.sh
Last active March 9, 2019 01:48
Make screenshot, blur it and save - very fast
#!/usr/bin/env bash
ffmpeg -loglevel panic\
-f x11grab\
-video_size $(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')\
-y -i :0.0\
-filter_complex "boxblur=9"\
-vframes 1\
/tmp/i3lock.png