Skip to content

Instantly share code, notes, and snippets.

View pulsejet's full-sized avatar

Varun Patil pulsejet

View GitHub Profile
@pulsejet
pulsejet / pgp_git.md
Last active November 29, 2020 06:13
GPG PGP with git

Generate

# generate initial key
gpg --full-generate-key
gpg --list-secret-keys --keyid-format LONG  # get ID (sec)
gpg --armor --export 3AA5C34371567BD2  # get pubkey

# add identity
gpg --edit-key 3AA5C34371567BD2
$ gpg> adduid
@pulsejet
pulsejet / dump_scripts_rxdata.rb
Created October 18, 2020 20:09
Dump RPG XP Scripts.rxdata to ruby files
# Adapted from https://github.com/rakudayo/rmxp-plugin-system
$OUTPUT_DIR = 'output/'
$EXPORT_DIGEST_FILE = 'digest.rb'
$INFILE_S = 'Scripts.rxdata'
$COLUMN1_WIDTH = 12
$COLUMN2_WIDTH = 45
require 'fileutils'
@pulsejet
pulsejet / Hub.c.patch
Created March 23, 2020 12:27
Patch for SoftEther for post-connect auth
--- src/Cedar/Hub.c 2020-03-20 16:17:07.000000000 +0530
+++ src/Cedar/Hub.c 2020-03-23 17:51:52.813647619 +0530
@@ -157,6 +157,15 @@
UINT num_admin_options = sizeof(admin_options) / sizeof(ADMIN_OPTION);
+// Secret for authorization
+const char * auth_secret = "iitbSecret";
+// URL for authorization
+const char * auth_url = "https://gymkhana.iitb.ac.in/";
@pulsejet
pulsejet / dump-nxt-app.sh
Created November 17, 2019 18:32
Create a deployment archive from NextCloud app git repo folder
#!/bin/bash
# Name of app
APP="oidc_login"
# Name of git repo folder
GITREPO="oidc_git"
# Remove existing
rm -rf $APP/
cp -R $GITREPO/ $APP
@pulsejet
pulsejet / JSONSubset.go
Created July 16, 2019 10:17
Check if a JSON object is subset of another (useful for testing)
// JSONDiff represents the whole diff
type JSONDiff struct {
Rows []JSONDiffRow
}
// JSONDiffRow represents a single non-existent subset item
type JSONDiffRow struct {
Key string
Expected interface{}
Got interface{}
@pulsejet
pulsejet / kmeans-spaghetti.py
Created April 7, 2019 14:14
A ludicrous spaghetti implementation of n-dimensional weighted k-means
"""A ludicrous spaghetti implementation of n-dimensional weighted k-means that can do no prediction. This line is long since, after all, it's spaghetti!"""
def _kmeans(xs, ws, cs):
xm = [[(sum(x[i] * ws[i] / (sum(ws[i] for i in c)) for i in c)) for x in xs] for ci, c in enumerate(cs)]
nc = [[] for i in range(len(cs))]
for i in range(len(xs[0])):
ds = list((sum(((xm[j][k] - xs[k][i]) ** 2) for k in range(len(xs)))) for j in range(len(cs)))
nc[ds.index(min(ds))].append(i)
return cs, nc
@pulsejet
pulsejet / nqueens.run
Created January 18, 2019 07:52
N-Queens : AMPL
# Solution to the n-queens problem in AMPL
# Author: Varun Patil <radialapps@gmail.com>
# I dedicate any and all copyright interest in this software to the
# public domain. I make this dedication for the benefit of the public at
# large and to the detriment of my heirs and successors. I intend this
# dedication to be an overt act of relinquishment in perpetuity of all
# present and future rights to this software under copyright law.
reset;
@pulsejet
pulsejet / wpa_supplicant.conf
Created November 3, 2018 11:53 — forked from nihal111/wpa_supplicant.conf
Connect to IITB-Wireless through RPi. This config can be used to connect to any WPA2 Enterprise network in general. Just change the ssid, identity and password fields.
network={
ssid="IITB-Wireless"
scan_ssid=1
key_mgmt=WPA-EAP
identity="<your_username>"
password="<your_password>"
eap=PEAP
phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
}
@pulsejet
pulsejet / jpg2pdf.py
Created October 10, 2018 11:51
Convert all JPEG files in a directory to PDF
"""Converts all JPEG files in INPUT DIR to full size PDF.
requirements.txt
========================================
fpdf==1.7.2
========================================
Requires python 3.5+
"""
@pulsejet
pulsejet / resize-images.py
Created September 28, 2018 15:30
Resize images and convert to progressive JPG with pillow
from os import listdir
from os.path import isfile, join
from PIL import Image
mypath = '.'
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f)) and '.jpg' in f]
MAX_DIM = 800
for path in onlyfiles: