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:
I hereby claim:
To claim this, I am signing this object:
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.
| 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 |
| 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) |
| Verifying my Blockstack ID is secured with the address 15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm https://explorer.blockstack.org/address/15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm |
| 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 |
| #!/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 |
| # Allows you to build a Hash in a fashion very similar to Builder. Example: | |
| # Fork of https://gist.github.com/360506 by BrentD with some enhancements | |
| # | |
| # HashBuilder.build! do |h| | |
| # h.name "Nilesh" | |
| # h.skill "Ruby" | |
| # h.skill "Rails" # multiple calls of the same method will collect the values in an array | |
| # h.location "Udaipur, India" do # If a block is given, first argument will be set as value for :name | |
| # h.location do | |
| # h.longitude 24.57 |
| # TODO | |
| # if a var has a value, it also needs a name. This should not be necessary. Variable.initialize should accept hashargs | |
| # Expression.to_s should output in infix-notation (like normal humans) | |
| # add more syntactic sugar by manipulating Ruby Numeric classes. Add symbolic operators to Ruby's Numeric | |
| # If symbolic expression contains variables without value then it should return nil (should it, really?) | |
| # Implement additional operators like ** | |
| # All symbolic expression should be automatically simplified when created: | |
| # cons(0) * x # => 0 | |
| # 2 + x + 1 # => x + 3 | |
| # -(x-y) + 2*x # => x + y |
| # My attempt to implement a simple virtual machine with a minimal instruction set | |
| # 8-bit computer, fixed-size memory, single cpu, 0-registers, based on von-neumann architecture | |
| # No support for interrupts or I/O although we cheat and provide a "print" instruction :) | |
| # The goal is to find a minimal, but turing-complete, instruction set | |
| # For simplicity, every instruction has two operands, which are located adjacent to it in the memory | |
| # This code is just to experiment with various instruction sets and not to be taken seriously | |
| # Next fun step would be to develop a language/compiler for this virtual machine | |
| class Memory | |
| def initialize(size, program) |