Skip to content

Instantly share code, notes, and snippets.


Vinay Sajip vsajip

View GitHub Profile
vsajip / test.ftl
Last active Jun 25, 2021
Python code generation template and result - how to pass indentation across multiple levels of nested directives?
View test.ftl
[#macro BuildCodeSequence expansion indent]
[#var is = ""?right_pad(indent)]
${is}# DBG > BuildCodeSequence ${indent}
[#list expansion.units as subexp]
[@BuildCode subexp indent /]
${is}# DBG < BuildCodeSequence ${indent}
[#macro BuildExpansionCode expansion indent]
[#var is=""?right_pad(indent)]
# From
# remove-silence-at-the-beginning-and-at-the-end-of-wave-files-with-pydub
from pydub import AudioSegment
def detect_leading_silence(sound, silence_threshold=-50.0, chunk_size=10):
sound is a pydub.AudioSegment
silence_threshold in dB
chunk_size in ms
vsajip /
Created Oct 28, 2020 — forked from eculver/
htpasswd script in python (no need to install apache utils)
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
vsajip /
Created Oct 26, 2020 — forked from nileshtrivedi/
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions:

I already have my own domain name: I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

vsajip /
Last active Nov 17, 2020
Python 3.6+ scripts for synchronizing IMAP mailboxes using mbsync and imapsync
# Copyright (C) 2020 Red Dove Consultants Limited
# License: GPL v2
# This script uses imapsync to synchronize IMAP mailboxes. It uses as input a CSV file
# with columns oldhost,olduser,oldpwd,newhost,newuser,newpwd,migrate. The first line
# is expected to be those column names. oldXXX columns refer to the source mailbox
# information and newXXX columns refer to the target mailbox information. The migrate

Keybase proof

I hereby claim:

  • I am vsajip on github.
  • I am vsajip ( on keybase.
  • I have a public key ASBsA1X70Mmfu4TObh0UTxcGZhq_ITQjgw2j8m0A6-f1Ewo

To claim this, I am signing this object:

vsajip / InlineInlineMonacoEditor.stories.tsx
Created Aug 17, 2020 — forked from abersnaze/InlineInlineMonacoEditor.stories.tsx
React component, in typescript, wrapping Monaco editor to automatically grow & shrink with content to avoid scroll.
View InlineInlineMonacoEditor.stories.tsx
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import InlineMonacoEditor from './InlineMonacoEditor';
export const LINES = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Aenean aliquet, nulla eget auctor porttitor, lacus urna',
'posuere purus, at suscipit orci sapien quis est. Curabitur',
vsajip /
Created Apr 25, 2020 — forked from aelbore/
Step by Step creating web components in typescript using rollup

Getting Started

  • Install Dependencies
    npm init
    npm install --save-dev ts-node typescript tslib express @types/express

Create your web server

  • Create server.ts in root folder of your app.
vsajip /
Created Apr 11, 2020 — forked from dwayneblew/
Overlay text on a PDF template using fpdf and PyPDF2
import fpdf
from PyPDF2 import PdfFileWriter, PdfFileReader
overlay_pdf_file_name = 'overlay_PDF.pdf'
pdf_template_file_name = 'base_PDF_template.pdf'
result_pdf_file_name = 'final_PDF.pdf'
# This section creates a PDF containing the information you want to enter in the fields
# on your base PDF.
from ctypes import *
from ctypes.wintypes import (HANDLE, ULONG, DWORD, BOOL, LPCSTR, LPCWSTR, WORD,
import msvcrt
import platform
import sys
# WinSock2 definitions