Skip to content

Instantly share code, notes, and snippets.

View darxtrix's full-sized avatar

Ankush Sharma darxtrix

View GitHub Profile
@soheilhy
soheilhy / nginxproxy.md
Last active April 11, 2025 06:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@staltz
staltz / introrx.md
Last active April 29, 2025 08:33
The introduction to Reactive Programming you've been missing
@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',
@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()
@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"
)
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
@tevino
tevino / epoll.go
Last active December 23, 2024 12:34
An example of using epoll in Go
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (

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
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 15, 2025 22:49
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

"""
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: