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 ( | |
"context" | |
"log" | |
"os" | |
"os/signal" | |
"syscall" | |
"github.com/apache/rocketmq-client-go/v2" |
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 ( | |
"context" | |
"encoding/json" | |
"log" | |
"os" | |
"os/signal" | |
"strconv" | |
"syscall" |
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
-- author: weedge | |
-- params: KEYS[1] user asset key | |
-- params: KEYS[2] event msg key | |
-- params: ARGV[1] incr asset num eg:1,-1 | |
-- params: ARGV[2] user asset key ttl | |
-- params: ARGV[3] event msg key ttl | |
-- return 1:操作成功, 0:无操作,-1:缓存资产不存在,-2:资产不足, | |
-- debug: | |
-- redis-cli --ldb --eval user_asset_change.redis.lua I.asset.{100} M.asset.{100}.`ksuid` , 100 86400 86400 | |
-- redis-cli -c -p 26383 --ldb --eval user_asset_change.redis.lua I.asset.{100} M.asset.{100}.`ksuid` , 100 86400 86400 |
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
// ¥¥¥ show me the money ¥¥¥ | |
// author: weedge | |
// desc: redis change asset tx demo | |
package main | |
import ( | |
"context" | |
"encoding/json" | |
"errors" | |
"fmt" |
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
show engines; | |
show databases; | |
drop database pay; | |
create database pay ; | |
use pay; | |
drop table `pay`.`user_asset`; | |
CREATE TABLE `user_asset` | |
( | |
`userId` bigint unsigned NOT NULL DEFAULT '0', | |
`assetCn` bigint unsigned NOT NULL DEFAULT '0', |
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 ( | |
"context" | |
"errors" | |
"fmt" | |
"log" | |
"sync" | |
"time" |
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
#!/bin/bash | |
mkdir -p ~/.vim/{ftdetect,indent,syntax} | |
for d in ftdetect indent syntax ; do | |
curl -o ~/.vim/$d/scala.vim https://raw.githubusercontent.com/gchen/scala.vim/master/scala.vim | |
done |
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
//Name: spinvsmutex2.c | |
//http://www.parallellabs.com/2010/01/31/pthreads-programming-spin-lock-vs-mutex-performance-analysis/ | |
//Source: http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_Locks | |
//Compile(spin lock version): gcc -o spin -DUSE_SPINLOCK spinvsmutex2.c -lpthread | |
//Compile(mutex version): gcc -o mutex spinvsmutex2.c -lpthread | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <sys/syscall.h> |
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
// Name: spinlockvsmutex1.cpp | |
//http://www.parallellabs.com/2010/01/31/pthreads-programming-spin-lock-vs-mutex-performance-analysis/ | |
// Source: http://www.alexonlinux.com/pthread-mutex-vs-pthread-spinlock | |
// Compiler(spin lock version): g++ -o spin_version -DUSE_SPINLOCK spinlockvsmutex1.cpp -lpthread | |
// Compiler(mutex version): g++ -o mutex_version spinlockvsmutex1.cpp -lpthread | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/syscall.h> | |
#include <errno.h> | |
#include <sys/time.h> |
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
import socket | |
import subprocess | |
# Start a socket listening for connections on 0.0.0.0:8000 (0.0.0.0 means | |
# all interfaces) | |
server_socket = socket.socket() | |
server_socket.bind(('0.0.0.0', 8000)) | |
server_socket.listen(0) | |
# Accept a single connection and make a file-like object out of it |