Skip to content

Instantly share code, notes, and snippets.

View devavret's full-sized avatar

Devavret Makkar devavret

View GitHub Profile
#include <unistd.h>
#include <iostream>
#include <err.h>
int main() {
pid_t pid = fork();
std::cerr << getpid() << ": Return value was: " << pid << std::endl;
if (pid == -1) err(2, "fork");
if (pid == 0) {
// child
@devavret
devavret / tmux_local_install.sh
Last active November 19, 2016 18:53 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.3
@devavret
devavret / powershell_move.ps1
Last active May 23, 2020 16:59
powershell to move files based on part of file name
# 1. Get a list of files in the d:\queries folder
$FileList = Get-ChildItem -Path d:\queries;
# 2. Parse file names, create folder structure, and move files
foreach ($File in $FileList) {
# Use regular expression to split up file name and assign pieces to field names of $matches
$File.Name -match '(?<folder>.*?)(?:_)(?<subfolder>\w{2})(?:_)(?<filename>.*)';
# $matches is a special variable which receives output of the -match operation, see http://www.powershelladmin.com/wiki/Powershell_regular_expressions