This file contains 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
# Dial | |
pppoecd vlan2 -u $user -p $password # wan1 | |
pppoecd vlan2 -u $user -p $password # wan2 | |
# Handle outgoing packet | |
# Make "ip route" contains a default route like this | |
# "ip route" final state | |
#default | |
# nexthop via $wan1_ip dev $wan1_dev weight 1 # such as 202.106.0.24 ppp0 |
This file contains 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/sh | |
# Copyright (C) 2009 Fabian Omar Franzotti <fofware@gmail.com> | |
# http://pastebin.ca/2098184 | |
# | |
#include /lib/network | |
. /etc/functions.sh | |
. /lib/config/uci.sh | |
# 传入的参数有 INTERFACE, DEVICE ACTION | |
# ACTION有:ifup, update, ifdown, changeRoute |
This file contains 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 decimal import Decimal | |
bids = [int(a) for a in '60 62 60 56 56 57'.split('\t')] | |
print(bids) | |
price = min(bids) | |
total_payment = (len(bids) - 1) * price | |
total_bid = sum(bids) - price | |
min_pos = bids.index(price) | |
max_pos = bids.index(max(bids)) | |
bids[min_pos] = 'min' | |
bids[max_pos] = 'max' |
This file contains 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 backtype.storm.tuple.Tuple; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Map; | |
import java.util.Set; | |
public class StreamTracker { |
This file contains 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 <numeric> | |
#include <algorithm> | |
#include <random> | |
#include <vector> | |
#include <iostream> | |
#include <limits> | |
typedef int V; | |
typedef std::vector<V> vi; |
This file contains 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 "github.com/modern-go/concurrent" | |
executor := concurrent.NewUnboundedExecutor() | |
executor.Go(func(ctx context.Context) { | |
everyMillisecond := time.NewTicker(time.Millisecond) | |
for { | |
select { | |
case <-ctx.Done(): | |
fmt.Println("goroutine exited") | |
return |
This file contains 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
// set a logger to show who is blocking | |
concurrent.InfoLogger = log.New(os.Stdout, "", 0) | |
executor := concurrent.NewUnboundedExecutor() | |
executor.Go(func(ctx context.Context) { | |
everyMillisecond := time.NewTicker(time.Millisecond) | |
for { | |
select { | |
case <-ctx.Done(): | |
// info log will be printed while we wait | |
time.Sleep(time.Second) |
This file contains 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 ExampleUnboundedExecutor_Go_panic() { | |
concurrent.HandlePanic = func(recovered interface{}, funcName string) { | |
fmt.Println(funcName) | |
} | |
executor := concurrent.NewUnboundedExecutor() | |
executor.Go(willPanic) | |
time.Sleep(time.Second) | |
// output: | |
// github.com/modern-go/concurrent_test.willPanic | |
} |
This file contains 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
function some_important_business_process(a, b) | |
result = a + b | |
c = 3 | |
result = result * c | |
return result | |
end | |
result = some_important_business_process(1, 2) | |
print(result) |
This file contains 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
function some_important_business_process(a, b) | |
result = a + b | |
c = 3 | |
result = result * c | |
return result | |
end | |
result = some_important_business_process(1, 2) | |
print(result) |
OlderNewer