Skip to content

Instantly share code, notes, and snippets.

View riverfor's full-sized avatar

River Yan riverfor

View GitHub Profile
@riverfor
riverfor / 0_reuse_code.js
Created July 24, 2017 02:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@riverfor
riverfor / gist:dae8b85b8a657d93c5086ea207c80eb3
Created July 24, 2017 03:32
easter-egg.py for qpython ios
# -*- coding: utf-8 -*-
# Author: Rriver
# Can you send the easter egg's result to us ? : )
import urllib,re,random
qw = 'http://www.qpython.org/'
html = urllib.urlopen(qw).read()
reg = r'src="(.*?\.jpg)'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
pics = []
import socket
import fcntl
import struct
interfaces = [
b"eth0",
b"eth1",
b"eth2",
b"wlan0",
b"wlan1",
@riverfor
riverfor / Permission.java
Created July 30, 2017 06:21 — forked from droibit/Permission.java
Helper class for runtime permission of Android M
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
h1 {
text-align:center;
}
p {
background-color: rgba(255, 0, 0, 0.5);
color: white;
text-align: justify;
}
import time
from androidhelper import Android
droid = Android()
droid.startLocating()
locproviders = droid.locationProviders().result
print("locproviders:"+repr(locproviders))
gpsprovider = droid.locationProviderEnabled('gps').result
print("gpsprovider:"+repr(gpsprovider))
i = 0
import time
from androidhelper import Android
droid = Android()
ccount = droid.contactsGetCount().result
print("contacts' number:"+str(ccount))
cids = droid.contactsGetIds().result
print("contacts' list:"+str(cids))
import time
from androidhelper import Android
droid = Android()
droid.startTrackingPhoneState()
time.sleep(1)
pstate = droid.readPhoneState().result
print("phone state:"+str(pstate))
droid.stopTrackingPhoneState()
from androidhelper import Android
droid = Android()
number = droid.dialogGetInput("Phone Number", "Input the phone number you want to send hello").result
droid.smsSend(number,"hello")
from androidhelper import Android
droid = Android()
number = droid.dialogGetInput("Phone Number", "Input the phone number you want to send hello").result
droid.phoneDialNumber(number)