This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local a = redis.call('get',KEYS[1]); | |
if a and a:find("^updateat:") ~= nil then | |
-- this key already update by anther thread. so we test | |
if tonumber(string.sub(a, 10, string.len(a))) <= tonumber(KEYS[2]) then | |
return redis.call('set',KEYS[1], KEYS[3]); | |
end | |
return; | |
end | |
return redis.call('set',KEYS[1], KEYS[3]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 # search and kill | |
32 function gkill(){ | |
31 filter=$1 | |
30 exp=[${filter:0:1}]${filter:1} | |
29 echo '>ps aux | grep' $exp | |
28 echo $( ps aux | grep $exp --color=always | xargs -I % echo '\n' %) | |
27 echo "Kill?" | |
26 read Keypress | |
25 case "$Keypress" in | |
24 * ) kill $2 $args $(ps aux | grep $exp --color=always | awk '{print $2}'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"time" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <u.h> | |
#include <libc.h> | |
/* | |
* algorithm by | |
* D. P. Mitchell & J. A. Reeds | |
*/ | |
#define LEN 607 | |
#define TAP 273 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#ifndef MERSENNE_TWISTER_H | |
#define MERSENNE_TWISTER_H | |
#define __STDC_LIMIT_MACROS | |
# define uint32_t unsigned int | |
#ifdef __cplusplus | |
extern "C" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://www.zhihu.com/people/tou-gou-bao-da | |
package main | |
import ( | |
"fmt" | |
"math" | |
"math/rand" | |
"reflect" | |
"runtime" | |
"sort" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestH(t *testing.T) { | |
say := func() { | |
fmt.Println("say") | |
} | |
rec := patchFunction(&say, func() { fmt.Println("replace") }) | |
say() | |
rec() | |
say() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
var l = sync.Mutex{} | |
var cond = sync.NewCond(&l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func main() { | |
s := []string{"A", "B", "C"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012-2019 Grabtaxi Holdings PTE LTD (GRAB), All Rights Reserved. NOTICE: All information contained herein | |
// is, and remains the property of GRAB. The intellectual and technical concepts contained herein are confidential, proprietary | |
// and controlled by GRAB and may be covered by patents, patents in process, and are protected by trade secret or copyright law. | |
// | |
// You are strictly forbidden to copy, download, store (in any medium), transmit, disseminate, adapt or change this material | |
// in any way unless prior written permission is obtained from GRAB. Access to the source code contained herein is hereby | |
// forbidden to anyone except current GRAB employees or contractors with binding Confidentiality and Non-disclosure agreements | |
// explicitly covering such access. | |
// | |
// The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, |