This file contains 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
# convert base10 number to desired base | |
def convertbase(num, base): | |
mods = [] | |
while num >= base: | |
mods.append(num % base) | |
num = num / base | |
if num <= base: | |
mods.append(num) | |
mods.reverse() |
This file contains 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 os | |
def file_len(fname): #get file linecount | |
if os.stat(fname).st_size == 0: | |
return 0 | |
with open(fname) as f: | |
for i, l in enumerate(f): | |
pass | |
return i+1 |
This file contains 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 os, datetime, random | |
while True: | |
os.system('clear') | |
print "ENTER to continue, or type 'quit'" | |
print datetime.datetime.now() | |
print '' | |
print(random.choice(('Left', 'Right'))) | |
print '' | |
prompt = raw_input("") | |
if prompt == 'quit': |
This file contains 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 python | |
def add_ints(*args): | |
return_sum = 0 | |
for i in args: | |
if type(i) in [list, tuple]: | |
for list_key in i: | |
return_sum += add_ints(list_key) | |
if type(i) == dict: |
This file contains 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
:: Requires Administrator | |
:: Copies entire GP object directory from system32 to current working directory | |
@echo off | |
setlocal EnableExtensions | |
setlocal | |
set "dirname=.\policyobjects - %DATE% %TIME%" | |
takeown /a /f %systemroot%\system32\grouppolicy /r /d y | |
xcopy %systemroot%\system32\grouppolicy "%dirname%" /s /h /i /y |
This file contains 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
:: This is not mine! | |
:: This is almost verbatim from an answer on stack exchange! | |
@echo off | |
setlocal EnableDelayedExpansion | |
setlocal | |
:getTime | |
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do ( | |
set "dt=%%a" |
This file contains 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
@echo off | |
:readCfgs | |
for %%A in (%~dp0*.cfg) do ( | |
for /f %%B in (%%A) do ( | |
set "varName=%%~nA" | |
set "!varName!=" | |
set "!varName!=%%B" | |
) | |
) | |
goto :EOF |
This file contains 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
:: Delete self, handy for scripts you need manually | |
:: copy and deploy to lots of machines | |
:: Pretty sure I stole this from SS64. | |
set "batchPath=%~0" | |
echo Set objFSO = CreateObject( "Scripting.FileSystemObject" ) > "%~dp0temp.vbs" | |
echo objFSO.DeleteFile( "!batchPath!" ) >> "%~dp0temp.vbs" | |
echo objFSO.DeleteFile WScript.ScriptFullName >> "%~dp0temp.vbs" | |
echo WScript.Quit >> "%~dp0temp.vbs" | |
"%~dp0temp.vbs |
This file contains 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/fish | |
set currentbranch (git branch | awk '{print $2}' | grep -v -e '^$'); | |
set otherbranches (git branch | awk '{print $1}' | grep -v -e '\*'); | |
git pull; | |
for i in $otherbranches | |
git checkout $i |
This file contains 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
class Person(object): | |
alive = True | |
def __init__(self, name, height): | |
self.name = name | |
self.height = height | |
def sayname(self): | |
print("Hi, name is ", self.name, " and I am ", self.height, " feet tall!") |
OlderNewer