Skip to content

Instantly share code, notes, and snippets.

View fourdollars's full-sized avatar
🏠
Working from home

Shih-Yuan Lee (FourDollars) fourdollars

🏠
Working from home
View GitHub Profile
#! /usr/bin/env python3
from gi.repository import GLib, UDisks
no_options = GLib.Variant('a{sv}', {})
udisks = UDisks.Client.new_sync(None)
manager = udisks.get_object_manager()
for item in manager.get_objects():
part = item.get_partition()
@fourdollars
fourdollars / install_pkgs.sh
Created May 12, 2014 09:17
Install some Debian packages.
#!/bin/sh
sudo apt-get update
sudo apt-get install --yes bash-completion devscripts exuberant-ctags ubuntu-dev-tools vim vim-addon-manager vim-scripts
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Set fonts selection order for Chinese users -->
<match target="pattern">
<test qual="any" name="family">
<string>serif</string>
</test>
<test name="lang">
@fourdollars
fourdollars / .bash_aliases
Created November 29, 2013 03:40
A little script to launch ssh-agent automatically.
#!/bin/sh
if [ -f "$HOME/.ssh-agent" ]; then
. "$HOME/.ssh-agent"
fi
PID="$(pidof ssh-agent)"
if [ -z "$PID" -o "$PID" != "$SSH_AGENT_PID" ]; then
if [ -n "$PID" ]; then
@fourdollars
fourdollars / grab-x11.c
Created November 27, 2013 06:00
A simple program to grab virtual core keyboard & pointer for 3 seconds.
/* -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- */
/**
* Copyright (C) 2013 Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
*
* 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,
@fourdollars
fourdollars / bt-debug.sh
Last active December 22, 2015 10:29
A little script to debug Bluetooth issue.
#!/bin/bash
# -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2; -*-
# vim:fileencodings=utf-8:expandtab:tabstop=2:shiftwidth=2:softtabstop=2
#
# Copyright (C) 2013 Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
#
# 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.
@fourdollars
fourdollars / hello.c
Created September 3, 2013 08:52
A simple program to print 'Hello World' in Chinese.
#include <glib.h>
#include <locale.h>
// gcc -Wall -Werror -g hello.c `pkg-config --cflags --libs glib-2.0` -o hello
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "en_US.utf8");
g_print ("哈囉世界\n");
return 0;
@fourdollars
fourdollars / udev-bluetooth-power_supply.c
Created September 2, 2013 07:39
A example by gudev to list if the power_supply is from bluetooth or not.
/* -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- */
/**
* Copyright (C) 2013 Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
*
* 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,
@fourdollars
fourdollars / launchpad.ls
Last active February 10, 2017 10:42
A little LiveScript to get personal information from https://launchpad.net.
#!/usr/bin/env lsc
require! fs
require! request
require! prompt
{map} = require \prelude-ls
{spawn} = require \child_process
oauth_consumer_key = 'node script'
@fourdollars
fourdollars / coscup-2013-speakers.ls
Created July 21, 2013 06:54
A little script to parse Email from Registrano's CSV output.
#!/usr/bin/env lsc
require! csv
require! fs
speakers = []
csv!
.from.stream fs.createReadStream __dirname + \/coscup2013-cfp.csv, do
delimiter: \,