Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Shih-Yuan Lee (FourDollars) fourdollars

🏠
Working from home
Block or report user

Report or block fourdollars

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fourdollars
fourdollars / brightness.stap
Created Jan 29, 2019
Using SystemTap to check the brightness level changes.
View brightness.stap
#!/usr/bin/env stap
probe module("video").function("acpi_video_device_lcd_set_level").call
{
printf ("%s -> %s\n", thread_indent(1), probefunc())
printf ("\t %s args [%s]\n", probefunc(), $$parms)
}
@fourdollars
fourdollars / .abcde.conf
Last active Oct 4, 2018
sudo apt install abcde cd-discid lame cdparanoia id3 id3v2 eyed3
View .abcde.conf
# System defaults for abcde version 2.8.1
# Nothing in this file is uncommented by default.
#
# If you wish to override these system-wide settings, create your own
# .abcde.conf file in your home directory.
# CDDB options
# Choose whether you want to use "cddb" and/or "musicbrainz". Default
# is "musicbrainz", but both can be specified in a comma delimited list
# to be tried sequentially in the event of failure of the first
View grub.cfg
function load_efi_video {
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
}
function load_video {
set gfxmode=auto
View grub.cfg
function load_efi_video {
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
}
function load_video {
set gfxmode=auto
View components.js
class MachineBox extends React.Component {
render(){
return ( <div>Hello From React </div> );
}
}
let target = document.getElementById('machine-box');
ReactDOM.render(
<MachineBox />, target
@fourdollars
fourdollars / num.sh
Last active Nov 23, 2016
Print numbers in sequence without repeated digits. https://www.ptt.cc/bbs/Programming/M.1479904715.A.DD6.html
View num.sh
#! /usr/bin/env bash
read -p 'Enter a number : ' num
seq $((10**num)) | egrep -v "([0-9]).*\1" | xargs echo | sed 's/ /, /g'
View location.py
#!/usr/bin/python3
import random, re
collection = ('A1-1', 'A1-2', 'A1-3', 'A1-4', 'A1-5', 'A1-6', 'A1-7', 'A1-8', 'A1-9', 'A1-10', 'A1-11', 'A1-12', 'A1-13', 'A1-14', 'A2-1', 'A2-3', 'A2-4', 'A2-5', 'A2-6', 'A2-7', 'A2-8', 'A2-9', 'A2-10', 'A2-11', 'A2-12', 'A2-13', 'A2-14', 'A3-1', 'B1-3', 'B1-4', 'B1-5', 'B1-6', 'B1-7', 'B1-8', 'B1-9', 'B1-10', 'B1-11', 'B1-12', 'B2-3', 'B2-4', 'B2-5', 'B2-6', 'B2-7', 'B2-8', 'B2-9', 'B2-10', 'B2-11', 'B2-12')
print('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>機車腳踏車車位選填志願抽籤結果</title>')
print('''<style>
table {border: 0; border-collapse: collapse; width: 100%; table-layout: fixed;}
td,th {border: 1px solid black;}
View forin.js
var scores = [98, 74, 85, 77, 93, 100, 89];
var total = 0;
for (var score in scores) {
total += score;
}
var mean = total / scores.length;
console.log(mean);
@fourdollars
fourdollars / game.js
Last active Dec 19, 2015
An example from Effective JavaScript
View game.js
function Scene(context, width, height, images) {
this.context = context;
this.width = width;
this.height = height;
this.images = images;
this.actors = [];
}
Scene.prototype.register = function(actor) {
this.actors.push(actor);
View range.py
#! /usr/bin/env python3
def find_duplicate(vbt_min, pwm_max):
prev = -1
pwm_min = round(vbt_min * pwm_max / 255)
print("sysfs : PWM")
print("-----------")
for i in range(pwm_max + 1):
pwm = round(i * (pwm_max - pwm_min) / pwm_max + pwm_min)
if prev == pwm:
You can’t perform that action at this time.