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
# Add to the given file the given lines, after the line with the given text, or replace the content | |
def add_to_file(path, text, after=nil, replace=false) | |
lines = [] | |
if replace | |
lines = text | |
else | |
File.readlines(path).each do |line| | |
if after != nil and line.include?(after) | |
lines << line | |
lines << text |
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
def mama | |
csv = open("lookahere") | |
qtys=[] | |
fail=[] | |
csv.each_line do |l| | |
# Replace comma with period for float value | |
ln = l.gsub(/((?<=,"\d)(,)(?=\d",))/,".") | |
# Split line on comma | |
dt = ln.split(",") | |
b = Biditem.find_by_tu_no(dt[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
privkey = OpenSSL::PKey::RSA.new(2048) | |
pubkey = privkey.public_key | |
# Return BrowserID Identity JSON | |
def to_json | |
{ | |
"public-key" => { "algorithm"=> "RS", "n" => public_key.n.to_s, "e" => public_key.e.to_s }, | |
"authentication" => "/sign_in", | |
"provisioning" => "/provision" | |
}.to_json |
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
{ | |
"pubkey" : | |
{ | |
"algorithm":"DS", | |
"y":"62b0ea6936a7ab30c95d8ffbbc77438a342faed99b6fc643a58f28d9ed2017177354f9f1d1d7e6b9e1c543780c3517953a124e66bc409fcaaa671d87a39cf897b32f47aaaffb7a3d297b89f9e116870a2182e2b2f84d68a7bc21a3f7934727e45e50a083e71a965d0cc320062598e407463f0c31cc2c20ed74d9bda98b21c902", | |
"p":"ff600483db6abfc5b45eab78594b3533d550d9f1bf2a992a7a8daa6dc34f8045ad4e6e0c429d334eeeaaefd7e23d4810be00e4cc1492cba325ba81ff2d5a5b305a8d17eb3bf4a06a349d392e00d329744a5179380344e82a18c47933438f891e22aeef812d69c8f75e326cb70ea000c3f776dfdbd604638c2ef717fc26d02e17", | |
"q":"e21e04f911d1ed7991008ecaab3bf775984309c3", | |
"g":"c52a4a0ff3b7e61fdf1867ce84138369a6154f4afa92966e3c827e25cfa6cf508b90e5de419e1337e07a2e9e2a3cd5dea704d175f8ebf6af397d69e110b96afb17c7a03259329e4829b0d03bbc7896b15b4ade53e130858cc34d96269aa89041f409136c7242a38895c9d5bccad4f389af1d7a4bd1398bd072dffa896233397a" | |
}, |
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
# @private_key is an OpenSSL private key | |
# params is Rack request params, or Rails params | |
expiration = (Time.now.strftime("%s").to_i + params["duration"].to_i) * 1000 | |
issue = { "iss" => "example.org", | |
"exp" => expiration, | |
"public-key" => params["pubkey"], | |
"principal" => { "email"=> "mormor@example.org" } | |
} | |
jwt = JSON::JWT.new(issue) |
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
chars = %w{ | / - \\ } | |
def find_all_email_addresses_in(base_folder) | |
# Bash goodness :P | |
a=`find #{base_folder} -type d -name cur`.split("\n") +`find #{base_folder} -type d -name new`.split("\n") | |
@emails=[] | |
# http://stackoverflow.com/questions/535644/find-email-addresses-in-large-data-stream | |
a.each do |folder| | |
Dir[folder+"/*"].each do |email| | |
content = File.read(email) | |
r1 = Regexp.new(/(((From|^To|Cc):.*<)\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b(>))/) |
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
{ | |
"log": { | |
"version": "1.2", | |
"creator": { | |
"name": "WebInspector", | |
"version": "536.11" | |
}, | |
"pages": [], | |
"entries": [ | |
{ |
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
$ sudo gluster volume info | |
Volume Name: data | |
Type: Replicate | |
Volume ID: 7ac35911-b9c2-4f20-a226-65a6173dafb3 | |
Status: Started | |
Number of Bricks: 1 x 2 = 2 | |
Transport-type: tcp | |
Bricks: | |
Brick1: gluster1:/data |
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
# Then this in Exchange Management Shell | |
$Location = "\\server\pstexport" | |
New-Item -path $Location -name "migrate.txt" -type File -force | |
Add-Content "$Location\migrate.txt" "datasourceuser,destinationuser" | |
# Create a hash table of Exchange mailboxes | |
$mailboxes = @{} | |
Get-Mailbox | Select-Object name, alias | | |
ForEach-Object { $mailboxes.Add($_.name, $_.alias) } |
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
$timeout = 300 | |
$message = "Please save your work. You will be logged off in "+ $timeout/60 +" minutes" | |
$sessions = @() | |
# Collect session IDs and warn users | |
query session | select-string "wdica" | | |
%{$_ -replace " {2,27}"," "} | | |
foreach {$_.ToString().split(" ")[3]} | | |
foreach { | |
$sessions += $_ |
OlderNewer