Skip to content

Instantly share code, notes, and snippets.

@zhangyoufu
zhangyoufu / cache.c
Last active August 29, 2015 14:26
ARM d-cache
#include <stdio.h>
unsigned char shellcode[] = {
0x4f, 0xf0, 0x00, 0x00,
0xf0, 0x47,
};
int main()
{
shellcode[2] = 0x01;
@zhangyoufu
zhangyoufu / gist:09a0122f8d78249dff1a
Created August 17, 2015 09:10
Debian/Ubuntu Package, top level dependency (cannot detect dependency loop)
dpkg-query -W | cut -f1 | xargs apt-cache rdepends --installed | python2.7 -c 'import re,sys;sys.stdout.write(re.sub(".*\nReverse Depends:\n( [ |].*\n)+","",sys.stdin.read()).replace("Reverse Depends:\n",""))'
@zhangyoufu
zhangyoufu / gdbserver.sh
Created November 6, 2015 16:41
gdb remote debugging android, w/o tcp forwarding
#!/bin/bash
# Usage:
# (gdb) target extended-remote | ./gdbserver.sh
(echo 'stty raw -echo; exec gdbserver --multi - 2>/dev/nul'; cat) | adb shell | stdbuf -o0 dos2unix | (read -r; read -r; cat)
@zhangyoufu
zhangyoufu / 99simple-vhost.conf
Last active April 14, 2016 02:31
bring lighttpd mod_simple_vhost to nginx
# for test purpose only, do not use in production
# inspired by http://blog.pkh.me/p/4-simple_vhost-with-nginx.html
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name default;
server_name_in_redirect off;
set $vpath /srv/_vhost/$host;
@zhangyoufu
zhangyoufu / chromium.gyp_env
Created June 22, 2016 06:26
enable Widevine CDM for Chromium (tested on 51.0.2704.103)
{
'GYP_DEFINES': 'ffmpeg_branding=Chrome proprietary_codecs=1 enable_widevine=1'
}
(lldb) p g_key_systems.Pointer()
(media::KeySystemsImpl *) $3 = 0x00000001222553b0
(lldb) p *$3
(media::KeySystemsImpl) $4 = {
key_system_map_ = size=2 {
[0] = {
__cc = {
first = "org.w3.clearkey"
second = {
key_system = "org.w3.clearkey"
@zhangyoufu
zhangyoufu / D.py
Last active October 17, 2016 20:14
Google APAC 2016 Round E Problem D, Sums of Sums (aka APAC 2017 Practice Round Problem D)
#!/usr/bin/env python2
# Ref: https://www.quora.com/How-can-problem-D-Sums-of-sums-from-Round-E-of-the-Google-APAC-Test-2016-be-solved-for-the-large-dataset
import multiprocessing
get_int = lambda: int( raw_input() )
get_multi_int = lambda: map( int, raw_input().strip().split() )
def binary_search( x, f, lo, hi ):
'''\
@zhangyoufu
zhangyoufu / xiaomi_mobile_numbers.py
Created August 27, 2016 07:30
小米移动选号辅助
# coding: utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import json
import requests
import time
@zhangyoufu
zhangyoufu / fintek.txt
Created December 5, 2016 06:16
Fintek SuperIO Chip, Vendor ID, Chip ID
http://www.hardwaresecrets.com/datasheets/F81865_V028P.pdf
F81865 0x3419, 0x0307
http://pdf1.alldatasheet.com/datasheet-pdf/view/257912/FINTEK/F71882.html
https://www.scribd.com/document/121452631/fintek-F71882F-datasheet
F71882 0x3419, 0x4105
http://pdf1.alldatasheet.com/datasheet-pdf/view/459084/FINTEK/F81866A.html
F81866A 0x3419, 0x1010
#!/usr/bin/env python3
import datetime
import requests
last = '20170807'
fmt = '%Y%m%d'
date = datetime.datetime.strptime(last, fmt).date()
today = datetime.date.today()
session = requests.Session()
while date < today: