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 boto3 | |
| from base64 import b64decode | |
| import json | |
| from urllib2 import urlopen, Request | |
| ENCRYPTED_GITHUB_TOKEN = ( | |
| # aws kms encrypt --profile <PROFILE_NAME> --region <REGION> | |
| # --key-id <KMS_KEY_ID> --plaintext <GITHUB_ACCESS_TOKEN> | |
| # --query CiphertextBlob --output text | |
| ) |
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
| ( echo "PASSWORD" ; echo "COMMAND" ) | pssh -t 1 -h ~/host_list -P -I "sudo -S su -" |
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
| class dotdict(dict): | |
| def __getattr__(self, attr): | |
| return self[attr] | |
| def __missing__(self, key): | |
| self[key] = dotdict() | |
| return self[key] | |
| __setattr__ = dict.__setitem__ |
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
| # Send VT100 "Report Device OK" every 60 seconds to keep SSH from timing out | |
| notidle() { printf "\033[0n"; sleep 60; notidle; } | |
| PARENT_CMD=$(/bin/ps -ocommand= -p $PPID) | |
| if [ ${PARENT_CMD:0:5} = "sshd:" ]; then | |
| { notidle 2>&3 & } 3>&2 2>/dev/null | |
| fi |
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
| cat | cc -xc -o time - | |
| #include <stdio.h> | |
| #include <sys/time.h> | |
| int main(void) | |
| { | |
| struct timeval time_now; | |
| gettimeofday(&time_now,NULL); | |
| printf ("%ld secs, %d usecs\n",time_now.tv_sec,time_now.tv_usec); | |
| return 0; |
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 os | |
| import sys | |
| from xml.sax import parse | |
| from xml.sax.saxutils import XMLGenerator | |
| class CycleFile(object): | |
| def __init__(self, filename): | |
| self.basename, self.ext = os.path.splitext(filename) | |
| self.index = 0 |
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
| sub do_something { | |
| my $path = shift; | |
| # Skip this if another server is already working on it | |
| return unless my $lock = LinkLock->lock($path); | |
| my $users = Get_arrayref_from_database(); | |
| open my $fh, '>', $path; | |
| print $fh join( ':', @$_ ), "\n" for @$users; |
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
| var gmaps = "//www.google.com/maps/preview#!q="; | |
| function coordsToGmaps(){ | |
| var anchors = document.getElementsByClassName('external'); | |
| var i = anchors.length; | |
| while ( i-- ) { | |
| var a = anchors[i]; | |
| if ( a.href.match( /geohack/ ) ) { | |
| var geodec = a.querySelectorAll('.geo-dec'); | |
| var latlong = geodec[0].textContent; |
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
| # .bash_profile | |
| # Get the aliases and functions | |
| if [ -f ~/.bashrc ]; then | |
| . ~/.bashrc | |
| fi | |
| # User specific environment and startup programs | |
| bind '"\e[A":history-search-backward' |
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/perl -nl | |
| next unless ($p) = /(\d+)-\d+$/; | |
| s/\\n.*//; | |
| s/.*\ - //; | |
| s/{{{/{/ and $t{$p}{++$d{$p}} = 0; | |
| s/}}}/}/ and --$d{$p} and /(\d+\.\d+)/ and $t{$p}{$d{$p}} += $1 and $a = $t{$p}{$d{$p}+1} and $r = round($1-$a) and s{$}{ / $r}; | |
| print; | |
| sub round { int($_[0]*10000+.5)/10000 } |