Skip to content

Instantly share code, notes, and snippets.

@chuckg
chuckg / README.md
Last active May 14, 2024 09:19
Bootstrap an image for use as a Vagrant base box

Requirements

Prepare virtual machine

@davidedc
davidedc / webgl_lines_colors.html
Created April 8, 2012 19:30
working motion blur with transparent background
<!doctype html>
<html lang="en">
<head>
<title>three.js webgl - lines - cubes - colors</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #FF0000;
margin: 0px;
@scriptingstudio
scriptingstudio / ConvertTo-HtmlTable.ps1
Last active May 14, 2024 09:18
Simple and robust PowerShell object to HTML table converter that just works
<#
.SYNOPSIS
Creates HTML table from .NET objects.
.DESCRIPTION
This is basic cmdlet, as a helper, to build HTML tables for complex HTML content.
Converts .NET objects into HTML that can be displayed in a Web browser.
This cmdlet works like "ConvertTo-Html -Fragment" but does not have any of its disadvantages, allowing HTML entities in cells, omiting the first column colons and allowing multi-column tables in the List mode, etc.
Features:
- Parameterset autoresolve. There are no predefined parameter sets
- Input data preprocessor: sorting and filtering
@padeoe
padeoe / README_hfd.md
Last active May 14, 2024 09:16
CLI-Tool for download Huggingface models and datasets with aria2/wget+git

🤗Huggingface Model Downloader

Considering the lack of multi-threaded download support in the official huggingface-cli, and the inadequate error handling in hf_transfer, this command-line tool smartly utilizes wget or aria2 for LFS files and git clone for the rest.

Features

  • ⏯️ Resume from breakpoint: You can re-run it or Ctrl+C anytime.
  • 🚀 Multi-threaded Download: Utilize multiple threads to speed up the download process.
  • 🚫 File Exclusion: Use --exclude or --include to skip or specify files, save time for models with duplicate formats (e.g., *.bin or *.safetensors).
  • 🔐 Auth Support: For gated models that require Huggingface login, use --hf_username and --hf_token to authenticate.
  • 🪞 Mirror Site Support: Set up with HF_ENDPOINT environment variable.
@pavel-kirienko
pavel-kirienko / 51-xbox-gamepad.rules
Last active May 14, 2024 09:15 — forked from dnmodder/fixcontroller.py
Use Microsoft X-Box 360 Gamepad with GNU/Linux
# By default, X-Box 360-compatible controllers are detectable but dysfunctional because they expect the host
# to send a particular USB control transfer with some sort of initialization command.
# This udev rule will invoke a trivial Python script automatically when the gamepad is connected that emits
# the required initialization command.
#
# Integration:
# 1. Put this rule into /etc/udev/rules.d/51-xbox-gamepad.rules
# 2. Install pyusb for the root's Python: sudo pip install pyusb
# 3. Reload udev rules as root: udevadm control --reload-rules && udevadm trigger
#
@chriskoelle
chriskoelle / max-image-size.js
Created December 16, 2014 20:06
Use javascript and canvas to resize images from file input before upload
jQuery(function($) {
// Test for file API support.
var fileApiSuport = !!(window.File && window.FileReader );
/**
* Resize images that exceed the maximum size (in pixels)
* @param {object} input The file input.
* @param {Function} callback Callback function run after the image has been resized.
* @return {null}
*/
@mda590
mda590 / boto3_listinstances_example.py
Last active May 14, 2024 09:14
Example using boto3 to list running EC2 instances
import boto3
ec2 = boto3.resource('ec2')
def lambda_handler(event, context):
# create filter for instances in running state
filters = [
{
'Name': 'instance-state-name',
'Values': ['running']
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@sebzur
sebzur / polish_holidays.py
Created February 12, 2012 20:25
Python generator for public holidays in Poland
from datetime import date, timedelta
from dateutil import easter
from dateutil.relativedelta import *
def get_holidays(year=2010):
""" Returns Polish hollidays dates (legally considered non-working days) """
easter_sunday = easter.easter(year)
holidays = {'New Year': date(year,1,1),
'Trzech Kroli': date(year,1,6),
'Easter Sunday': easter_sunday,