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
#!/bin/awk | |
#before processing lines, check if "src" variable has been passed | |
#If so, print it out, if not just print "origin" | |
#Set the field separator to be '(' or ')' | |
BEGIN { | |
if (src) { | |
printf "%s -> ", src | |
} else { | |
printf "%s -> ", "origin" | |
} |
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
#!/usr/local/bin/python3 | |
class Animal(): | |
def __init__(self,name,species,sound,age): | |
self.name = name | |
self.species = species | |
self.sound = sound | |
self.age = age | |
def make_sound(self): |
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
#!/usr/bin/env node | |
const child_process = require('child_process'); | |
function runCmd(cmd) { | |
let resp = child_process.execSync(cmd); | |
let result = resp.toString('UTF8'); | |
return result; | |
} | |
cmd = `curl -w ' | |
time_namelookup: %{time_namelookup} |
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
#/usr/bin/env bash | |
curl_format=' | |
time_namelookup: %{time_namelookup} | |
time_connect: %{time_connect} | |
time_appconnect: %{time_appconnect} | |
time_pretransfer: %{time_pretransfer} | |
time_redirect: %{time_redirect} | |
time_starttransfer: %{time_starttransfer} |
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
Solution for https://www.codewars.com/kata/highest-scoring-word/train/javascript | |
const high = (wordsString) => { | |
const words = wordsString.split(" ") | |
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); | |
let scores = [] | |
let maxScore = 0 | |
let maxScoreIndex | |
words.forEach(word => { | |
let letters = word.split('') |
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
[root@mgmt01 logs]# time zfgrep -vw CM manager.log.7.gz|awk --profile 'BEGIN{print "Date,Time,FX SessID,USRM SessID,Home,Asset";OFS=","};$7 == 17018{split($NF,HA,"[$_]"); A[$8] = HA[3];H[$8] = HA[4]} $7 == 17031 && $0 ~ /available/ || $0 ~ /unusable/ {dec=substr($8,14);ses=substr($8,2,12);dec_ses[$8]=ses"/"strtonum("0x"dec); print $1,$2,$8,dec_ses[$8],H[$8],A[$8];home[H[$8]]++};END{print "home,# of errors";K = asorti(home,n);for (i=1;i<=K;i++) print n[i],home[n[i]]} ' | |
Date,Time,FX SessID,USRM SessID,Home,Asset | |
12/02/13,18:44:16.636,@00223A25759201250256,00223A257592/19202646,35674934,65019706 | |
12/02/13,19:13:21.379,@001AC3FDF72C04530C7A,001AC3FDF72C/72551546,36959215,64824121 | |
12/02/13,19:38:54.079,@ECE09B07960105E4B090,ECE09B079601/98873488,43795953,65057265 | |
12/02/13,19:47:34.777,@001AC3FDF72C04530C7E,001AC3FDF72C/72551550,36959215,64824121 | |
home,# of errors | |
35674934,1 | |
36959215,2 | |
43795953,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
[root@proxy01 tmp]# wc -l lix.tp | |
157317 lix.tp | |
[root@proxy01 tmp]# head -5 lix.tp | |
10/25/13 20:00.01 Info Public Queue Size for A_COMP is 0 | |
10/25/13 20:00.01 Info Private Queue Size for A_COMP is 15061 | |
10/25/13 20:00.01 Warning Combined Threadpool size for A_COMP has exceeded 10000 | |
10/25/13 20:00.01 Info Public Queue Size for PRO-POOL is 0 | |
10/25/13 20:00.01 Info Private Queue Size for PRO-POOL is 0 | |
[root@proxy01 tmp]# time awk '{SUBSEP=" ";OFS=",";H=substr($2,0,2);T=$(NF-2)} | |
H > 19 && H < 24 && /Info/ && T == "HELLO" && $4 == "Public" {t[$1,$2]++;HPUB[$1,$2]=$NF} |
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
#Notes in response to http://bit.ly/1fFMKIx (really cool blog) | |
output=$(fgrep -c CRON /var/log/messages) #grave accent notation is depreciated | |
##no reason for 2 pipes when 0 will do | |
#if you're not using regex, use fgrep | |
if [[ -n ${output} ]];then #we can avoid the `local` issue by just checking the existence | |
echo "Found ${output}..." #of output | |
#exit 0 #you can set your exit status explicitly, but not a big deal | |
else | |
echo "No instances of..." |
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
"Turn on line numbering | |
set number | |
"Enable syntax highlighting | |
syntax enable | |
"Start scrolling 14 lines from edge | |
set so=14 | |
" Control character highlighting. | |
"Inserts ↵ at EOL and denotes hard tabs with ⇥⇥ | |
set list listchars=tab:⇥⇥,eol:↵ | |
" Tab settings. |
NewerOlder