Skip to content

Instantly share code, notes, and snippets.

View darxtrix's full-sized avatar

Ankush Sharma darxtrix

View GitHub Profile
@shimpe
shimpe / fancy_captions.py
Last active May 17, 2024 02:41
fancy captions with moviepy
import PySide6.QtSvg
import PySide6.QtGui
import PySide6.QtCore
import moviepy.video.VideoClip
import moviepy.editor
import numpy as np
from moviepy.editor import *
from vectortween.PointAnimation import PointAnimation
from vectortween.SequentialAnimation import SequentialAnimation
@karpathy
karpathy / stablediffusionwalk.py
Last active June 29, 2024 03:43
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
"""
An alternative text clip for Moviepy, relying on Gizeh instead of ImageMagick
Advantages:
- Super fast (20x faster)
- no need to install imagemagick
- full-vector graphic, no aliasing problems
- Easier font names
Disadvantages:
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active June 25, 2024 07:29
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

Random weighted element with Redis sorted sets

Imagine you have elements A, B and C with weights 1, 2 and 3. You compute the sum of the weights, which is 1+2+3 = 6

At this point you add all the elements into a sorted set using this algorithm:

SUM = ELEMENTS.TOTAL_WEIGHT // 6 in this case.
SCORE = 0
@tevino
tevino / epoll.go
Last active January 20, 2024 22:50
An example of using epoll in Go
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
anonymous
anonymous / patch.diff
Created July 7, 2015 21:35
diff --git a/ptop/interfaces/GUI.py b/ptop/interfaces/GUI.py
index 897bef3..c045fe7 100644
--- a/ptop/interfaces/GUI.py
+++ b/ptop/interfaces/GUI.py
@@ -305,6 +305,9 @@ class PtopGUI(npyscreen.NPSApp):
self.CHART_LENGTH = int(self.CHART_LENGTH*self.X_SCALING_FACTOR)
self.CHART_HEIGHT = int(self.CHART_HEIGHT*self.Y_SCALING_FACTOR)
+ self.cpu_array = [0]*self.CHART_LENGTH
+ self.memory_array = [0]*self.CHART_LENGTH
@fatih
fatih / yamux-exmaple.go
Created May 22, 2015 10:19
A simple working yamux example
package main
import (
"fmt"
"log"
"net"
"time"
"github.com/hashicorp/yamux"
)
@zsrinivas
zsrinivas / pour1.py
Created March 29, 2015 11:51
spoj POUR1 - Pouring water | http://www.spoj.com/problems/POUR1/
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# pylint: disable=invalid-name,missing-docstring,bad-builtin
from sys import stdin
from collections import deque
def main():
def steps(a, b, c):
queue = deque([(0, 0), (-1, -1)])
visited = set()
@jossef
jossef / colors.py
Last active February 2, 2023 20:39
python coloring for linux, based on this answer http://stackoverflow.com/a/26445590/3191896
def color(text, **user_styles):
styles = {
# styles
'reset': '\033[0m',
'bold': '\033[01m',
'disabled': '\033[02m',
'underline': '\033[04m',
'reverse': '\033[07m',