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
package main | |
import ( | |
"fmt" | |
"os" | |
"regexp" | |
"strings" | |
"github.com/btnguyen2k/oaiaux" | |
) |
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
package main | |
import ( | |
"fmt" | |
"github.com/btnguyen2k/oaiaux" | |
) | |
func CountTokens(text, lang, encoding string) { | |
numTokens := oaiaux.CountTokens(text, oaiaux.Option{Key: "encoding", Value: encoding}) |
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
// EstimateTokens estimates the number of tokes for an input string. | |
func EstimateTokens(input string) int { | |
const re1 = `[^\w\d]+` | |
const re2 = `[\w\d]+` | |
reWords := regexp.MustCompile(re1) | |
words := reWords.Split(input, -1) | |
numWords := 0 | |
for _, w := range words { | |
if w != "" { | |
numBytes := len([]byte(w)) |
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
--- | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
name: kured | |
rules: | |
# Allow kured to read spec.unschedulable | |
# Allow kubectl to drain/uncordon | |
# | |
# NB: These permissions are tightly coupled to the bundled version of kubectl; the ones below |
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 java.util.*; | |
/** | |
* A demo Java application to see how GC works. | |
* | |
* @author Thanh Nguyen | |
*/ | |
public class GcMemDemo { | |
static Map<Long, byte[]> buffer = new HashMap<>(); |
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/bash | |
echo '==================================================' | |
echo '===============Install necessary tools===============' | |
echo '==================================================' | |
sudo yum update | |
sudo yum install git make flex bison libtool automake openssl-devel libevent libevent-devel python-devel gcc-c++ byacc java-1.7.0-openjdk ant | |
echo '==================================================' |
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
package ddth.dasp.framework.utils; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class DPathUtils { | |
private final static Pattern PATTERN_INDEX = Pattern |