Skip to content

Instantly share code, notes, and snippets.

Chat GPT prompt for generating first pass malli schemas:
```
I have a set of react components written in ClojureScript. These components form the design system of a react-native application. I want to introduce prop type checking for these components using the Malli Spec Library.
Here's an example of how we spec a component
start-clojure-code---
(def ?schema
[:=>
[:catn
{
"pubkey": "3fA3QiNEFgZwSxqRnvqAqRmX2P5eUUngCv79ApEdz2Hc",
"info": {
"executable": false,
"owner": {
"_bn": "0b7065b1e3d17c45389d527f6b04c3cd58b86c731aa0fdb549b6d1bc03f82946"
},
"lamports": 5616720,
"data": {
"type": "Buffer",
@shivekkhurana
shivekkhurana / 0.json
Last active August 5, 2022 02:41
Generate NFTs with Candy Machine v2
{
"name": "Tara Base Card",
"description": "Tara universe is a demo project to showcase the power of Meta Blocks Protocol. This base card is where the story begins.",
"image": "0.png",
"attributes":
[
{
"trait_type": "texture",
"value": "futuristic"
},
@shivekkhurana
shivekkhurana / hooks-with-reagent.cljs
Last active August 7, 2023 22:32
Using React hooks with Reagent
;; Reagent component that depends on Ratom
(def counter-state (r/atom 0))
(defn counter [params]
[:<>
[:div (str params)]
[:div @counter-state]
[:button {:on-click #(swap! counter-state inc)} "Inc"]])
;; Wrapper component that will be rendered as React element, will call hooks and pass values from hooks to Reagent component
;; currently using `useParams` hook from `react-router-dom`, but any hook can be used
@shivekkhurana
shivekkhurana / karuna2020Runtime.js
Created April 27, 2020 15:32
The JavaScript model of the Karuna 2020 runtime
async funtion main() {
// call the godown manager and inquire about inventory
const inventory = await getGodownStatus(godownManagerContact);
// get request details (generally from a whatsapp message)
const distributionRequest = await fetchReqestDFetails();
// an id is needed for our records and we'll only distribute at places where we have strong ground control
const isRequestValid = await beneficieriesHaveAUniqueId(distributionRequest) && await weTrustRequesters();
@shivekkhurana
shivekkhurana / install-docker.sh
Created January 16, 2020 08:08
Install Docker and Docker Compose on a Ubuntu Machine (Tested on AWS)
#!/bin/sh
set -eu
# Docker
sudo apt remove --yes docker docker-engine docker.io || true
sudo apt update
sudo apt --yes --no-install-recommends install apt-transport-https ca-certificates
wget --quiet --output-document=- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@shivekkhurana
shivekkhurana / FadeRoute.js
Last active January 2, 2018 18:03 — forked from mhaagens/gist:61f88e3fbfddbe2c00708f3ebd099be4
Transition Motion React Router 4 Route Transition
import React from 'react';
import {Route} from 'react-router-dom';
import PropTypes from 'prop-types';
import {TransitionMotion, spring} from 'react-motion';
const FadeRoute = ({component: Component, ...rest }) => {
return (<Route {...rest} children={({location, match}) => (
<TransitionMotion
willEnter={() => ({opacity: 0})}
willLeave={() => ({opacity: spring(0)})}

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@shivekkhurana
shivekkhurana / keducer.js
Created December 7, 2017 06:27
Automate writing redux reducers
export default function keducer(prefix, actionMutationMap={}) {
return (state={}, action) => {
return actionMutationMap[action.type] ?
actionMutationMap[action.type](state, action.payload) :
action.type.indexOf(`${prefix}.`) === 0 ? {…state, …(action.payload)} : state
;
};
}
@shivekkhurana
shivekkhurana / main.py
Created June 25, 2017 07:36
Listen to multiple rethinkdb change feeds with python(3.6) using asyncio
import rethinkdb as r
import asyncio
from typing import Callable, Dict
r.set_loop_type('asyncio')
async def get_connection():
return await r.connect(
db='test',