Skip to content

Instantly share code, notes, and snippets.

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

Ethan dcalsky

🏠
Working from home
  • The University of Hong Kong
  • Hong Kong
View GitHub Profile
@cmj
cmj / verify_credentials.sh
Last active March 10, 2025 06:03
Simple Twitter verify_credentials example
#!/bin/bash
# Test various Bearer tokens in Twitter API verify_credentials/isLoggedIn endpoint
# parameters:
# include_entities
# skip_status
# include_email
auth_token=$1
usage() { echo "$0 auth_token"; exit 1; }
@cmj
cmj / likes.sh
Last active January 1, 2025 16:30
grab last 100 (hidden) likes from a twitter user
#!/bin/bash
# grab the last ~100 (hidden) likes from a twitter user
# requires account, 2 parameters from header
x_csrf_token='XXXXXXXXXX'
auth_token='XXXXXXXXXX'
####
usage() { echo "$0 username"; exit 1; }
@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 November 4, 2024 16:26
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 April 19, 2025 05:14
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