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
View india_twitter_muted_words_list.md

To bring some sanity to your twitter feed, add these words to your muted list here: https://twitter.com/settings/muted_keywords

Needless to say, this is highly subjective and may not be applicable to how you want to use Twitter. Many of these conversations are important, but I have those on other platforms, not Twitter.

Other people's likes

suggest_recycled_tweet_inline

suggest_activity_tweet

@nileshtrivedi
nileshtrivedi / composable_web.md
Last active Dec 13, 2019
My thoughts on making the Web more composable like UNIX
View composable_web.md

The Composable Web Proposal

Serverless infrastructure like AWS Lambda and Google Cloud Functions have made it much cheaper for developers to offer server-side code for public consumption without keeping a server always running.

If these functions could be declared as stateless or deterministic, costs can be brought down even more because only the first invocation needs to be executed. Cached response could be returned for future invocations with the same input arguments.

All modern browsers support URL lengths of thousands of characters, even on mobile. A lot of data can be embedded and passed around directly in the URLs (instead of passing identifiers which requires a look-up which costs server time).

So here's a thought:

@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
You can’t perform that action at this time.