Skip to content

Instantly share code, notes, and snippets.

View activeliang's full-sized avatar
🏠
Working from home

activeliang activeliang

🏠
Working from home
View GitHub Profile
@activeliang
activeliang / socket.rb
Created May 10, 2020 15:22 — forked from Hersha-Snips/socket.rb
Ruby: Simple TCP Server
require 'socket' # Sockets are in standard library
server = TCPServer.new(1234)
begin
while connection = server.accept
while line = connection.gets
break if line =~ /quit/
puts line
connection.puts "Received!\n"
end
@activeliang
activeliang / em.rb
Created May 14, 2020 07:08 — forked from khash/em.rb
eventmachine daemon start method
@pid_full = '/tmp/my_daemon.pid'
def run
EM.run{
Signal.trap('INT') { stop }
Signal.trap('TERM'){ stop }
# your daemon code runs here. This will not exit since it is running in EM
}
end
@activeliang
activeliang / sidekiq.service
Created July 25, 2020 01:47 — forked from mkhuda/sidekiq.service
Sidekiq service auto start for Ubuntu 16.04 using Systemd
#
# Sidekiq auto start using systemd unit file for Ubuntu 16.04
#
# Put this in /lib/systemd/system (Ubuntu).
# Run:
# 1. systemctl enable sidekiq (to enable sidekiq service)
# 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service)
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
@activeliang
activeliang / puppeteer-bot.js
Created September 18, 2020 10:31 — forked from nicoandmee/puppeteer-bot.js
disguisePage - undetectable puppeteer
const WEBGL_RENDERERS = ['ANGLE (NVIDIA Quadro 2000M Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (NVIDIA Quadro K420 Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (NVIDIA Quadro 2000M Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (NVIDIA Quadro K2000M Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (ATI Radeon HD 3800 Series Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (AMD Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics Family Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics 4000 Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Intel(R) HD Graphics 3000 Direct3D9Ex vs_3_0 ps_3_0)', 'ANGLE (Mobile Intel(R) 4 Seri
@activeliang
activeliang / SplashActivity.java
Created September 28, 2020 12:20 — forked from jiangecho/SplashActivity.java
simulate user clicks on the content of webview
int X_MAX = 412;
int Y_MAX = 50;
int x, y;
x = random.nextInt(X_MAX);
y = random.nextInt(Y_MAX);
// String htmlEventJs = "var ev = document.createEvent(\"HTMLEvents\"); " +
// "var el = document.elementFromPoint(%d,%d); " +
// "ev.initEvent('click',true,true);" +
// " el.dispatchEvent(ev);";
@activeliang
activeliang / ProxyUtils.java
Created September 30, 2020 18:38 — forked from mcxiaoke/ProxyUtils.java
set proxy for Android WebView, worked on api 9 ~ 19
package com.mcxiaoke.next.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Proxy;
import android.os.Build;
import android.os.Parcelable;
import android.util.ArrayMap;
import android.util.Log;