Skip to content

Instantly share code, notes, and snippets.

View toshsan's full-sized avatar
🌴
On vacation

Santosh Sahoo toshsan

🌴
On vacation
  • CircleHD
  • San francisco
  • X @huhyroceq
View GitHub Profile
@toshsan
toshsan / System Design.md
Created April 22, 2016 14:51 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@toshsan
toshsan / bling.js
Created April 3, 2016 05:01 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

<head>
...
<meta name="viewport" content="width=device-width">
...
</head>
# tested on Debian
# require [email protected] with --enable-libfreetype for drawtext extension
# ffmpeg streaming to ffserver feed
# file -> ffmpeg (playback) -> ffmpeg (add timestamp) -> ffmpeg (add timestamp) -> ffserver (FFM delivery)
ffmpeg -i your-file.mp4 -tune zerolatency -filter:v "setpts=1.0*PTS" -f nut pipe:1 \
| ffmpeg -re -i pipe:0 -vf "drawtext=expansion=normal:fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf:reload=1:textfile=test.txt: x=50: y=50: fontcolor=white" -tune zerolatency -f nut pipe:1 \
| ffmpeg -y -i pipe:0 -tune zerolatency http://ffserver-ip:7000/feed1.ffm
@toshsan
toshsan / sitemapgen.py
Created March 12, 2016 19:59
Google Sitemapgen.py
#!/usr/bin/env python
#
# Copyright (c) 2004, 2005 Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
@toshsan
toshsan / resque.py
Last active December 27, 2015 18:38 — forked from defunkt/resque.py
Resque client in Python (fixed)
from redis import Redis
import simplejson
class Resque(object):
"""Dirt simple Resque client in Python. Can be used to create jobs."""
redis_server = 'localhost:6379'
def __init__(self):
host, port = self.redis_server.split(':')
self.redis = Redis(host=host, port=int(port))
@toshsan
toshsan / words
Last active November 26, 2015 18:09
Words cat /usr/share/dict/words
A
a
aa
aal
aalii
aam
Aani
aardvark
aardwolf
Aaron
@toshsan
toshsan / dumpwebserver.py
Last active November 3, 2015 05:09
dumpwebserver.py to dump http headers and body. run python dumpwebserver.py 8080
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from urlparse import parse_qs
from cgi import parse_header, parse_multipart
from SocketServer import ForkingMixIn
class ForkingHTTPServer(ForkingMixIn, HTTPServer):
def finish_request(self, request, client_address):
request.settimeout(30)
@toshsan
toshsan / dummy-web-server.py
Created November 3, 2015 04:03 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost