Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@amitsaha
amitsaha / tail.py
Last active April 30, 2024 11:49
Simple implementation of the tail command in Python
'''
Basic tail command implementation
Usage:
tail.py filename numlines
'''
import sys
import linecache
@abul4fia
abul4fia / Animations.md
Created March 11, 2024 08:56
How Animation works (more or less)

How animations work (more or less)

To be frank, I don't know all the details about making your own custom Animation class. I know only a general idea, but the details are fuzzy. I usually end up using a trial-and-error approach trying different methods and reading the source code of similar animations, until it works. But the main idea is:

  1. An animation receives a mobject (it can be a group) on which it will operate. In the __init__ method usually it only stores that object into self.mobject, so every animation has that object, and other animation attributes such as the run time, rate function, etc.
  2. When used in a .play(), manim will call its begin() method. Usually you don't need to override that. The default implementation creates another inner object called self.starting_mobject which stores the initial state of the mobject being animated, and it is simply a deep copy of self.mobject (although you can override how that starting mobject is created by overriding `create_starting_mobj
@rkallensee
rkallensee / github_issues_to_csv.rb
Last active April 30, 2024 11:48 — forked from tkarpinski/github_issues_to_csv.rb
Export Github issues to CSV grouped by Milestone
# original source: https://gist.github.com/tkarpinski/2369729
require 'octokit'
require 'csv'
require 'date'
# Github access token to access the project
# Create one at https://github.com/settings/tokens
ACCESS_TOKEN="GITHUB_ACCESS_TOKEN"
@u01jmg3
u01jmg3 / bluetooth.ps
Created May 17, 2020 09:52
Windows Powershell Script to Toggle Bluetooth On or Off
[CmdletBinding()] Param (
[Parameter()][ValidateSet('On', 'Off')][string]$BluetoothStatus
)
If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv }
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
@abul4fia
abul4fia / 00README.md
Last active April 30, 2024 11:44
Working with sections in manim

Working with sections in manim

Manim provides out of the box the possibility of marking parts of your scene as separate sections, by using self.next_section(). This will cause a separate video to be rendered for each section, and then all of them will be stitched together for the final result. The final result will be the same as if you hadn't used sections at all.

But the use of sections allows you to mark some of them with the parameter skip_animations=True, and in that case, that section will not be rendered. The code of the section will be run anyway (because it may be defining objects or variables needed in following sections), but for every self.play(), only the final frame will be computed (and not rendered). This ensures that, at the end of the section, all objects are at the same positions as if the animations were played, but skipping the actual rendering significantly reduces the time required to run the code.

In addition, the resulting video when skip_animations=True is used will be s

@simonster
simonster / attention_distance.py
Last active April 30, 2024 11:43
Mean attention distance
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# Author: Maithra Raghu <maithra@google.com>
def compute_distance_matrix(patch_size, num_patches, length):
"""Helper function to compute distance matrix."""
distance_matrix = np.zeros((num_patches, num_patches))
@veekaybee
veekaybee / normcore-llm.md
Last active April 30, 2024 11:43
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

Registered Name: https://zhile.io
License Key: 48891cf209c6d32bf4