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
#Connect to this using websockets on port 9454 | |
#Send in the format of {"data":[1,2,3]} | |
#The ppp returns the standard deviation of the sent array | |
library(jsonlite) | |
library(httpuv) | |
#server | |
app <- list( | |
onWSOpen = function(ws) { | |
ws$onMessage(function(binary, message) { | |
write(message, file = "log.txt",append = TRUE, sep = "\n") |
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
<?php | |
$url = 'https://api.smartystreets.com/street-address?'; | |
$url .= 'auth-id=[auth-id]&auth-token=[auth-token]'; | |
$url .= '&street=' . $street . '&zipcode=' . $zip; | |
$urlData = json_decode(file_get_contents($url),true); | |
//print_r($urlData); | |
if(isset($urlData[0]['metadata']['latitude'])) { | |
$latitude = $urlData[0]['metadata']['latitude']; | |
$longitude = $urlData[0]['metadata']['longitude']; |
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
//server | |
sudo apt-get update | |
sudo apt-get install lxc wget bsdtar curl | |
sudo apt-get install linux-image-extra-$(uname -r) | |
sudo apt-get install gcc | |
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash | |
//user |
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
#Route port 3000 to 80 | |
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000 | |
#Search for running node.js processes | |
ps aux | grep node | |
#Kill process | |
kill -9 [id] | |
#Run node.js after closing shell |
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
#Define the interval to cycle through | |
interval <- 30 | |
#Replace sample_vector with your vector | |
sample_vector <- runif(100, 1, 10) | |
#Loop through each break in the sequence | |
for(i in seq(1,length(sample_vector),interval)) { | |
#Used to prevent the sequence from extending beyond the remainders | |
if(i+interval>=length(sample_vector)) { | |
#Vector access for this sequence is as follows: | |
print(sample_vector[i:length(sample_vector)]) |
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
vector <- c(10,1,0,10,0,0,10,0,0,10) | |
matches <- find_patterns(vector,seq(2,3)) | |
find_patterns <- function (vector, intervals) { | |
matches <- matrix(c(NA, NA), nrow=1, ncol=2) | |
for(interval in intervals) { | |
for(i in 1:interval) { | |
if(sd(vector[seq(i,length(vector),interval)])==0) { | |
if(is.na(matches[1,1])) { | |
matches[1,] <- c(vector[i],interval) |
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
vector <- c(10,1,0,10,0,0,10,0,0,10) | |
match_interval(vector,3)) | |
match_interval <- function (vector, interval) { | |
matches <- c() | |
for(i in 1:interval) { | |
if(sd(vector[seq(i,length(vector),interval)])==0) { | |
matches[length(matches)+1] <- vector[i] | |
} | |
} |
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
awk -F"," 'NR>1 {print $0 >> ($1 ".csv"); close($1 ".csv")}' file.csv |
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
<?php | |
function createDateRangeArray($startDate,$endDate) | |
{ | |
$range[0] = $startDate; | |
$startDateInt = preg_replace('/[^0-9]/', '', $startDate); | |
$endDateInt = preg_replace('/[^0-9]/', '', $endDate); | |
if($endDateInt>$startDateInt) | |
{ | |
while($range[count($range)-1]!=$endDate) |
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
<?php | |
define('DB_NAME', 'zip'); | |
/** MySQL database username */ | |
define('DB_USER', '*****'); | |
/** MySQL database password */ | |
define('DB_PASSWORD', '*****'); | |
/** MySQL hostname */ |