Skip to content

Instantly share code, notes, and snippets.

View ryanbarrett's full-sized avatar

ryanbarrett

View GitHub Profile
@ryanbarrett
ryanbarrett / cron.start.if.not.running.sh
Created July 2, 2015 02:00
Crontab; start a program if it is not running
#!/bin/sh
if ps -ef | grep -v grep | grep program.sh ; then
exit 0
else
~/scripts/program.sh >> /dev/null &
echo "Restarting program.sh, it was not running." | wall
exit 0
fi
@ryanbarrett
ryanbarrett / argparse_template.py
Last active September 1, 2015 21:03
Argparse template
import argparse
argparser = argparse.ArgumentParser(description='Arguments that may be parsed.',epilog="The Epilog")
argparser.add_argument('--test',action='store_true',help='Simulate the Run')
argparser.add_argument('--dir','-d',type=str,required=True,help='Required variable "dir" with the following text as its value. i.e. --dir /test/123/ ')
argparser.add_argument('--optionaldefault','-o',default="the default value",type=str,help='Creates a variable "optionaldefault" ')
argparser.add_argument('--integer','-i',default=0,type=int,help='Creates a variable "integer" with the value 0 if nothing is specified.')
args = argparser.parse_args()
@ryanbarrett
ryanbarrett / MainWindow.xaml
Created April 24, 2012 21:56
Update View from View Model
<Window x:Class="_0message.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox HorizontalAlignment="Left" Margin="12,266,0,0" Name="tbSendMessageText" VerticalAlignment="Top" Width="392" Height="auto" AcceptsReturn="False" Text="{Binding SendText, Mode=TwoWay}" />
<TextBlock Height="248" HorizontalAlignment="Left" Margin="12,12,0,0" Name="tbReceiveMessage" VerticalAlignment="Top" Width="479" Text="{Binding ReceivedText, Mode=TwoWay}" />
<Button Content="Send" Height="23" HorizontalAlignment="Left" Margin="416,266,0,0" Name="bSend" VerticalAlignment="Top" Width="75" Command="{Binding Send}" />
</Grid>
# Add to ~/.bashrc, ~/.profile, or similar
# Usage:
# $gh nano
# Returns:
# 50 nano .bashrc
function gh { history | grep $1; }
@ryanbarrett
ryanbarrett / interfaces
Last active December 22, 2015 10:09
Ubuntu /etc/network/interfaces with static IP
auto eth0
iface eth0 inet static
address 10.10.10.10
netmask 255.255.255.0
gateway 10.10.10.1
dns-nameservers 8.8.8.8 8.8.4.4
dns-search domain.com
@ryanbarrett
ryanbarrett / nodejsserver
Last active December 22, 2015 10:09
init.d script for node js. Put in /etc/init.d/ and run update-rc.d nodejsserver
#!/bin/bash
NODE=/usr/bin/nodejs
SERVER_JS_FILE=/scripts/server.js
USER=username
OUT=/var/log/nodejs.log
case "$1" in
start)
@ryanbarrett
ryanbarrett / btsync
Last active January 3, 2016 10:09
Bittorrent Sync btsync Ubuntu Autostart script init.d To Export config file sample: ./btsync --dump-sample-config > sync.conf
#! /bin/sh
# /etc/init.d/btsync
#
# Carry out specific functions when asked to by the system
case "$1" in
start)
/etc/btsync/btsync --config /etc/btsync/sync.conf
;;
stop)
@ryanbarrett
ryanbarrett / gist:f850f734d68ab98e7059
Last active January 6, 2016 05:15
Disable IPv6 in Ubuntu
#Tried this, It did not work:
# Put at bottom of /etc/sysctl.conf:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
# Then run:
sudo sysctl -p
@ryanbarrett
ryanbarrett / .screenrc.prettyping
Created June 1, 2016 15:34
using denilsonsa/prettyping to ping 8 network nodes and display in one terminal session. (Screen version 4.03.01 (GNU) 28-Jun-15)
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{..G}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a"
screen -t host0 0 /home/user/bin/prettyping host0
screen -t host1 1 /home/user/bin/prettyping host1
screen -t host2 2 /home/user/bin/prettyping host2
screen -t host3 3 /home/user/bin/prettyping host3
screen -t host4 4 /home/user/bin/prettyping host4
@ryanbarrett
ryanbarrett / .screenrc
Last active June 11, 2016 19:03 — forked from jbeluch/.screenrc
Basic .screenrc
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{..B}%n %t %=%{..B} %H %{..B} %m/%d %C%a"
defscrollback 30000
screen -t bash0 0
screen -t bash1 1
screen -t pypthon 2 python