Skip to content

Instantly share code, notes, and snippets.

## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@fredrikaverpil
fredrikaverpil / sql-backup.bat
Last active August 29, 2015 13:56
mySQL BAT backup script
REM Export all data from this database
cd C:\Program Files\MySQL\MySQL Server 5.6\bin
REM To export to file (structure only)
mysqldump --no-data [DATABASENAME] -h localhost -u [USER] -p[PASSWORD] > C:\databackup\database_ddl_backup.sql
mysqldump --no-create-info --no-create-db [DATABASENAME] -h localhost -u [USER] -p[PASSWORD] > C:\databackup\database_data.sql
@fredrikaverpil
fredrikaverpil / padding.py
Last active March 23, 2017 01:26
Add padding to number #python
# Make 13 into 0013
'{:04}'.format(13)
@fredrikaverpil
fredrikaverpil / get_set_values.py
Last active November 26, 2022 22:27
Get and set knob values #nuke
# Get all nodes of type Read
readnodes = nuke.allNodes('Read')
for readnode in readnodes:
print readnode
# List all knobs for selected node
print( nuke.toNode('Read1') )
# List all knobs for specific node
print( nuke.selectedNode() )
@fredrikaverpil
fredrikaverpil / nuke_traverse_backwards.py
Created March 25, 2014 12:58
Traverse backwards folderpath to find a folder #nuke
def traverseBackwardsAndFindFolder( startPath, searchForFolder ):
# Usage example: traverseBackwardsAndFindFolder( nuke.root().name(), 'render' )
returnPath = ''
for i in range(len(startPath.split('/'))):
startPath = startPath[:startPath.rfind('/')]
# Check if it exists
if (os.path.isdir(startPath + '/' + searchForFolder)):
returnPath = startPath + '/' + searchForFolder
@fredrikaverpil
fredrikaverpil / nuke_environment.py
Last active August 29, 2015 13:57
Get environment settings #nuke
# List Nuke's environment settings
print( nuke.root() )
# Nuke script's filename
print( os.path.basename( nuke.root().name() ) )
# Nuke script's directory
print( os.path.dirname( nuke.root().name() ) )
@fredrikaverpil
fredrikaverpil / get_subdirs.py
Created March 25, 2014 13:04
Get subdirectory of directory #python
def getSubdirs( directory ):
for item in os.listdir( directory ):
# print path to all subdirectories first.
if os.path.isdir( os.path.join( directory, item ) ):
print item
@fredrikaverpil
fredrikaverpil / find_dir.py
Created March 25, 2014 13:05
Find directory based on search string #python
# This searches for a sequence of characters
import os
def checkForDir(searchDirs, partialOrFullDirNameToFind):
for searchDir in searchDirs:
for directory in os.listdir(searchDir):
if partialOrFullDirNameToFind in directory.lower():
foundDirectories.append(searchDir + directory)
return str(foundDirectories[len(foundDirectories)-1])
@fredrikaverpil
fredrikaverpil / walk_with_filetype_filter.py
Last active March 12, 2022 06:43
Walk folder and filter on filetype #python
import os, fnmatch
startDirectory = 'C:/temp'
filetypes = ['*.jpg', '*.exr']
for root, dirs, files in os.walk( startDirectory ):
for extension in ( tuple(filetypes) ):
for filename in fnmatch.filter(files, extension):
filepath = os.path.join(root, filename)
if os.path.isfile( filepath ):
@fredrikaverpil
fredrikaverpil / walk_search_replace.py
Created March 25, 2014 13:07
Walk folder and search and replace in files #python
import os
startDirectory = "c:/temp/"
searchString = "maya2012"
replacement = """multiline
string"""
for dname, dirs, files in os.walk(startDirectory):
for fname in files:
if ".ma" in fname:
fpath = os.path.join(dname, fname)