Skip to content

Instantly share code, notes, and snippets.

Verifying my Blockstack ID is secured with the address 15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm https://explorer.blockstack.org/address/15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm
@nileshtrivedi
nileshtrivedi / sm.rb
Created February 2, 2018 06:22
Multiplication of two state machines
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

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 / txn.sql
Created March 16, 2018 09:26
Transaction validation in database with Python (INCOMPLETE)
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[]
@nileshtrivedi
nileshtrivedi / sample.py
Created June 18, 2018 06:22
Cloud Firestore - Python example
# 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 / MainActivity.java
Last active January 8, 2019 12:05
HyperTrack Onboarding
HyperTrackCore.requestLocationPermissions(this, new LocationPermissionCallback() {
@Override
public void onLocationPermissionGranted() {
// Handle location permission granted
}
@Override
public void onLocationPermissionDenied() {
// Handle location permission denied
}

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 / worldview.md
Created May 12, 2020 01:50
WorldView : A personal beliefs management system

WorldView

This is the idea for an app I have wanted to build for many years. This would be a database of personal beliefs (also known as a "Propositional Knowledge Base"), connected via logical arguments of various kinds: deductive, inferential and Bayesian. Any new facts you learn should update the certainties of the involved beliefs and propagate that through the graph. You could build a social network around it, giving all users a chance to learn from each other's worldview. This would also help one detect inconsistencies and contradictions. The challenge here is to allow local contradictions without blowing up the system as Principle of Explosion implies.

Related links:

@nileshtrivedi
nileshtrivedi / html-mocker.js
Last active July 11, 2020 09:32
HTML Mocker
/*
This is an idea for mocking HTML data that lets you test whether your layout breaks on any screen size for any
unexpected dynamic data.
This script scans the document for class names with a specific pattern and periodically randomizes the content
of those elements while meeting the constraints specified in the class name. This can let you quickly test
whether your layout breaks for any dynamic content that you may not have thought about. This should ideally be used
with a responsive design testing tool such as DevTools or Sizzy/Bizzy.
@nileshtrivedi
nileshtrivedi / chatbot.rb
Last active October 27, 2020 07:29
A stateful chatbot to capture data in 50 lines of Ruby
# https://medium.com/cleartax-engineering/a-simple-rule-based-stateful-chatbot-for-data-capture-ebfad9271388
require 'ostruct'
# Track the current state of the conversation
state = {pointer: ""}
# Metadata is used to fill the outgoing templates AND store the captured data from conversation
metadata = {name: "Calvin"}