Skip to content

Instantly share code, notes, and snippets.

View chuanxd's full-sized avatar

Timmy Chang chuanxd

View GitHub Profile
@chuanxd
chuanxd / axios.refresh_token.js
Created May 12, 2020 09:00 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@chuanxd
chuanxd / curl.md
Created October 25, 2018 15:26 — forked from UnableRegister/curl.md
curl #curl

CURL

查看网页源码

curl url

保存

  • curl -o [文件名] url

自动跳转

curl -L url

@chuanxd
chuanxd / sniff.txt
Created October 23, 2018 19:25 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n
@chuanxd
chuanxd / bash_curl_loop
Created October 23, 2018 19:07 — forked from ceme/bash_curl_loop
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done
@chuanxd
chuanxd / gist:6141c28f74a667f6c5770ffbff481ecc
Created May 26, 2018 10:02 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@chuanxd
chuanxd / scapeCostco.js
Created October 17, 2017 00:52 — forked from clonn/scapeCostco.js
擷取 costco 商品資料,如果商品沒有貨, result 的結果會是已售完
var request = require('request');
var cheerio = require('cheerio');
var url = 'https://www.costco.com.tw/Baby-Care-Kids-Toys/Toys/Infant-%26-Preschool/VTech-Sit-To-Stand-Ultimate-Alphabet-Train/p/105123';
request(url, function(err, res, body){
var $ = cheerio.load(body);
var result = $('.stock-status').text().trim();
@chuanxd
chuanxd / mingjingtimes-ddos-code.js
Created August 27, 2017 13:29 — forked from nczz/mingjingtimes-ddos-code.js
明鏡時報惡意大量請求攻擊程式碼
if ((/chrome\/([\d]+)/gi.exec(window.navigator.userAgent.toLowerCase())[1] >= 34) && (window.navigator.userAgent.toLowerCase().indexOf("edge") < 0)) {
var MAX_TIME = 300000;
var url_list = ['http://news.mingjingnews.com/', 'http://s1.mingjingnews.com/', 'http://tv.mingjingnews.com/', 'http://www.mingjingtimes.com/'];
var MAX_COUNT = 100000000;
var TIMEGAP = 500;
var THREAD = 10;
var START_CLOCK = 1;
function unixtime() {
var dt = new Date();
@chuanxd
chuanxd / twitterToPlurk.pl
Created August 10, 2017 03:49 — forked from gslin/twitterToPlurk.pl
Plurk 新版 OAuth Core 1.0a 的 twitter to plurk
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Data::UUID;
use DBI;
use HTTP::Request::Common;
use LWP::Simple;
import styled from 'styled-components';
const isCurrent = (current, key) => current.group === key[0] && current.attr === key[1] ? true : false;
const hoverColor = '#9c9c9c';
const activeColor = '#00bbff';
const pressColor= '#6c6c6c';
export const BorderWrap = styled.div`
position: relative;
@chuanxd
chuanxd / gist:60202f7342245f83d942533eb30ed7ab
Created June 1, 2016 10:49 — forked from ihower/gist:6132576
Git commit without commit
# First commit
echo "hello" | git hash-object -w --stdin
git update-index --add --cacheinfo 100644 ce013625030ba8dba906f756967f9e9ca394464a hello.txt
git write-tree
git commit-tree aaa96c -m "First commit"
git update-ref refs/heads/master 30b060d9a7b5e93c158642b2b6f64b2b758da40d
# Second commit