Skip to content

Instantly share code, notes, and snippets.

View dcalsky's full-sized avatar
🏠
Working from home

zuozuo dcalsky

🏠
Working from home
  • The University of Hong Kong
  • Hong Kong
View GitHub Profile
@kouroshHakha
kouroshHakha / create_test_dataset.py
Created December 11, 2023 05:06
JSON Mode and Function-calling on Open LLMs Blogpost
import datasets
import re
import json
import tqdm
ds = datasets.load_dataset("glaiveai/glaive-function-calling-v2", split="train")
out_ds_size = 100
class UserAssistantNotFoundError(Exception):
@rogeriochaves
rogeriochaves / main.py
Created July 10, 2023 05:34
MULTI_PROMPT_ROUTER_TEMPLATE improved
"""You help triaging user requests. Given a raw text input, output either DOCS or DEFAULT, according to those definitions:
DOCS: if user is asking a seemingly technical question, programming questions or company-specific questions
DEFAULT: if user is just chit-chatting or basic knowledge questions
====================
Input: hello there
Output: DEFAULT
@AlexV525
AlexV525 / create_images.dart
Last active November 17, 2023 10:28
How do we create images through RepaintBoundary or Widget? (Null safety version)
///
/// [Author] Alex (https://github.com/AlexV525)
/// [Date] 07/30/21 5:29 PM
///
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
@zhanwenchen
zhanwenchen / export_tf_model.py
Last active August 31, 2021 22:51
Minimal code to load a trained TensorFlow model from a checkpoint and export it with SavedModelBuilder
import os
import tensorflow as tf
trained_checkpoint_prefix = 'checkpoints/dev'
export_dir = os.path.join('models', '0') # IMPORTANT: each model folder must be named '0', '1', ... Otherwise it will fail!
loaded_graph = tf.Graph()
with tf.Session(graph=loaded_graph) as sess:
# Restore from checkpoint
loader = tf.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
@revotu
revotu / remove_attrs.py
Last active January 27, 2024 06:48
remove all HTML attributes with BeautifulSoup except some tags(<a> <img>...)
from bs4 import BeautifulSoup
# remove all attributes
def _remove_all_attrs(soup):
for tag in soup.find_all(True):
tag.attrs = {}
return soup
# remove all attributes except some tags
def _remove_all_attrs_except(soup):
package auth
import (
"context"
"net/http"
"strings"
"google.golang.org/grpc/metadata"
"github.com/andela/micro-api-gateway/pb/authorization"
@ecnelises
ecnelises / qregex.c
Last active January 13, 2016 10:00
支持基本正则运算的正则引擎
/*
* regex.c
* Qiu Chaofan, 2016/1/12
*
* Regular expression engine.
*
* Features:
* Support matching for | * ? + . ()
* No error handling is considered yet.
*/
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@fred3m
fred3m / Multilayer Canvas
Created March 11, 2015 03:33
An html5 canvas with multiple layers
// Canvas with multiple layers
// copyright 2015 by Fred Moolekamp
// MIT License
initMultiCanvas=function(div,options){
var $div;
if(div instanceof jQuery){
$div=div;
}else{
$div=$(div);
};
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.