Skip to content

Instantly share code, notes, and snippets.

@SAPikachu
SAPikachu / README.md
Last active December 11, 2015 18:19
Enable / disable individual adbd service on phone

Compiling

Apply the patch to android_system_core repository (located at <android source root>/system/core for CM10), then compile as usual.

Usage

In root shell, use setprop [persist.]sys.adbse.<service name> <0/1> to toggle adb services. It will be immediately effective to new adb connections. Existing connections won't be affected.

@SAPikachu
SAPikachu / kwacros.py
Last active December 14, 2015 13:59 — forked from skyl/kwacros.py
Make {% loadkwacros %} be able to use variables and filters
#
# templatetags/kwacros.py - Support for macros in Django templates
#
# Based on snippet by
# Author: Michal Ludvig <[email protected]>
# http://www.logix.cz/michal
#
# modified for args and kwargs by Skylar Saveland http://skyl.org
#
#!/usr/bin/env python3
# Prerequisite: pypng (https://github.com/drj11/pypng)
# Issue: Converted images don't work well with \fad
# Test environment: i5-520M, 8GB memory, Radeon 5650M
# Image size: 345 x 164, more than 80% pixels are not fully transparent
# Video: H264 10bit, 1920 x 1080, ~4Mbps
# Software:
@SAPikachu
SAPikachu / custom-convert.conf
Created January 2, 2014 12:37
Logitech Media Server hack * Tracks in single-file FLAC+CUE albums can be played individually * Transcode APE to FLAC since APE support is not very good
# $Id$
#
# Configuration file for transcoding
#
# If you wish to create custom transcoding entries that won't be overwritten
# by a new release of Logitech Media Server, create a custom-convert.conf file in the
# Logitech Media Server root directory, or the root of the Plugins directory.
#
# On Debian, you can also create this file in # /etc/slimserver/custom-convert.conf
#
@SAPikachu
SAPikachu / README.md
Created January 27, 2014 02:47
OpenVPN/6in4 tunnel over IPSec (alpha)
  • Draft, very hard to configure and use
  • Don't ask me how to use it at this moment, once it matures I will move it to a repository and add instructions.
  • Remember to run ip xfrm state flush && ip xfrm policy flush after changing configuration and before re-running easy-ipsec.py
  • Requirements:
    • Linux
    • iproute2
    • dig
    • Python 2.7
  • PyCrypto
@SAPikachu
SAPikachu / gist:a2a5a572ad376288b442
Created November 14, 2014 03:45
广州电信劫持一号店请求
GET http://www.yhd.com/ HTTP/1.1
Host: www.yhd.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.7,zh-cn;q=0.3
Accept-Encoding: gzip, deflate
Cookie: abtest=56; provinceId=20; gla=20.237_0; _ga=GA1.2.84242378.1415496467; guid=PTV1EPTMGSE39YQRUWDNF8CJ4HJCZHF16WMG; tma=40580330.17223687.1415496470262.1415496470262.1415496470262.1; tmd=4.40580330.17223687.1415496470262.; wide_screen=1; search_browse_history=31087315%2C9751673; gc=93805155%2C29798229; grouponAreaId=37; uname=%E8%83%A1%E5%B9%BF%E6%98%8E; yihaodian_uid=121197816; cart_num=0; pms_cart=33841551x85081x1; __utma=40580330.84242378.1415496467.1415666972.1415666972.1; __utmz=40580330.1415666972.1.1.utmcsr=t.yhd.com|utmccn=(referral)|utmcmd=referral|utmcct=/detail/1110174
Connection: keep-alive
# User authentication method. Could be set multiple times and in that case
# all should succeed.
# Options: certificate, pam.
auth = "certificate"
#auth = "plain[passwd]"
#auth = "pam"
# The plain option requires specifying a password file which contains
# entries of the following format.
# "username:groupname:encoded-password"
@SAPikachu
SAPikachu / gist:c276860e466c36070904
Created June 8, 2015 03:52
scp performance benchmark
sapikachu@sapikachu-netbox:/tmp/memtest$ ./bench.sh
blowfish-cbc
Bytes per second: sent 42984714.6, received 7850.0
Bytes per second: sent 42957622.1, received 7874.5
Bytes per second: sent 43907095.0, received 8061.9
aes128-ctr
Bytes per second: sent 57376736.6, received 10429.3
Bytes per second: sent 57130993.1, received 10765.5
Bytes per second: sent 60852877.9, received 11334.7
aes192-ctr
@SAPikachu
SAPikachu / gist:caa7da4925d1872d95db
Created July 20, 2015 13:58
Test code for sending mail to change event in Google Calendar
#!/usr/bin/env python3
import requests
# [email protected] is the organizer, [email protected] is controlled by our app and wants to update the event
# Message body is modified from the mail sent by Google Calendar
body = """Date: Fri, 17 Jul 2015 13:23:53 +0000
Subject: Updated: RFC2446 Test @ Tue Jul 21, 2015 5pm - 6pm ([email protected])
From: [email protected]
@SAPikachu
SAPikachu / firewall-start.sh
Last active May 24, 2022 12:09
Custom guest wireless network on ASUS RT-AC68U (Merlin firmware)
#!/bin/sh
# /jffs/scripts/firewall-start
# A VM in VLAN 1111 (tagged) is plugged to port 1, it will act as router of guest network, offer DHCP, and do other filtering as necessary
# Port 5 (internal CPU port) has to be included to make it works
robocfg vlan 1111 ports "1t 5t"
# Bring up VLAN interface
ip link add link eth0 name vlan1111 type vlan id 1111