Skip to content

Instantly share code, notes, and snippets.

View dgovil's full-sized avatar

Dhruv Govil dgovil

View GitHub Profile
@dgovil
dgovil / CMakeLists.txt
Last active April 2, 2023 22:21
SQLite Cmake Sample
cmake_minimum_required(VERSION 3.25)
project(sqlite_example)
set(CMAKE_CXX_STANDARD 20)
find_package(SQLite3 REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${SQLite3_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${SQLite3_INCLUDE_DIRS})
@dgovil
dgovil / .dockerignore
Created July 25, 2020 04:16 — forked from NogaMan/.dockerignore
Gatsby Dockerfile
.cache/
node_modules/
public/
@dgovil
dgovil / pidcheck.rs
Created January 26, 2019 02:36
Get a list of parent pids using rust
use std::process;
fn get_parent_pid(pid: u32) -> Vec<u32> {
let mut pids: Vec<u32> = Vec::new();
// ps -o ppid=66393
let ret = process::Command::new("ps")
.arg("-o")
.arg(format!("ppid={}", pid))
.output();
@dgovil
dgovil / QActiveParent.py
Created December 24, 2018 00:03
Context Manager that adds any created widgets to a currently active widget
"""
I don't recommend using this but it was just exploring an idea of automatically adding widgets
"""
import sys
import inspect
from PyQt5 import QtWidgets
class ActiveParent(object):
@dgovil
dgovil / maya_moc.cmake
Last active December 18, 2020 21:53
Configuring Qt for Maya moc
# Do some setup for Maya's Qt
set(QT_VERSION_MAJOR 5)
# Set moc Path
set(QT_MOC_EXECUTABLE ${MAYA_BIN_PATH}/moc)
add_executable(Qt5::moc IMPORTED)
set_target_properties(Qt5::moc PROPERTIES IMPORTED_LOCATION ${QT_MOC_EXECUTABLE})
set(CMAKE_AUTOMOC TRUE)
# Set the UIC Path
@dgovil
dgovil / foo.py
Created September 18, 2017 01:33
Python Circular Imports
import spam
def goodbye(name):
print("Goodbye {0}".format(name))
if __name__ == '__main__':
print(spam.abc)
spam.greet('Dan')
@dgovil
dgovil / simplexInstaller.py
Created May 4, 2017 05:39
A simple installer script to install simplex by Blur. Simply run this in Python in maya
from maya import cmds as mc
import urllib2
import os
import zipfile
import shutil
def downloadRelease():
userTmpDir = mc.internalVar(userTmpDir=True)
dest = os.path.join(userTmpDir, 'simplex.zip')
@dgovil
dgovil / pyside_dynamic.py
Created April 6, 2017 00:09 — forked from cpbotha/pyside_dynamic.py
pyside_dynamic.py with minor improvements - also see http://stackoverflow.com/a/14894550/532513
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Sebastian Wiesner <lunaryorn@gmail.com>
# Modifications by Charl Botha <cpbotha@vxlabs.com>
# * customWidgets support (registerCustomWidget() causes segfault in
# pyside 1.1.2 on Ubuntu 12.04 x86_64)
# * workingDirectory support in loadUi
# found this here:
# https://github.com/lunaryorn/snippets/blob/master/qt4/designer/pyside_dynamic.py
@dgovil
dgovil / mayaFileImportNodeQuery.py
Created January 21, 2017 04:20
Finding what nodes were imported from a Maya file
# First lets import our Maya command library
from maya import cmds
# Then we import our file. In this case I'm using a hardcoded value
# But notice the returnNewNodes parameter that tells it to give us back any imported nodes
# This may contain nodes we don't want
# So we'll need to shorten it down
nodes = cmds.file('C:/Users/dhruv/Documents/maya/controllerLibrary/bigdonut.ma',
i=True, returnNewNodes=True)
@dgovil
dgovil / windowPositions.py
Created January 21, 2017 04:08
Saving Window Positions in PyQt or PySide
# First lets import the two modules we'll need from Qt
from Qt import QtWidgets, QtCore
# Then we create our Window class, in this case from a QDialog
class MyWindow(QtWidgets.QDialog):
def __init__(self):
# We use the __init__ method to initialize it
# The super function gets the class we are inheriting from (in this case QDialog) and calls its' __init__ as well