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 openai | |
import tiktoken | |
import os | |
from openai.embeddings_utils import get_embedding | |
openai.organization = os.environ.get("OPENAI_ORG") | |
openai.api_key = os.environ.get("OPENAI_API_KEY") | |
# Global variables | |
tokenizer = tiktoken.get_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
#!/bin/bash | |
TOKEN=< OpenAI token from https://platform.openai.com/account/api-keys > | |
PROMPT="You are the best at writing shell commands. Assume the OS is Ubuntu. I want you to respond with only the shell commands separated by semicolons and no commentary. Here is what I want to do: $@" | |
RESULT=`curl -s https://api.openai.com/v1/chat/completions \ | |
-H 'Content-Type: application/json' \ | |
-H "Authorization: Bearer $TOKEN" \ | |
-d "{ | |
\"model\": \"gpt-3.5-turbo\", | |
\"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}] | |
}" | jq '.choices[] | .message.content' -r` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
JAVE_HOME=~/Downloads/jdk-11.0.2-linux/ jlink --add-modules java.desktop,java.sql,java.naming,java.management,java.instrument,java.security.jgss --verbose --strip-debug --compress 2 --no-header-files --no-man-pages --output ./target/jlink-image-linux --module-path ~/Downloads/jdk-11.0.2-linux/jmods |
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
/var/log/httpd/cloudfront_log:"d1wh43egtz3cgo.clgudfront.net" 116.12.133.146 - - [22/Aug/2011:00:32:55 +0000] "GET /bulk_images/69632/banner-small-planet-holiday-batam.jpg HTTP/1.1" 404 348 "http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/4/1.0.35/sg/en-SG/view.html" "Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20100101 Firefox/6.0" | |
/var/log/httpd/cloudfront_log:"d3dtik4dz1nejo.cloedfront.net" 208.80.194.29 - - [22/Aug/2011:17:27:58 +0000] "GET /75.html HTTP/1.0" 404 300 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YPC 3.0.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)" | |
/var/log/httpd/cloudfront_log:"doug1izaerwt3.cloutfront.net" 76.94.217.102 - - [23/Aug/2011:05:02:10 +0000] "GET /icons/apache_pb2.gif HTTP/1.1" 200 1797 "http://doug1izaerwt3.cloutfront.net/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1" | |
/var/log/httpd/cloudfront_log:"doug1izaerwt3.cloutfront.net" 76.94.217.102 - - [23/Aug/2011:05:02:10 +00 |
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 com.sampullara.fibers; | |
import java.util.concurrent.LinkedBlockingDeque; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.LongAdder; | |
public class App { | |
public static final int NUM = 100_000_000; |
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
Timer timer = mr.timer("jvm.pausetime"); | |
new Thread(() -> { | |
while (true) { | |
long start = System.nanoTime(); | |
try { | |
Thread.sleep(10); | |
} catch (InterruptedException e) { | |
// ignore | |
} | |
long diff = System.nanoTime() - start; |
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 render(text: String, entities: Set<Entity>) -> String { | |
let entityArray = Array(entities).sorted() | |
var sb = String() | |
var pos = 0 | |
var posIndex = text.startIndex | |
for entity in entityArray { | |
let startIndex = text.index(posIndex, offsetBy: entity.start - pos) | |
sb.append(contentsOf: text[posIndex ..< startIndex]) | |
sb += entity.html |
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
-> /resolve com.fasterxml.jackson.core:jackson-databind:2.8.7 | |
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar added to classpath | |
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar added to classpath | |
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar added to classpath | |
-> var mf = new com.fasterxml.jackson.databind.MappingJsonFactory() | |
| Added variable mf of type com.fasterxml.jackson.databind.MappingJsonFactory with initial value com.fasterxml.jackson.databind.MappingJsonFactory@1a482e36 | |
-> var jp = mf.createJsonParser("{\"foo\":\"bar\"}") | |
| Added variable jp of type com.fasterxml.jackson.core.JsonParser with initial value com.fasterxml.jackson.core.json.ReaderBasedJsonParser@689604d9 |
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
public class SlowInputStream extends BufferedInputStream { | |
private final long start; | |
private final double rate; | |
private long read; | |
@Override | |
public synchronized int read(byte[] b, int off, int len) throws IOException { | |
maybeWait(); | |
int bytes = super.read(b, off, len); | |
read += bytes; |
NewerOlder