Skip to content

Instantly share code, notes, and snippets.

View qwIvan's full-sized avatar

yang chanfa qwIvan

View GitHub Profile
@noobnooc
noobnooc / cloudflare-worker-proxy.js
Last active August 9, 2025 14:12
cloudflare-worker-proxy
// Website you intended to retrieve for users.
const upstream = 'api.openai.com'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = upstream
// Countries and regions where you wish to suspend your service.
@fortuna
fortuna / Queries.md
Last active May 3, 2025 10:08
Grafana dashboard for Outline Servers

Example Queries

1h active keys by location:

sum(max(increase(shadowsocks_data_bytes{access_key!=""} [1h])) by (access_key, location) > bool 0) by (location)

1h usage by location:

sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"} [1h])) by (location)
@qwIvan
qwIvan / app.py
Created March 26, 2018 09:15 — forked from seanbehan/app.py
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
@seanbehan
seanbehan / app.py
Last active March 13, 2023 04:55
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
/**
* For Google Voice
* @Author zbinlin <[email protected]>
*/
var sleep = delay => new Promise(resolve => setTimeout(resolve, delay));
var composeClick = function x(btn) {
var rect = btn.getBoundingClientRect();
var x = Math.floor(rect.clientX + rect.width * Math.random());
var y = Math.floor(rect.clientY + rect.height * Math.random());
@tniessen
tniessen / service.md
Created October 1, 2016 11:46
Using the "service" tool with ADB and why to avoid it

As it turns out, it is not trivial to control the audio volume of an Android device using ADB. At the time of writing, the only way appears to be using the service tool. Actually, the service command allows to "connect" to a number of services (104 on Android 6.0.1) and invoke functions. Not knowing much about this tool, I managed to completely mute all sounds and speakers of my Nexus 5, and I was stuck without any sound for quite some time. I did not find a way to unmute the sound from within the system UI, so I got to dive a little deeper into this.

If you know which service you want to use, you then need to find its interface declaration. The command

service list

gives you a list of all services with the associated interfaces, if applicable:

...

26 backup: [android.app.backup.IBackupManager]

@zmwangx
zmwangx / qqvdl
Last active June 8, 2019 08:47
v.qq.com SHD downloader (腾讯超清视频下载) https://github.com/soimort/you-get/issues/1298#issuecomment-236489420
#!/usr/bin/env zsh
print_progress () print -R $'\e[32m'"$*"$'\e[0m' >&2
print_error () print -R $'\e[31m'"Error: $*"$'\e[0m' >&2
# Obvious parameters
vid=f00213kcpwl
defn=shd
# To be extracted from browser's network inspector
@qwIvan
qwIvan / web-servers.md
Created April 23, 2016 18:10 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@GitaiQAQ
GitaiQAQ / PhuckQQ.md
Created March 2, 2016 12:53
a xposed module for QQbot
  private void a1405(final XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException,NoSuchFieldException,IllegalAccessException{
      String className = "com.tencent.mobileqq.activity.ChatActivity";
      String methodName = "a";

      Class<?> message = lpparam.classLoader.loadClass("com.tencent.mobileqq.app.message.QQMessageFacade$Message");

      XposedBridge.log("Hooking a(QQMessageFacade$Message qQMessageFacade$Message)[1405]");

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o