This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import atexit | |
import ldap3 | |
__LDAP_USER = "" | |
__LDAP_PASSWORD = "" | |
__LOCKED_STR = b"LOCKED" | |
__USERS = "ou=users,dc=unity,dc=rc,dc=umass,dc=edu" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
prepend_path() { | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "usage: prepend_path <directory> <env.var>" | |
echo "e.g. prepend_path ~/.local/bin PATH" | |
echo "received: prepend_path $@" | |
return 1 | |
fi | |
local dir="$1" | |
local env_var="$2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# assuming that username is LDAP `cn` and email is LDAP `mail` | |
USERS="ou=users,dc=unity,dc=rc,dc=umass,dc=edu" | |
ldapsearch -LLL -x -o ldif-wrap=no -b $USERS mail cn | | |
grep -v dn: | # delete lines that have `dn:` | |
tr '\n' ',' | # replace newlines with command | |
sed -r 's/\,{2,}/\n/g' | # replace multiple commans with a newline | |
sed -r 's/mail: (.*),cn: (.*)/cn: \2,mail: \1/g' | # if string is `mail,cn` rearrange it to be `cn,mail` | |
sed 's/mail: //g' | # remove `mail: ` | |
sed 's/cn: //g' # remove `cn: ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print to stderr. If stderr is a TTY, print in red | |
def print_err(*args, **kwargs): | |
if sys.stderr.isatty(): | |
print('\033[1;31m', end='', file=sys.stderr) | |
print(*args, **kwargs, file=sys.stderr) | |
if sys.stderr.isatty(): | |
print('\033[0m', end='', file=sys.stderr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import bisect | |
import math | |
N = 4 # number of different tasks | |
T_MAX = 25 # how many time steps to simulate | |
MIN_PERIOD = 2 #integer! | |
MAX_PERIOD = 9 #integer! | |
class Task: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def indent(string: str, indenter=" ", num_indents=1) -> str: | |
for i in range(num_indents): | |
string = indenter + string # first line | |
string = string.replace('\n', '\n'+indenter) # all other lines | |
return string | |
def remove_empty_lines(string: str) -> str: | |
return re.sub(r"\n{2,}", '\n', string) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ls="ls --color=auto -F --quoting-style=shell" | |
alias la="ls -a" | |
alias ll="ls -la" | |
alias cp="cp -v" | |
alias rm="rm -v" | |
alias mv="mv -v" | |
alias chmod="chmod -v" | |
alias chown="chown -v" | |
alias df="/bin/df -h --output=source,size,used,avail,pcent,file" | |
alias cdp="cd $OLDPWD" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-Write-Privs{ | |
param([string]$filename) | |
$acl = Get-Acl $filename | |
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users", "Write", "Deny") | |
$acl.AddAccessRule($rule) | |
Set-Acl $filename $acl | |
} |
NewerOlder