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` |
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 indy; | |
import java.lang.invoke.CallSite; | |
import java.lang.invoke.ConstantCallSite; | |
import java.lang.invoke.MethodHandle; | |
import java.lang.invoke.MethodHandles; | |
import java.lang.invoke.MethodType; | |
import java.lang.reflect.Constructor; | |
import org.objectweb.asm.ClassWriter; |
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/sh | |
# simple script for turning a jar with a Main-Class | |
# into a stand alone executable | |
# cat [your jar file] >> [this file] | |
# then chmod +x [this file] | |
# you can now exec [this file] | |
commandToRun="$(printf "%q " "$@")" | |
if test "$commandToRun" = "'' "; then | |
eval "exec java -Xmx1G -jar $0" | |
else |
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; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Spliterator; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.function.Consumer; | |
import java.util.stream.Stream; | |
import java.util.stream.StreamSupport; |
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
// 1) Stride through the database using KeySelectors until you pass the end of the database | |
// 2) Then, back off until you find the last key | |
final AtomicBoolean retry = new AtomicBoolean(); | |
Function<Transaction, Long> function = new Function<Transaction, Long>() { | |
private long start = System.currentTimeMillis(); | |
private long count = 0; | |
private int offset = 1000000; | |
private KeySelector keySelector = KeySelector.firstGreaterOrEqual(new byte[0]); | |
private boolean narrowing = false; |
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 Rated { | |
public Rated(JsonNode node) { | |
starRating = node.get("rating").intValue(); | |
} | |
int starRating; | |
class Star { | |
boolean active; |
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 spullara.util.concurrent; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.concurrent.*; | |
import java.util.concurrent.atomic.AtomicBoolean; |
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
@Test | |
public void testPivotTable() { | |
List<Row> rows = new ArrayList<>(); | |
rows.add(new Row("East", "Boy", "Tee", 10, 12.00)); | |
rows.add(new Row("East", "Boy", "Golf", 15, 20.00)); | |
rows.add(new Row("East", "Girl", "Tee", 8, 14.00)); | |
rows.add(new Row("East", "Girl", "Golf", 20, 24.00)); | |
rows.add(new Row("West", "Boy", "Tee", 5, 12.00)); | |
rows.add(new Row("West", "Boy", "Golf", 12, 20.00)); | |
rows.add(new Row("West", "Girl", "Tee", 15, 14.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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.yourpackage</groupId> | |
<artifactId>parentartifactofeverything</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<modules> | |
<module>module1</module> | |
<module>module2</module> |
NewerOlder