Skip to content

Instantly share code, notes, and snippets.

View santosh's full-sized avatar
:octocat:

Santosh Kumar santosh

:octocat:
View GitHub Profile
@santosh
santosh / docker_postgres.md
Last active May 20, 2020 19:30
Basic docker postgres setup for dev.
docker run -d --name postgres -e POSTGRES_PASSWORD=Pass2020! -v postgres-data:/var/lib/postgresql/data -p 5432:5432 postgres:11-alpine

More env vars at https://hub.docker.com/_/postgres.

Hop into the container:

docker exec -it postgres bash

And use the psql repl.

@santosh
santosh / description.md
Created April 29, 2020 18:05
How to test this func in handler.go?

I can run those tests on my local machine where I have mongo instance spinned up. But what about CI/CD services like Travis-CI?

How do I approach this?

@santosh
santosh / usestate.js
Created March 16, 2020 05:13
Using states in functional components.
function App() {
const [count, setCount] = React.useState(0)
function increment() {
setCount(prevCount => prevCount + 1)
}
function decrement() {
setCount(prevCount => prevCount - 1)
}
@santosh
santosh / reactforms.js
Created March 11, 2020 09:27
React Forms.
class App extends React.Component {
constructor() {
super()
this.state = {
firstName: "",
lastName: "",
age: null,
location: "",
gender: "",
dietaryRestrictions: {
@santosh
santosh / apicall.js
Created March 9, 2020 15:41
Fetching data from within #React component. Loading component can be added for smooth transition.
class App extends React.Component {
constructor() {
super()
this.state = {
character: {}
}
}
componentDidMount() {
this.setState({ loading: true })
@santosh
santosh / disable_callback.py
Created February 20, 2020 20:13
disable nuke callbacks for debugging
CALLBACKS = (
'beforeRenders',
'beforeFrameRenders',
'afterRenders',
'afterFrameRenders',
'updateUIs',
'autolabels',
'filenameFilters',
'onCreates',
'onDestroys',
@santosh
santosh / vectoraccess.cc
Created February 15, 2020 18:04
Vectors in C++ are more or less similar to what list is in Python.
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
vector<int> g1;
for (int i = 1; i <= 10; i++) {
g1.push_back(i * 10);
}
@santosh
santosh / custom_command.py
Created December 10, 2019 19:46
Custom command inside maya. Similarly custom nodes can be created. Part of ADN.
import maya.OpenMayaMPx as ommpx
import sys
class Sample(ommpx.MPxCommand):
kPluginCmdName = "foo"
def __init__(self):
ommpx.MPxCommand.__init__(self)
@santosh
santosh / composition.go
Created June 6, 2019 07:51
Composition with Go. #golang
package main
import "fmt"
// Board represents a surface we can work on
type Board struct {
NailsNeeded int
NailsDriven int
}
@santosh
santosh / channel_example.go
Created June 4, 2019 03:51
Simplest example of channels in Go. #golang
package main
import (
"fmt"
"math/rand"
"time"
)
func boring(msg string, c chan string) <-chan string {
for i := 0; ; i++ {