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
@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) <[email protected]>
*
* 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: \,
@fourdollars
fourdollars / launchpad-oauth-token.sh
Last active August 1, 2018 21:22
A simple shell script to get OAuth tokens from https://launchpad.net/ .
#!/bin/sh
oauth_consumer_key='just+testing'
for x in $(wget -q --post-data "oauth_consumer_key=$oauth_consumer_key&oauth_signature_method=PLAINTEXT&oauth_signature=%26" https://launchpad.net/+request-token -O - | sed 's/&/ /g'); do
case "$x" in
(oauth_token=*)
oauth_token="${x#*=}"
;;
(oauth_token_secret=*)
@fourdollars
fourdollars / launchpad_me.ls
Created July 17, 2013 05:58
A simple NodeJS server made by ExpressJS and node-request that uses https://help.launchpad.net/API/SigningRequests to get personal information from https://launchpad.net/ .
#!/usr/bin/env lsc
require! express
require! request
app = express!
oauth_consumer_key = 'just+testing'
var oauth_token
var oauth_token_secret
express = require \express
app = express!
app.use require(\connect-compiler) do
enabled: <[ livescript ]>
src: 'assets'
dest: 'assets'
@fourdollars
fourdollars / modaliases.sh
Created June 14, 2013 05:10
A little script using busybox to extract all pci and usb modaliases strings and generate JSON request to some server.
#!/bin/busybox sh
JSON="$(echo '{"modalias":['; find /sys -name modalias -exec cat {} \; 2>/dev/null | grep -e '^\(pci\|usb\)' | sort | sed 's/^/"/' | sed 's/$/",/\'; busybox echo -n ']}')" # Find all pci/usb modaliases.
JSON="$(echo $JSON | sed 's/, ]}/]}/' | sed 's/\s\+//g')" # Remove trailing comma and white-space characters.
wget -q --header 'content-type: application/json' --post-data "$JSON" http://localhost:8000 -O -
require! 'http'
url = 'http://ppa.launchpad.net/fourdollars/fglrx/ubuntu/dists/oneiric/main/binary-amd64/Packages'
parse = (data) ->
lines = data.split "\n"
for line in lines
if line.match /^Package/
pkg = line.split /\s+/ .[1]
else if line.match /^Version/
@fourdollars
fourdollars / dkms.sh
Last active January 23, 2017 09:09
Deprecated
https://github.com/fourdollars/scripts/blob/master/ubuntu/dkms-helper.sh