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
import requests | |
import base64 | |
import json | |
import datetime | |
def push_to_repo_branch(gitHubFileName, fileName, repo_slug, branch, user, token): | |
''' | |
Push file update to GitHub repo | |
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
## Randomly sample a given percentage of lines from files in a directory | |
## and write them out to a file | |
## | |
sampleFiles <- function(dir = './', ofname, perc = 1, append = TRUE, seed = 1234) { | |
## 'dir' is a characted vector of length 1 representing the name of the directory | |
## 'ofname' is a character vector of length 1 indicating the name of the output file | |
## 'append' is logical to tell wheter to append to sampled fraction to the output file | |
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
# count empty lines in a file | |
numberOfEmptyLines <- function(fname) { | |
if(!file.exists(fname)) { | |
stop(paste("Cannot read file ", fname, sep = " ")) | |
} | |
as.integer(strsplit(try(system(paste("grep -cP '^$'", fname, sep = " "), intern = TRUE)), " +")[[1]][1]) | |
} |
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
# get the number of lines in a file | |
numberOfLines <- function(fname) { | |
if(!file.exists(fname)) { | |
stop(paste("Cannot read file ", fname, sep = " ")) | |
} | |
as.integer(strsplit(try(system(paste("wc", fname, sep = " "), intern = TRUE)), " +")[[1]][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
dummy_box_url = "/home/avullo/work/vagrant-feature-jmg-vagrant-vcloud/vcloudTest/boxes/starman.box" | |
nodes = [ | |
{ :hostname => "starman", :box => "starman", :box_url => dummy_box_url }, | |
] | |
Vagrant.configure("2") do |config| | |
# vCloud Director provider settings | |
config.vm.provider :vcloud do |vcloud| |