Skip to content

Instantly share code, notes, and snippets.

Nilesh nileshtrivedi

Block or report user

Report or block nileshtrivedi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nileshtrivedi
nileshtrivedi / MainActivity.java
Last active Jan 8, 2019
HyperTrack Onboarding
View MainActivity.java
HyperTrackCore.requestLocationPermissions(this, new LocationPermissionCallback() {
@Override
public void onLocationPermissionGranted() {
// Handle location permission granted
}
@Override
public void onLocationPermissionDenied() {
// Handle location permission denied
}
@nileshtrivedi
nileshtrivedi / sample.py
Created Jun 18, 2018
Cloud Firestore - Python example
View sample.py
# This script can be used standalone
# So it doesn't depend on filesystem or Google Cloud for the credentials
from google.cloud import firestore
from google.oauth2 import service_account
key = 'your_credentials_json_string'
info = json.loads(key)
creds = service_account.Credentials.from_service_account_info(info)
@nileshtrivedi
nileshtrivedi / txn.sql
Created Mar 16, 2018
Transaction validation in database with Python (INCOMPLETE)
View txn.sql
CREATE EXTENSION IF NOT EXISTS plpythonu;
-- plpython is untrusted. Access needs to be controlled carefully
CREATE OR REPLACE FUNCTION py_test () RETURNS varchar AS $$
return 'hi'
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION py_create_ed25519_keypair ()
RETURNS varchar[]
View keybase.md

Keybase proof

I hereby claim:

  • I am nileshtrivedi on github.
  • I am nileshtrivedi (https://keybase.io/nileshtrivedi) on keybase.
  • I have a public key ASDS2qJDEl9_uy-LwMNZItAdCCU9ct2v6V57tlhS80cErgo

To claim this, I am signing this object:

@nileshtrivedi
nileshtrivedi / programming.md
Last active Jan 25, 2019
Programming: Mostly A Hate Story
View programming.md

Programming: Mostly A Hate Story

I wanted to do digital signatures validation, preferably ed25519, inside PostgreSQL triggers. Here is how it went:

Surely pgcrypto must be supporting it, right? Most Postgres cloud hosting providers already support pgcrypto so this would be perfect. Right?

Well, pgcrypto only supports PGP and that too excludes digital signatures. Let's give PGP a try anyway and see how far can we go.

Installed gpg to generate the keys and the experience is less than pleasant. Sometimes it gets stuck at the passphrase prompt. The keys are too big, but still I can make pgcrypto's pgp_pub_encrypt and pgp_pub_decrypt methods work. Just remeber to convert keys in ASCII to binary and vice-versa using armor()/dearmor(). I hate the big key size in RSA, even though GPG defaults to 2048-bit keys and not the more secure 4096-bit ones. Let's look into ed25519 now.

@nileshtrivedi
nileshtrivedi / sm.rb
Created Feb 2, 2018
Multiplication of two state machines
View sm.rb
a = {a: [:b, :c], b: [:c]}
def get_edges(sm)
res = []
sm.each do |s, e|
e.each do |d|
res.push([s,d])
end
end
res
@nileshtrivedi
nileshtrivedi / ed25519.sql
Last active Feb 14, 2018
ed25519 digital signature methods in PostgreSQL via PL/Python
View ed25519.sql
CREATE EXTENSION IF NOT EXISTS plpythonu;
CREATE FUNCTION py_create_ed25519_keypair ()
RETURNS varchar[]
AS $$
import axolotl_curve25519 as curve
import os
import base64
randm32 = os.urandom(32)
View blockstack
Verifying my Blockstack ID is secured with the address 15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm https://explorer.blockstack.org/address/15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm
@nileshtrivedi
nileshtrivedi / deploy.rb
Last active Jan 16, 2016
Deploy a Play framework app with SSHKit
View deploy.rb
require 'sshkit'
require 'sshkit/dsl'
# Once "bundle install" has been run, this script can be run as "ruby deploy.rb staging" or "ruby deploy.rb prod"
if ARGV.first == "prod"
servers = ['deploy@prod1.example.com', 'deploy@prod2.example.com']
elsif ARGV.first == "staging"
servers = ['deploy@staging.example.com']
else
View stereo.py
#!/usr/bin/python
# You need stereovision package to run this. Try "sudo pip install stereovision"
import cv2
from stereovision.blockmatchers import StereoBM, StereoSGBM
from stereovision.calibration import StereoCalibration
from stereovision.stereo_cameras import CalibratedPair
from stereovision.ui_utils import STEREO_BM_FLAG, BMTuner
You can’t perform that action at this time.