Skip to content

Instantly share code, notes, and snippets.

@wjfz
wjfz / limitConcurrentGoroutines.go
Created November 25, 2020 02:40 — forked from AntoineAugusti/limitConcurrentGoroutines.go
Limit the maximum number of goroutines running at the same time
package main
import (
"flag"
"fmt"
"time"
)
// Fake a long and difficult work.
func DoWork() {
@wjfz
wjfz / rate.php
Created August 12, 2017 07:26
rate
<?php
/**
* Created by PhpStorm.
* User: wangjunfengze
* Date: 2017/8/12
* Time: 下午2:54
*/
$money = 6988;
private function doFetch()
{
$header[] = "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
$header[] = "Accept-Language:zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4";
$header[] = "Cache-Control:max-age=0";
$header[] = "Connection:keep-alive";
$header[] = "DNT:1";
$header[] = "Host:www.amazon.cn";
$header[] = "Upgrade-Insecure-Requests:1";
public function actionJd()
{
$first = JdSku::model()->find("fetched = 0");
echo $first->sku."\n\n";
$this->doFetch($first->sku);
$first->fetched = 1;
$saved = $first->save();
public function actionJd()
{
$first = JdSku::model()->find("fetched = 0");
echo $first->sku."\n";
$this->doFetch($first->sku);
$first->fetched = 1;
$first->save();
@wjfz
wjfz / check_content_language
Created September 28, 2015 03:28
检测语言
function isEnglish(s)
{
for(var i=0;i<s.length;i++)
{
if(s.charCodeAt(i)>126)
{
return false;
}
}
return true;