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
#!/bin/sh
strip_spaces () {
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/ \+/ /g;s/^ *//g;s/ *$//g")
}
remove_parameters () {
for i in "$@"; do
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/$i//g")
done
@fourdollars
fourdollars / HowFastOfUbuntu.py
Created July 3, 2015 11:17
A simple fullscreen video player by clutter-gst.
#!/usr/bin/env python3
from gi.repository import Clutter, ClutterGst, Gdk
class VideoPlayer:
def __init__(self, filename):
stage_color = Clutter.Color.new(0, 0, 0, 0)
screen = Gdk.Screen.get_default()
monitor = screen.get_primary_monitor()
@fourdollars
fourdollars / wodim-iso.py
Last active August 29, 2015 14:24
A simple program to burn DVD ISO by wodim with the minimum write speed. For example: ./wodim-iso.py /dev/sr0 ubuntu.iso
#! /usr/bin/env python3
#
# Copyright (C) 2015 Canonical Limited
# Author: Shih-Yuan Lee (FourDollars) <sylee@canonical.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.
#
/* Cascaded function calls in C */
#include <stdio.h>
#include <stdlib.h>
typedef struct Object Object;
struct Object {
Object* (*foo)(Object*);
};
@fourdollars
fourdollars / fourdollars.vim
Created December 17, 2009 14:19
fourdollars.vim
syntax on
set fileencodings=utf-8,big5,ucs-bom,iso8859-1
set termencoding=utf-8
set encoding=utf-8
set shiftwidth=4
set tabstop=4
set expandtab
set nocompatible
set hlsearch
$(function() {
var num = Math.round(Math.random(new Date()) * 46) % 46;
if (num < 26) {
num = num + 65;
} else {
num = num % 26;
num = num + 97;
}
alert(String.fromCharCode(num));
});
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# generate json data from txt file
import re
def main():
words = []
file = open("words.txt")
while True:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import curses
import time
import sys
def main(curses):
pad = curses.newpad(100, 100)
for y in range(0, 100):
" cursor highlight
set cursorline
highlight CursorLine cterm=NONE ctermbg=Black
autocmd InsertEnter * set nocursorline
autocmd InsertLeave * set cursorline
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 2.6.24-26-generic (buildd@vernadsky) (gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)) #1 SMP Tue Dec 1 18:37:31 UTC 2009 (Ubuntu 2.6.24-26.64-generic)
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
[ 0.000000] BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
[ 0.000000] BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[ 0.000000] BIOS-e820: 0000000000100000 - 000000009fff0000 (usable)
[ 0.000000] BIOS-e820: 000000009fff0000 - 000000009fff3000 (ACPI NVS)
[ 0.000000] BIOS-e820: 000000009fff3000 - 00000000a0000000 (ACPI data)