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
#!/bin/sh | |
die() { | |
printf '%s\n' "${1}" >&2 | |
exit 1 | |
} | |
ROLE_ARN="" | |
ROLE_SESSION_NAME="dev-${USER}" | |
EXTERNAL_ID="" |
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
# /etc/conf.d/redshift | |
DISPLAY="${DISPLAY:-:0}" | |
# Make it a function in case we have to repeat it in init script later | |
set_xauth() { | |
# common case (works in almost all tested environments (except of lightdm)): | |
#XAUTHORITY="$(ps wwax -C X,Xorg -o args= --sort=-stime | grep -m 1 -o '\B[-]auth\s*/var\S*' | cut -d ' ' -f 2)" |
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
#!/bin/bash | |
script=$(basename ${0}) | |
exec > >(tee -ia /var/log/${script}_out.log) # Redirect stdout to logfile and continue to print on stdout | |
exec 2> >(tee -ia /root/${script}_err.log >&2) # Redirect stderr to logfile and continue to print of stderr | |
echo stdout # Appears on stdout and in logfile | |
echo stderr >&2 # Appears on stderr and in logfile |
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
g.V() | |
// Find (single) vertex to change | |
.as('old') | |
.addV(select('old').label()) | |
.as('new') | |
.property(id, new_id) // Insert new ID for vertex here | |
.sideEffect( | |
select('old') |
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
#!/bin/bash | |
REPO_BASE="https://svn.repo/department/team" | |
LOCAL_BASE="${HOME}/svn" | |
backoff() { | |
local count iteration timeout output ret | |
timeout=1 | |
count=5 | |
iteration=0 |
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
#!/bin/bash | |
args=$(getopt n:t:r:o: ${*}) | |
if [ $? -ne 0 ] || [ $# -lt 1 ] | |
then | |
echo "Usage: ${0} [-n=<max-attempts>] [-t=<initial-timeout>] [-r=0] [-o=<output>] <command> <args...>" | |
echo "Runs <command> with <args> a maximum of <max-attempts> times until it succeeds. \"Succeeds\" is" | |
echo "defined as returning <r> to the shell (default 0) and printing <output> to the console." | |
echo "Waits <initial-timeout> between the first and second attempts, and doubles the timeout each time" |
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
#!/bin/bash | |
# This hook is sourced after a new virtualenv is activated. | |
pip install ipykernel | |
python -m ipykernel install --user --name $(basename ${VIRTUAL_ENV}) --display-name "$(basename ${VIRTUAL_ENV})" |
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
//\ | |
public class C { //\ | |
public static void main(String[] args) { //\ | |
System.out.println("hello"/* | |
#include <stdio.h> | |
int main() { | |
{ | |
return puts("world"/**/); | |
} | |
} |
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
#include <tuple> | |
#include <iterator> | |
#include <algorithm> | |
template <class InputIterator> | |
std::tuple<typename std::iterator_traits<InputIterator>::value_type, | |
InputIterator, InputIterator> | |
maximum_subarray(InputIterator first, InputIterator last) { | |
typedef typename std::iterator_traits<InputIterator>::value_type value_type; | |
using std::max; |
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
#include <stdio.h> | |
#include <inttypes.h> | |
#include <math.h> | |
uint64_t fibonacci(uint64_t n) { | |
static const double golden = 1.61803398874989484820; | |
return (uint64_t)floor((pow(golden, (double)n) / sqrt(5.0)) + 0.5); | |
} | |
NewerOlder