Skip to content

Instantly share code, notes, and snippets.

@Semmu
Semmu / batch_remove_onlyshowin.sh
Created February 26, 2014 14:22
Shell script to remove "OnlyShowIn=" lines from .desktop files
#!/bin/sh
#
# wrote this snippet to see all my applications and shortcuts in Synapse, the launcher I'm using
FILES=/usr/share/applications/*.desktop
for f in $FILES
do
echo 'removing OnlyShowIn from' $f
sed --in-place '/OnlyShowIn/d' $f
done
@Semmu
Semmu / C++ public and private interface trick
Last active August 29, 2015 14:05
How to create a class that only exposes it's "private" things to its owner
#include <iostream>
class Owner
{
public:
class PublicInterface
{
public:
int publicVariable;
@Semmu
Semmu / .run_synapse.sh
Created April 18, 2015 03:22
Ubuntu 14.10 synapse starting script
#!/bin/sh
# in ubuntu 14.10, using the synapse/testin PPA synapse crashes
# a workaround is to set the GTK_IM_MODULE envvar to nothing at the first start
# this script does it, or invokes the already running instance, if there is any
pidof synapse
if [ $? -eq 0 ]
then
# so it does not wrap
git config --global core.pager 'less -S'
# graphical git log with some settings
git log --graph --full-history --all --color --date=relative --pretty=format:"%x09%C(yellow)%h%C(auto)%d %C(magenta)(%ad) %C(blue)<%an>%n%x09%x09%s"
@Semmu
Semmu / bg_check.html
Created November 26, 2015 19:34
BG check - b&w check pattern for analog display tuning
<html>
<head>
<title>BG check - b&w check pattern</title>
<style>
html {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAAAAABX3VL4AAAADElEQVQI12Ng+A+EAAYAAf9C8vvWAAAAAElFTkSuQmCC);
}
</style>
</head>
<body>
@Semmu
Semmu / ripper.sh
Created January 6, 2017 19:13
VGM ripper (http://downloads.khinsider.com/), batch download whole albums. First argument to the script must be an album URL.
#!/bin/bash
TRACKS=$(curl -v --silent ${1} 2>/dev/null | grep ".mp3\">Download" | sed -e 's/.*href=\"\(.*\)\">Download.*/\1/')
for TRACK in ${TRACKS}; do
URL=$(curl -v --silent ${TRACK} 2>/dev/null | grep "Click here" | sed -e 's/.*href=\"\(.*\)\">Click.*/\1/')
wget ${URL}
done
@Semmu
Semmu / shout.sh
Created July 14, 2017 22:30
Small convenience function to notify when a long running command finishes
# small convenience function to notify when a long running command finishes
#
# usage:
# shout [full command with arguments and whatnot]
#
# eg. shout sudo apt update
#
function shout {
@Semmu
Semmu / bug.py
Created August 7, 2017 14:02
Sublime Text color scheme force-refresh (sometimes different open windows don't register the change)
[ v.settings().erase("color_scheme") for views in [ w.views() for w in sublime.windows() ] for v in views ]
@Semmu
Semmu / bkmrk.sh
Last active September 12, 2017 14:46
#!/bin/bash
#
# SIMPLE FILESYSTEM BOOKMARK MANAGEMENT
#
# usage:
# - create a bookmark for your current working directory with `bkmrk $NAME`
# - cd to any of your bookmarks with `jump $NAME`
# - list your bookmarks and their destinations with `lsbkmrks`
@Semmu
Semmu / .bashrc
Created January 17, 2018 16:20
Descriptive git bash prompt
RESET='\[\033[0m\]'
RED='\[\033[00;31m\]'
GREEN='\[\033[00;32m\]'
YELLOW='\[\033[00;33m\]'
BLUE='\[\033[00;34m\]'
PURPLE='\[\033[00;35m\]'
CYAN='\[\033[00;36m\]'
LIGHTGRAY='\[\033[00;37m\]'