Skip to content

Instantly share code, notes, and snippets.

@Maximilian-Winter
Maximilian-Winter / gbnf_grammar_generator.py
Last active April 24, 2024 22:03
GBNF grammar generator for always valid function calls and object creation in JSON with llama.cpp
import inspect
import json
import re
import typing
from inspect import isclass, getdoc
from types import NoneType
from pydantic import BaseModel, Field
from pydantic.fields import FieldInfo
from typing import Any, Type, List, get_args, get_origin, Tuple, Union, Optional
@Hellisotherpeople
Hellisotherpeople / blog.md
Last active May 13, 2024 20:04
You probably don't know how to do Prompt Engineering, let me educate you.

You probably don't know how to do Prompt Engineering

(This post could also be titled "Features missing from most LLM front-ends that should exist")

Apologies for the snarky title, but there has been a huge amount of discussion around so called "Prompt Engineering" these past few months on all kinds of platforms. Much of it is coming from individuals who are peddling around an awful lot of "Prompting" and very little "Engineering".

Most of these discussions are little more than users finding that writing more creative and complicated prompts can help them solve a task that a more simple prompt was unable to help with. I claim this is not Prompt Engineering. This is not to say that crafting good prompts is not a difficult task, but it does not involve doing any kind of sophisticated modifications to general "template" of a prompt.

Others, who I think do deserve to call themselves "Prompt Engineers" (and an awful lot more than that), have been writing about and utilizing the rich new eco-system

@carlopi
carlopi / cheerp_jit.cpp
Created March 21, 2021 19:47
Skeleton of Jit implementation with Cheerp
namespace [[cheerp::genericjs]] client {
//forward declare a bunch of JavaScript APIs existing on the browser
namespace WebAssembly {
public:
Promise* instantiate(ArrayBuffer* code, ImportObject* imports);
};
}
[[cheerp::genericjs]] void onSuccess(ModuleAndInstance* res) {
auto start_function = res->get_instance()->get_start_function();
/// <reference path="../../typings/ue.d.ts">/>
@UCLASS(BlueprintComponent)
class MyCharacter extends Character {
@UPROPERTY(EditAnywhere)
CameraBoom: SpringArmComponent;
@UPROPERTY(EditAnywhere)
FollowCamera: CameraComponent;
@shubhamwagh
shubhamwagh / TexturedMeshSteps.md
Last active April 24, 2024 14:26
Steps to create textured mesh from point cloud using Meshlab

Steps to create Textured Mesh from Point Cloud using Meshlab

Get your PointCloud into MeshLab

  • Import the pointcloud file in ".ply" file format in Meshlab. Before importing make sure you do some pre-processing / cleaning on point cloud so as to ease the process of meshing.

Point Cloud Simplification and Normals Computation

  • Next we need to reduce the number of point samples for smooth meshing.
    • So go to Filters -> Point Set -> Point Cloud Simplification. Enter Number of samples circa 5% of original number of points. Make sure Best Sample Heuristic is checked.
  • After point cloud simplification, make sure to select Simplified point cloud in the Show Layer Dialog on the right hand side. If not visible, it can be opened by navigating to View -> Show Layer Dialog. Now we need to compute normals for point set.
  • So go to Filters -> Point Set -> Compute normals for point sets . Enter Neighbour num between 10 - 100. Initially try with 10 and
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
import argparse
import deepspeech as ds
import numpy as np
import shlex
import subprocess
import sys
parser = argparse.ArgumentParser(description='DeepSpeech speech-to-text from microphone')
parser.add_argument('--model', required=True,
help='Path to the model (protocol buffer binary file)')
def DepthConversion(PointDepth, f):
H = PointDepth.shape[0]
W = PointDepth.shape[1]
i_c = np.float(H) / 2 - 1
j_c = np.float(W) / 2 - 1
columns, rows = np.meshgrid(np.linspace(0, W-1, num=W), np.linspace(0, H-1, num=H))
DistanceFromCenter = ((rows - i_c)**2 + (columns - j_c)**2)**(0.5)
PlaneDepth = PointDepth / (1 + (DistanceFromCenter / f)**2)**(0.5)
return PlaneDepth
@MatthieuLemoine
MatthieuLemoine / crypto.js
Created January 23, 2017 14:36
Node crypto sign & verify
const id = '__JUNK__';
// Public key need to be in PKCS8 format
// ssh-keygen -e -m PKCS8 -f id_rsa.pub > id_rsa.pkcs8
const publicKey = fs.readFileSync(path.join(__dirname, 'id_rsa.pkcs8'), { encoding : 'utf8' });
const privateKey = fs.readFileSync(path.join(__dirname, 'id_rsa'), { encoding : 'utf8' });
// Sign
const signer = crypto.createSign('RSA-SHA512');
signer.update(id);
const signature = signer.sign(privateKey, 'hex');
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
<script src="https://npmcdn.com/expect/umd/expect.min.js"></script>
<script src="https://npmcdn.com/redux@3.5.2/dist/redux.js"
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>