Skip to content

Instantly share code, notes, and snippets.

@fcwu
fcwu / hello.py
Created June 17, 2013 03:34
python, gtk 3 and CSS
#!/usr/bin/python3
from gi.repository import Gtk, Gdk
import sys
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Hello World")
self.set_name('MyWindow')
@fcwu
fcwu / power.sh
Created June 27, 2013 08:47
Linux power statistics
#!/bin/sh
echo "current average capacity full_capacity time_left"
factor=0.7
last_pwr=0
charge_full=`cat /sys/class/power_supply/BAT0/charge_full`
voltage_min_design=`cat /sys/class/power_supply/BAT0/voltage_min_design`
full_pwr=`echo "scale=5; $charge_full * $voltage_min_design / 1000000 / 1000000" | bc`
while [ 1 ]; do
voltage_now=`cat /sys/class/power_supply/BAT0/voltage_now`
@fcwu
fcwu / go.mod
Created April 30, 2020 23:26
go-systemd example
module example.com
replace github.com/coreos/go-systemd => github.com/coreos/go-systemd/v22 v22.0.0
go 1.13
require github.com/coreos/go-systemd v0.0.0-00010101000000-000000000000 // indirect

a.go

package main

/*
#include <stdio.h>
char __attribute__((section(".signature"))) signature[40] ;
int helloFromC() {
        printf("hello from C\n");
#!/bin/sh
if [ `id -u` != "0" ]; then
echo You have to run with root user
exit 1
fi
cat <<EOF | tee /etc/systemd/user/x11vnc-password.service
[Unit]
Description=x11vnc password
@fcwu
fcwu / supertrace.py
Last active November 6, 2016 13:24
#!/usr/bin/python
import gdb
INDENT = ' '
class SuperTrace(gdb.Command):
old_stack = []
def __init__(self):
set pagination off
b main
r
python
sys.path.insert(0, './')
import supertrace
end
#!/bin/bash
# Local Network
NETWORK=192.168.16.0
GW=192.168.16.1
# Server IP Address
SERVER=123.123.123.123
# Server 對外的 Interface
SERVER_IF=eth0
#!/bin/bash
# Before script...
# $ mkdir src
# $ amd-driver-installer-<version>-x86.x86_64.run --extract src
# $ cd src
# $ ./packages/Ubuntu/ati-packager.sh --buildpkg source
# change this script modalias 6600 to your graphic card
#
# run this script
#
@fcwu
fcwu / facebook_login.js
Created October 21, 2013 16:20
Quick login button for facebook via greasemonkey
// ==UserScript==
// @name facebook login
// @namespace http://123.123
// @include https://www.facebook.com/*
// @version 1
// @require http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.2.js
// @require http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js
// @resource bt http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css
// @resource bt-theme http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css
// @grant GM_addStyle