Skip to content

Instantly share code, notes, and snippets.

View lorenzos's full-sized avatar

Lorenzo Stanco lorenzos

View GitHub Profile
@lorenzos
lorenzos / color_picker
Created October 28, 2014 13:59
Pick color and store #HEX in system clipboard
#!/usr/bin/env python
import gtk
import gobject
import pynotify
import sys
# Clipboard object
clipboard = None
/*
* Simple hash map using javascript objects and an ordered array.
* Repeated elements are not allowed.
*
* @param sort_method By default is ASC order, but you can specified whatever you want.
*
* The public methods are:
* -set
* -get
* -del
@lorenzos
lorenzos / android-screen-to-gif.sh
Last active March 30, 2019 21:00
Captures screen from Android device via ADB and makes a 180x320 GIF
#!/bin/bash
# How to install:
# exo-open "http://developer.android.com/sdk/index.html#Other"
# sudo apt-get install libav-tools imagemagick
# wget https://gist.githubusercontent.com/lorenzos/e8a97c1992cddf9c1142/raw/android-screen-to-gif.sh
# chmod a+x android-screen-to-gif.sh
# Help message
function usage() {
@lorenzos
lorenzos / byzanz-record-ui.sh
Created July 14, 2015 09:19
Records a portion of your screen to an animated GIF
#!/bin/bash
#
# RECORDS A PORTION OF YOUR SCREEN TO AN ANIMATED GIF
#
# REQUIREMENTS:
# byzanz: Screen recorder, found in repos
# zenity: Dialogs and notifications, found in repos
# xrectsel: Screen portion selector, found at https://github.com/lolilolicon/xrectsel
#
@lorenzos
lorenzos / better_mootools_docs.css
Last active June 1, 2017 13:17
Better Mootools docs - User script & user styles
@-moz-document url-prefix("http://mootools.net/core/docs/"), url-prefix("http://mootools.net/more/docs/"), url-prefix("https://mootools.net/core/docs/"), url-prefix("https://mootools.net/more/docs/") {
#global-bar {
padding-bottom: 10px;
padding-top: 10px;
}
#logo p img {
width: auto;
height: 20px;
@lorenzos
lorenzos / youtube-pl-dump.js
Last active April 17, 2023 17:20
Dump YouTube playlist data from console to JSON
dump = () => {
const dump = Array.from(document.querySelectorAll('ytd-playlist-video-list-renderer ytd-playlist-video-renderer')).map(item => {
return {
id: item.querySelector('a').href.match(/v=([^&]+)&/)[1],
title: item.querySelector('h3')?.textContent?.trim() || null,
thumb: item.querySelector('ytd-thumbnail img')?.src || null,
by: item.querySelector('ytd-channel-name #text-container')?.textContent?.trim() || null,
length: item.querySelector('.ytd-thumbnail-overlay-time-status-renderer:not([hidden])')?.textContent?.trim() || null
};
});
@lorenzos
lorenzos / discord-dark-sidebar.user.js
Last active September 26, 2019 02:29
Userscript for making Discord sidebar in Light theme dark again, after September 2019 update.
// ==UserScript==
// @name Discord dark sidebar for Light theme
// @namespace Violentmonkey Scripts
// @match https://discordapp.com/*
// @grant none
// ==/UserScript==
var style = `
/*
@lorenzos
lorenzos / partitions.js
Created October 2, 2021 23:01
Generate all partitions of a set of elements
// GENERATES ALL PARTITIONS OF A SET OF ELEMENTS
// A thorough definition can be found on Wikipedia: https://en.wikipedia.org/wiki/Partition_of_a_set
// Implementation of: https://stackoverflow.com/a/20530130
// First, let's solve a simpler problem: how to find all partitions consisting of exactly two parts.
// For an n-element set, we can count an int from 0 to (2^n)-1. This creates every n-bit pattern,
// with each bit corresponding to one input element. If the bit is 0, we place the element in the
// first part; if it is 1, the element is placed in the second part.
// This leaves one problem: For each partition, we'll get a duplicate result where the two parts are
// swapped. To remedy this, we'll always place the first element into the first part. We then only
@lorenzos
lorenzos / dropbox-ignore.sh
Last active May 8, 2024 15:29
Set Dropbox ignored attribute on files, updates emblems for Thunar
#!/bin/bash
# Requires: sudo apt install attr libglib2.0-bin xdotool
ATTR_IGNORED="com.dropbox.ignored"
ATTR_EMBLEMS="metadata::emblems"
EMBLEM_IGNORED="emblem-colors-red"
function ignore {