Skip to content

Instantly share code, notes, and snippets.

View vivien's full-sized avatar

Vivien Didelot vivien

  • Montréal
View GitHub Profile
From 2ac63f597648408c225ea43a447363f7b913a035 Mon Sep 17 00:00:00 2001
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Wed, 6 Jun 2012 12:24:47 -0400
Subject: [PATCH] io: use system() if a command contains a pipe
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
io.c | 4 ++++
1 file changed, 4 insertions(+)
@vivien
vivien / to_hash.rb
Last active December 14, 2015 01:39
Module to mixin into a DataMapper model to add a #to_hash method returning a hash with loaded properties.
module ToHash
def to_loaded_hash
fields = properties.select { |p| p.loaded?(self) }.map(&:name)
hash = {}
fields.each { |f| hash[f] = self[f] }
hash
end
end
@vivien
vivien / twitter.rb
Last active December 27, 2015 02:08
Fetch last few tweets, unauthenticated.
# Fetch last few tweets, unauthenticated.
#
# I just want the last few tweets of a user, I really don't want to do this:
# http://stackoverflow.com/a/15314662
require 'open-uri'
require 'cgi'
require 'openssl'
module Twitter
@vivien
vivien / custom-separator-trick.conf
Created March 4, 2014 04:32
Custom separator trick for i3blocks
# We use the global settings as a shortcut to define our own separator.
# Based on the default i3blocks config file.
full_text=〉
align=center
color=#666666
separator=false
separator_block_width=7
[volume]
command=/usr/libexec/i3blocks/volume
@vivien
vivien / notify
Last active December 23, 2023 03:41
i3blocks integration with dunst
#!/bin/sh
#
# i3blocks integration with dunst.
# Author: Vivien Didelot <vivien.didelot@gmail.com>
#
# dunst caches a notification and signals i3blocks.
# i3blocks catches the signal and prints the cached notification.
#
# Put this rule at the end of your ~/.config/dunst/dunstrc:
#
@vivien
vivien / timezone.rb
Last active August 29, 2015 13:57
Script to toggle timezones in i3blocks
#!/bin/ruby
#
# Toggle timezones in i3blocks
# Author: Vivien Didelot <vivien.didelot@gmail.com>
#
# Fill the ZONES array and define a block like this:
#
# [timezone]
# command=THIS_SCRIPT
# interval=5
@vivien
vivien / weather.ca.sh
Created March 13, 2014 19:50
i3blocks script for weather in Canada
#!/bin/sh
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@vivien
vivien / imgur
Last active January 27, 2022 19:46
Shell script to upload image(s) to imgur.com
#!/bin/sh
#
# Upload image(s) to imgur.com
# Copyright (C) 2014 Vivien Didelot <vivien@didelot.org>
# Licensed under GPL version 3, see http://www.gnu.org/licenses/gpl.txt
#
# Requires "jshon":
# http://kmkeen.com/jshon/
#
# Alternatives, which suck:
@vivien
vivien / battery
Last active February 3, 2024 01:35
battery script for i3blocks
#!/usr/bin/perl
#
# Copyright 2014 Pierre Mavro <deimos@deimos.fr>
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
#
# Licensed under the terms of the GNU GPL v3, or any later version.
#
# This script is meant to use with i3blocks. It parses the output of the "acpi"
# command (often provided by a package of the same name) to read the status of
# the battery, and eventually its remaining time (to full charge or discharge).
@vivien
vivien / irccat
Created May 2, 2014 00:38
irccat - Using netcat with an IRC channel
#!/bin/sh
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# Licensed under the terms of the GNU GPL v3, or any later version.
NICK=irccat42
SERVER=irc.freenode.net
PORT=6667
CHAN="#irccat"
{