Skip to content

Instantly share code, notes, and snippets.

@antonylu
antonylu / rotate_desktop.sh
Created April 13, 2018 05:43 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@antonylu
antonylu / shm.c
Created April 13, 2018 06:34
Wayland shm example
/*
* Wayland shm example
* Based on https://jan.newmarch.name/Wayland/SharedMemory/
* Build: gcc -o shm shm.c -lwayland-client -lpthread
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wayland-client.h>
@antonylu
antonylu / rfc6749.md
Last active April 18, 2018 06:54
The OAuth 2.0 Authorization Framework
Internet Engineering Task Force (IETF)                     D. Hardt, Ed.
Request for Comments: 6749                                     Microsoft
Obsoletes: 5849                                             October 2012
Category: Standards Track
ISSN: 2070-1721

The OAuth 2.0 Authorization Framework

Abstract

@antonylu
antonylu / markdown.md
Last active April 18, 2018 08:23
Markdown 語法

Markdown語法主要分為如下幾大部分:

標題

段落

區塊引用

代碼區塊

強調

列表

分割線

鏈接

圖片

@antonylu
antonylu / maxLeftRight.py
Created May 12, 2018 04:11
Brute force solution for maximum sum of left/right continuous cells in a list
class Solution(object):
def maxLeftRight(self, lst, L, R):
"""
:type lst: list of Non-negative int
:type L: int
:type R: int
:rtype: int
"""
# Approach #1, brute force, enumerate all possible cases and keep the maximum
maxi = 0
@antonylu
antonylu / pad38.py
Created May 22, 2018 03:23
pad-38 test script
import os,time,signal
loop = True
def stop_all(*args):
global loop
loop = False
if __name__ == '__main__':
signal.signal(signal.SIGTERM, stop_all)
signal.signal(signal.SIGABRT, stop_all)
@antonylu
antonylu / NFC_AndroidO.md
Last active August 27, 2018 07:55
Android patches for support of PN7150 NCI based NXP NFC Controller in Android Oreo

nxpnfc_android_oreo

Repository containing the files allowing to patch 8.1.0 Oreo version of AOSP source in order to add support for PN7150 NXP-NCI NFC controller to an Android based system, can be found on CodeAurora: https://source.codeaurora.org/external/nfcncisw/nxpnfc_android_oreo

Information about NXP NFC Controller can be found on NXP website.

Further details about the stack and integration guidelines here.

@antonylu
antonylu / volume.cs
Created September 11, 2018 08:43
Change Audio Volume, Mute, Unmute on Windows
// 宣告常式
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int APPCOMMAND_VOLUME_UP = 0x0a0000;
private const int APPCOMMAND_VOLUME_DOWN = 0x090000;
private const int WM_APPCOMMAND = 0x319;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
private void btnVup_Click(object sender, EventArgs e)
@antonylu
antonylu / property_set.c
Created October 2, 2018 02:05
An example of property_set() usage of native application in C
#include <cutils/properties.h>
int main(int ac, char **av )
{
char *percentage = "100";
if(property_set("persist.bios.percent", percentage))
fprintf(stderr,"could not set property\n");
}
@antonylu
antonylu / remove_ansi.py
Created October 29, 2018 01:35
A Python script which removes all ANSI escape code from standard input
"""
Remove ansi escape code, for example, '\033[0m'
Usage:
type in_ansi.txt | remove_ansi.py > out_no_ansi.txt
cat in_ansi.txt | remove_ansi.py > out_no_ansi.txt
"""
import re, sys
ansi_escape =re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')