Skip to content

Instantly share code, notes, and snippets.

@JamesOBenson
JamesOBenson / gist:30a4ddcc789b76fe9184a3eb3d756537
Created July 13, 2016 13:41
R code to connect/disconnect, download & save data from remote SQL database
TO CONNECT:
library("RPostgreSQL")
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="postgres",host="dataport.pecanstreet.org",port=5434,user="username",password="password")
GETS EVERYTHING FROM THIS TABLE:
myTable <- dbReadTable(con, c("university", "electricity_egauge_15min"))
SELECT CERTAIN VALUES FROM A TABLE:
data <- dbGetQuery(con, "SELECT * from university.weather WHERE localhour BETWEEN '01-01-2015' AND '02-01-2015'")
@JamesOBenson
JamesOBenson / gist:4bce1e61e4d02524862cd47732a2159d
Created August 19, 2016 04:11
R basic parameters (par) to help create a great looking boxplot....
load("some_data.RData")
png(file=output.png",width=1200,height=1200)
par(cex.main = 1.5, mar = c(5, 6, 4, 5) + 0.1, mgp = c(3.5, 1, 0), cex.lab = 2.0,
font.lab = 2, cex.axis = 2.0, bty = "n", las = 1, family="serif")
boxplot(formula~categories,
data=mydata,
ylim=c(0,100),
cex.out = 1,
col="blue",
@JamesOBenson
JamesOBenson / Generating a secure SSH Key and commands
Last active January 20, 2026 19:42
SSH Generation and commands.
To find your public SSH key(s) on github, navigate to:
https://github.com/<username>.keys
ssh-keygen
-t ed25519 - for greatest security (bits are a fixed size and -b flag will be ignored)
-t rsa - for greatest portability (key needs to be greater than 4096 bits)
-t ecdsa - faster than RSA or DSA (bits can only be 256, 284, or 521)
-t dsa - DEEMED INSECURE - DSA limted to 1024 bit key as specified by FIPS 186-2, No longer allowed by default in OpenSSH 7.0+
-t rsa1 - DEEMED INSECURE - has weaknesses and shouldn't be used (used in protocol 1)
ping range of IP's
for x in {100..125}; do ping -c 1 -W 100 10.3.100.$x | grep 'time='; done
@JamesOBenson
JamesOBenson / README.md
Created November 30, 2016 22:04 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

Step 1: Create Volume in OpenStack (Can be completed in GUI)
CLI:
cinder create SIZE_IN_GB --display-name NAME
cinder create 10 --display-name mystorage
cinder list
Step 2: Attach volume to Openstack instance (Can be completed in GUI)
CLI:
nova volume-attach INSTANCE_ID VOLUME_ID auto
nova volume-attach myhost f14e47ab-18f6-4f85-bd17-a3f63a38d609 auto
Source: http://hints.macworld.com/article.php?story=20100113142633883
To have tab to complete from .ssh/config file in MacOS (Verified on MacOS 10.12.4),
vi ~/.bash_profile (New file)
# Copy and paste this line
complete -o default -o nospace -W "$(/usr/bin/env ruby -ne 'puts $_.split(/[,\s]+/)[1..-1].reject{|host| host.match(/\*|\?/)} if $_.match(/^\s*Host\s+/);' < $HOME/.ssh/config)" scp sftp ssh
source ~/.bash_profile
@JamesOBenson
JamesOBenson / json misc
Created September 6, 2017 15:20
Random json examples.
## Python 2.7
>>> import json
>>> import sys
>>>
>>> #load the data into an element
... data={"test1" : "1", "test2" : "2", "test3" : "3"}
>>>
>>> #dumps the json object into an element
... json_str = json.dumps(data)
@JamesOBenson
JamesOBenson / README
Created September 14, 2017 04:18 — forked from xbb/README
IDRAC6 Virtual Console Launcher
Use this as an example on how to start the virtual console without the need of Java Web Start or accessing it from the web interface.
You can use the user and password that you use for the web interface.
You need an old JRE... I used 1.7.0_80 from the Server JRE package, also I have tested successfully 1.7.0_79 with MacOS.
You don't need to install it, just extract it or copy the files in "jre" folder.
Open the viewer.jnlp file that you get by launching the virtual console from the web interface with a text editor.
Note the urls to the jar files. Download the main jar file avctKVM.jar and the libs for your operating system and architecture.
Extract the dlls (.so Linux, .jnilib MacOS) from the jar libs.
https://help.ubuntu.com/community/Router#Enable_IP_forwarding_and_Masquerading
4.5. Enable IP forwarding and Masquerading
Doing the above might not be enough to make the Ubuntu machine a real router which does NAT (Network Address Translation) and IP Forwarding. The following script configures the Kernel IPTable and IP forwarding. You will have to configure at least the script's 2 variables; the 1st is the external network interface; the 2nd is the internal network interface.
EXTIF="eth0"
INTIF="eth1"
The script was originally from a Ubuntu router guide forum article which has 2 internal network interfaces. What's showing below uses only 1 internal network interface. You will have to modify the script manually or use the script in the Ubuntu router guide forum article if you need to configure 2 internal network interfaces.
echo -e "\n\nLoading simple rc.firewall-iptables version $FWVER..\n"