Skip to content

Instantly share code, notes, and snippets.

View xcaptain's full-sized avatar

Joey xcaptain

View GitHub Profile
@xcaptain
xcaptain / machine_represent.c
Created July 28, 2018 03:33
represent a variable in machine code
#include <stdio.h>
typedef unsigned char* byte_pointer;
void show_bytes(byte_pointer start, size_t len) {
size_t i;
for (i = 0; i < len; i++) {
printf("%.2x", start[i]);
}
printf("\n");
@xcaptain
xcaptain / js_to_php.php
Created June 27, 2018 10:52
破解网页js加密,把js语法转为php语法 http://www.lzkan.com/k/212509/61798041.html 中的fid
<?php
function transform($s)
{
$s0 = preg_replace('#String#', 'strval', $s);
$s1 = preg_replace('#!!\[\]#', 1, $s0);
$s2 = preg_replace('#!\[\]#', 0, $s1);
$s3 = preg_replace('#\[\]#', 0, $s2);
$s4 = preg_replace('#\)\)\)\+\(\(#', '))).((', $s3);
$s5 = preg_replace('#\)\)\+\(#', ')).(', $s4);
@xcaptain
xcaptain / binary_tree.py
Created June 24, 2018 16:12
binary tree in python
# python binary tree
class BinaryNode:
def __init__(self, value = None):
self.value = value
self.left = None
self.right = None
def add(self, val):
if val <= self.value:
if not self.left: # 左子树为空,直接设置左子树
@xcaptain
xcaptain / deploy.php
Created June 22, 2018 02:55
用rsync的方式配置deployer实现代码部署
<?php
namespace Deployer;
require 'recipe/rsync.php';
set('rsync', [
'exclude' => [
'.env',
'.git/',
'.gitignore',
@xcaptain
xcaptain / redpacket_gen.py
Created May 5, 2018 08:55
正态分布红包生成算法
import numpy as np
from scipy.stats import truncnorm
import matplotlib.pyplot as plt
class RedpacketPolicy:
def __init__(self):
self.sd = 80
self.miss = 0.1
def gen(self, amount, total):
@xcaptain
xcaptain / pusher_test.mjs
Last active January 11, 2018 12:09
pusher test
import Pusher from "pusher-js";
import axios from 'axios';
// online token
const jwtToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiAF7vaVJ0P4s';
const pusher = new Pusher("f38f86445b8c318d6ac1", {
authEndpoint: "http://21ji.wanuq.com/pusher/auth",
authTransport: "ajax",
auth: {
headers: {
@xcaptain
xcaptain / README-Template.md
Created December 31, 2017 05:48 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@xcaptain
xcaptain / dianping_downloader.ts
Created November 12, 2017 10:15
用typescript+puppeteer写的点评网页下载脚本
import * as puppeteer from 'puppeteer';
import * as fs from 'fs';
/**
* 使用typescript实现一个点评页面爬虫
*/
class DianpingDownloader {
private urls;
/**
@xcaptain
xcaptain / typescript_axios_async_request.ts
Created November 6, 2017 16:39
使用typescript + axios异步发送请求
import axios from 'axios';
async function getBaidu() {
return axios.get('http://www.baidu.com');
}
async function getBing() {
return axios.get('http://www.guazi.com');
}
@xcaptain
xcaptain / .php_cs
Created October 14, 2017 10:47
php-cs-fixer config
<?php
$excluded_folders = [
'node_modules',
'storage',
'vendor',
'bootstrap/cache',
];
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude($excluded_folders)