Skip to content

Instantly share code, notes, and snippets.

View pjq's full-sized avatar

Jianqing Peng pjq

View GitHub Profile
@pjq
pjq / gist:80fb9444a623b9540b0a48a14f202a41
Created April 27, 2024 15:06
Cloudflare ddns update shell script
#!/bin/bash
# CHANGE THESE
auth_email="[email protected]"
auth_key="xxxxxxxx" # found in cloudflare account settings
zone_name="xxxxx"
sub_domains=("sub1" "sub2")
zone_id="your_zone_id"
# MAYBE CHANGE THESE
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@pjq
pjq / TestActivity.kt
Created October 14, 2023 10:04 — forked from StelianMorariu/TestActivity.kt
Rudimentary MotionLayout collapsible toolbar
/*
* Copyright © 2019 Stelian Morariu. All rights reserved.
*/
package com.stelianmorariu.antrics
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class TestActivity : AppCompatActivity() {
@pjq
pjq / sys_proxy
Created September 17, 2018 04:06 — forked from jsfaint/sys_proxy
Set System Proxy for OS X
#!/bin/bash
wifi="Wi-Fi"
IP=127.0.0.1
PORT=7777
[[ $# -ne 1 ]] && echo "$0 http|pac|disable" && exit 1
flag=$1
function webproxy_set() {
@pjq
pjq / GagSsl.java
Created July 18, 2017 02:09 — forked from mefarazath/GagSsl.java
Get OkHttpClient which ignores all SSL errors.
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
}
@pjq
pjq / bluetooth-a2dp
Created April 17, 2017 02:14 — forked from ragusa87/bluetooth-a2dp
Enable bluetooth A2DP on Raspberry-PI via pulseaudio. To install, edit /etc/udev/rules.d/99-input.rules and add the line: SUBSYSTEM=="bluetooth", RUN+="/usr/lib/udev/bluetooth" Then save this script as /usr/lib/udev/bluetooth and set it executable. Bluetooth devices must be linked first.
#!/bin/bash
# This script is called by udev when you link a bluetooth device with your computer
# It's called to add or remove the device from pulseaudio
#
#
# Output to this file
LOGFILE="/var/log/bluetooth_dev"
# Name of the local sink in this computer
@pjq
pjq / pmspi.py
Created February 24, 2017 16:32 — forked from lackofdream/pmspi.py
Raspberry Pi and PMS5003
import serial
import datetime
from pymongo import MongoClient
port = serial.Serial('/dev/ttyAMA0', baudrate=9600, timeout=2.0)
client = MongoClient('172.31.150.230')
def read_pm_line(_port):
rv = b''
@pjq
pjq / Connectivity.java
Created March 14, 2016 02:58 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
package com.emil.android.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* Check device's network connectivity and speed
* @author emil http://stackoverflow.com/users/220710/emil
@pjq
pjq / introrx.md
Last active August 27, 2015 02:53 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@pjq
pjq / markdown.css
Last active August 29, 2015 14:21 — forked from imjasonh/markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}