Skip to content

Instantly share code, notes, and snippets.

View WangYihang's full-sized avatar
🎯
Focusing

Yihang Wang WangYihang

🎯
Focusing
View GitHub Profile
import math
import random
import matplotlib.pyplot as plt
def generate_candidates(M):
r = list(range(M))
random.shuffle(r)
return r
def percent_n_in_m_rule(N, M):
@WangYihang
WangYihang / root-of-an-equation.scm
Last active January 22, 2022 16:58
Structure and Interpretation of Computer Programs - Section 1.3.3 Procedures as General Methods
; Calculate the root of an equation using numerical computation
; (scheme is hard to write :(
; 2022-01-23
; Yihang Wang <wangyihanger@gmail.com>
(define (same-sign? a b) (or (and (>= a 0) (>= b 0)) (and (<= a 0) (<= b 0))))
(define (average a b) (/ (+ a b) 2))
(define (abs x) (cond
((< x 0) (- x))
((= x 0) 0)
upstream jupyter-notebook {
server localhost:8888;
}
server{
listen 8080;
server_name notebook.example.com;
location / {
proxy_pass http://jupyter-notebook;
'''
Solution for XOR challenge (http://scz.617.cn:8/misc/202007101723.txt)
'''
from termcolor import colored
from colorama import init
import string
import math
import shlex
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
from sys import version
import semver
import requests
import itertools
from bs4 import BeautifulSoup
def md5(data):
if type(data) is str:
data = bytes(data, encoding='utf-8')
return __import__('hashlib').md5(data).hexdigest()
@WangYihang
WangYihang / brainfuck.c
Last active September 5, 2021 13:01
BrainFuck Interpreter in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/**
* BrainFuck Interpreter in C [1-2]
* Wang Yihang <wangyihanger@gmail.com>
*
* == Run
from __future__ import print_function
import frida
import sys
device = frida.get_device_manager().add_remote_device('127.0.0.1:27042')
session = device.attach(int(sys.argv[1]))
code = '''
Interceptor.attach(Module.findExportByName("libssl-ws.so", "tls1_setup_key_block"), {
onEnter: function(args) {
import random
def solve():
'''
area of unit circle at (0.5, 0.5) = pi * (0.5 ^ 2)
area of unit trangle at (0.5, 0.5) = 1 * 1
the ratio of the number of points that fall in the circle to the number
of all points will approximate the ratio of the area of the circle to
the area of the entire square.
'''

Keybase proof

I hereby claim:

  • I am wangyihang on github.
  • I am wangyihang (https://keybase.io/wangyihang) on keybase.
  • I have a public key ASAgocxodMp98MAOht9nFCua-961GQ0TSG_HjU7IceBnsAo

To claim this, I am signing this object: