Skip to content

Instantly share code, notes, and snippets.

@danveloper
danveloper / api_adapter.py
Created December 22, 2023 14:16
Translate Llama2-7B-functions output model to OAI JSON spec
from fastapi import FastAPI, Request
import json
import requests
"""
{
"messages": [
{
"content": "you are immensely smart function AI",
"role": "system"
@danveloper
danveloper / build.gradle
Created October 28, 2018 11:15
adding ignore-exceptions-ast to Gradle build
apply plugin: 'groovy'
apply plugin: 'idea'
repositories {
maven { url "https://dl.bintray.com/danveloper/maven" }
}
dependencies {
compile 'com.github.danveloper.ast:ignore-exceptions-ast:1.0.0-rc-2'
}
  • Create a new folder
  • Create a build.gradle file
  • Inside the build.gradle file, put the following:
buildscript {
  repositories {
    jcenter()
  }
 dependencies {

Ratpack "Hello World" on a t2.micro, Ubuntu 14.04, no extra server configuration.

~30,000 req/s

# ./wrk -t4 -c72 -d60s -R35000 http://localhost:5050
Running 1m test @ http://localhost:5050
  4 threads and 72 connections
  Thread calibration: mean lat.: 823.764ms, rate sampling interval: 3041ms
 Thread calibration: mean lat.: 800.518ms, rate sampling interval: 2902ms

Keybase proof

I hereby claim:

  • I am danveloper on github.
  • I am danveloper (https://keybase.io/danveloper) on keybase.
  • I have a public key whose fingerprint is FE5B 4B85 F69A 746A 4485 0EB6 8878 7076 EB89 3653

To claim this, I am signing this object:

@danveloper
danveloper / 0_ConfigSlurperConfigSource.groovy
Created June 27, 2016 05:52
Groovy Script Config Source for Ratpack
package app
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.ObjectNode
import com.google.common.io.ByteSource
import com.google.common.io.Resources
import ratpack.config.ConfigSource
import ratpack.file.FileSystemBinding
import java.nio.file.Files
@danveloper
danveloper / FibBackoff.groovy
Last active June 23, 2016 04:38
Fibonacci Backoff Strategy
import groovy.transform.Memoized
class FibBackoff {
int tryNum
void backoff() {
tryNum = fib(tryNum)
sleep(tryNum * 1000)
}
/**
* The `Promise#map` method is used to retrieve
* a value asynchronously (via a `Promise`) and
* transform it synchronous to a new value.
*/
class MappingSpec extends Specification {
@AutoCleanup
ExecHarness harness = ExecHarness.harness()

Ratpack Production Tunings

# cat /etc/security/limits.conf

*         hard    nofile      500000
*         soft    nofile      500000
root      hard    nofile      500000
root      soft    nofile      500000
@danveloper
danveloper / a.md
Last active August 29, 2015 14:25
optimization question

Optimization Question

Does JavaScript optimize for a function that is defined within the context of another function?

For example, are the following examples canonically represented (in performance terms) after compilation, or is one approach favored optimally over the other?

Inner-function

function sortMyThings() {