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 / 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++ {
@santosh
santosh / binarytree.py
Created June 1, 2019 08:47
Implementation of binary tree in Python. #DataStructures
class Node:
"""
This Node class has been created for you.
It contains the necessary properties for the solution, which are:
- text
- next
"""
def __init__(self, data, value):
self.data = data
@santosh
santosh / stack.py
Created June 1, 2019 06:02
Stack implementation in Python. #DataStructure
class Node:
""" This Node class has been created for you.
It contains the necessary properties for the solution, which are:
- text
- next
"""
def __init__(self, name):
self.name = name
self.__next = None
@santosh
santosh / queue.py
Created June 1, 2019 05:05
Queue implementation in Python. #DataStructure
class Node:
"""This Node class has been created for you.
It contains the necessary properties for the solution, which are:
- name
- phone
- next
"""
def __init__(self, name, phone):
self.name = name
@santosh
santosh / linkedlist.py
Last active June 1, 2019 05:03
Linked List implementation in Python. #DataStructure
class Node:
"""This Node class has been created for you.
It contains the necessary properties for the solution, which are:
- name
- matric
- year
- next"""
def __init__(self, name, matric, year):
self.name = name
@santosh
santosh / connectionpool.py
Last active August 24, 2021 05:16
Connection pooling with PostgreSQL in Python.
from psycopg2.extras import DictCursor
from psycopg2.pool import SimpleConnectionPool
class Database:
__pool = None
@classmethod
def initialize(cls, **kwargs):
cls.__pool = SimpleConnectionPool(minconn=2,