Skip to content

Instantly share code, notes, and snippets.

View abhn's full-sized avatar
🦊
Hey internet friend

Abhishek Nagekar abhn

🦊
Hey internet friend
View GitHub Profile
const toCamel = s => {
return s.replace(/([-_][a-z])/ig, ($1) => {
return $1.toUpperCase()
.replace('-', '')
.replace('_', '');
});
};
const isArray = a => {
return Array.isArray(a);
@abhn
abhn / script.py
Created March 7, 2019 15:06
Inserting new frontmatter fields to all of your posts at once, just above the ending '---' and beginning of the post matter
from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir('./') if isfile(join('./', f))]
for file in onlyfiles:
print(file)
if file == 'helper.py':
continue
with open(file, 'r') as myfile:
@abhn
abhn / keybase.md
Created July 6, 2018 18:17
keybase.md

Keybase proof

I hereby claim:

  • I am abhn on github.
  • I am abhn (https://keybase.io/abhn) on keybase.
  • I have a public key ASC2Qt0_C769tGtV0Z1LNDPyL3lj1BTMieseE3ZeNXwnNAo

To claim this, I am signing this object:

@abhn
abhn / hash.py
Created June 24, 2018 17:46
stanford crypto 1 week 3 practice
import hashlib
sha = hashlib.sha256()
f = open('vid1', 'rb')
chunklist = []
hashlist = []
tmp = f.read(1024)
@abhn
abhn / shardstorage.md
Last active June 23, 2018 14:13
Shard storage

Shard Storage

To ensure that the pieces of secrets ('shards') are not misplaced or stolen, and to avoid the possibility of losing your secret, there are some measures that need to be taken to ensure safe and secure storage of each shard. Here are some suggested ways of storing them.

Storage is two step process. There's the storage of the actual secret on a media, and then there's storage of the media itself. Let's call it technical and physical storage respectively. Listed below are some of the best practices for each.

The solution you choose depends upon your usecase and level of paranoia.

Technical Storage

  1. Cold storage in airgapped Tails persistence volume
  • Install Tails onto a USB stick, enable encrypted volume and save the shard on that volume.
@abhn
abhn / script.sh
Last active September 2, 2017 19:17
batch file encryption-decryption using GnuPG and rsync
# Encryption/Decryption script
# Requires "rync" (for incremental sync) and "gpg" (for encryption/decryption)
# Usage:
# Download this script
# $ chmod +x script.sh
### Encrypt
# (-e) (-s/--source) (-d/--destination) (-pf/--password-file)
# $ ./script.sh -e -s=./path/to/source-dir -d=./path/to/destination-dir -pf=./passfile.txt.gpg
@abhn
abhn / s3.py
Last active May 26, 2017 13:26
S3 Tool
import re
import sys, os
import httplib2
import boto3, botocore
from BeautifulSoup import BeautifulSoup, SoupStrainer
from optparse import OptionParser
# base url supplied. The search will move inward
globalBaseUrl = ""
globalLinkList = []
@abhn
abhn / pir.ino
Last active September 9, 2016 18:39
Arduino code for PIR
int ledPin = 7; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
@abhn
abhn / buttons.js
Last active June 27, 2016 16:44
The dynamic buttons javascript
var openTechnology = function (slug) {
document.location.href = 'http://' + document.location.hostname + 'technology/' + slug;
}
var openDomain = function (slug) {
document.location.href = 'http://' + document.location.hostname + 'domain/' + slug;
}
// techOrDomain should either be 'technology' or 'domain'
// parentDiv to append the result grid
@abhn
abhn / linkedlist.c
Last active May 4, 2016 06:36
linkedlist linkedlist.c
#include "linkedlist.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
struct node {
void *dataptr;
struct node *link;
char *type;