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 / .abcde.conf
Last active October 4, 2018 00:32
sudo apt install abcde cd-discid lame cdparanoia id3 id3v2 eyed3
# 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
function load_efi_video {
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
}
function load_video {
set gfxmode=auto
function load_efi_video {
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
}
function load_video {
set gfxmode=auto
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 November 23, 2016 12:42
Print numbers in sequence without repeated digits. https://www.ptt.cc/bbs/Programming/M.1479904715.A.DD6.html
#! /usr/bin/env bash
read -p 'Enter a number : ' num
seq $((10**num)) | egrep -v "([0-9]).*\1" | xargs echo | sed 's/ /, /g'
#!/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;}
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 December 19, 2015 10:52
An example from Effective JavaScript
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);
#! /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:
@fourdollars
fourdollars / list.sh
Last active November 2, 2015 07:31
Please replace [...] with your code snippets. This script will be used in busybox to find out the partitions by following the specific order.
#!/bin/sh
PARTITIONS="/dev/mmcblk0p1 /dev/mmcblk1p1 /dev/nvm0n1p1 /dev/nvm0n2p1 /dev/sda1 /dev/sdb1"
DEVICES="/dev/sdb /dev/nvm0n2 /dev/nvm0n1 /dev/mmcblk0"
result=""
[...] # can not use PARTITIONS here
for partition in $PARTITIONS; do