Skip to content

Instantly share code, notes, and snippets.

@drldcsta
drldcsta / Alt tags to tool tips
Created February 12, 2021 04:10
Turns alt text tags into tool tips
javascript:(function(){document.getElementsByTagName('img').forEach(i=>{
if(i.alt==="Image"){
i.title="No Alt Text"
}else{
i.title=i.alt
}
})})();
]
#!/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):
#!/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}
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('')
@drldcsta
drldcsta / motivational_nonsense.py
Created November 25, 2015 20:09
motivational_nonsense.py
>>> d = {}
>>> chars
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>> nums
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
>>> tups = zip(chars,nums)
>>> for i in tups:
... d[i[0]] = i[1]
...
>>> s = 0
@drldcsta
drldcsta / gist:401603649aafe96d3a0d
Created October 28, 2015 05:17
hiding and restoring desktop icons in osx
ProBoxAlpha:~ hegemon$ tail .bash_functions
hide_dt_icons ()
{
defaults write com.apple.finder CreateDesktop false && killall Finder
}
restore_dt_icons ()
{
defaults write com.apple.finder CreateDesktop true && killall Finder
}
@drldcsta
drldcsta / netcap.sh
Created May 21, 2015 02:26
netcap script. Was originally used to have constant tcpdumps running against all relevant management boxes. example of using old style bash variable to create "arrays" which contain both hostnames and IPs. (certain digits have been removed to obfuscate IP address)
#!/bin/bash
######################################################
# Program: netCap.sh
# Date Created: 7 July 010
# Description: Starts a TCP dump of the management network and the USRM's or the management network and the proxy.
# Date Updated: 1 June 01
# |_Complete Rewrite
# |_Added check if running on primary machine
# |_Added crateion of pid files for use in cleanup
# |_Added ability to be run from cron for simple hourly zips
@drldcsta
drldcsta / logGen.sh
Last active August 29, 2015 14:21
log parsing script. Only interesting in that it's a good example of using lock files to make sure there is never more than one copy of a script running on cron
#!/bin/bash
######################################################
# Program: logGen.sh
# Date Created: 22 Aug 2012
# Description: parses the manager log in real time into daily error files
# Date Updated: 27 Nov 2013
# |_moved all data parsing logic to awk instead of shell
# |_Need to analyze memory/CPU usage and consider changing
# |_restart frequency in cron
# Developer: Darrell DeCosta (Senior Support Engineer)
@drldcsta
drldcsta / gist:3adcf26176f925f365e9
Created April 12, 2015 06:51
Crispy's C# homework in Python
AirBoxOmega:Projects d$ python crispy.py
What is the Diver's name? Darrell
What is the Diver's city? W.Village
What is the Diver's difficulty? 3
What is Judge 1's score?? 10
What is Judge 2's score?? 1
What is Judge 3's score?? 4
What is Judge 4's score?? 5
What is Judge 5's score?? 6
[4, 5, 6]
@drldcsta
drldcsta / gist:3165dbff89a9cef8d6ed
Last active August 29, 2015 14:18
Checking for existence of an element in an array in awk
c82a1446be6c:~ decostad$ echo "1,2,3"|awk -F, '{{split($0,arr,",")};if ("1" in arr){print "found it"}}'
found it
c82a1446be6c:~ decostad$ echo "1,2,3"|awk -F, '{{split($0,arr,",")};if ("2" in arr){print "found it"}}'
found it
c82a1446be6c:~ decostad$ echo "1,2,3"|awk -F, '{{split($0,arr,",")};if ("3" in arr){print "found it"}}'
found it
c82a1446be6c:~ decostad$ echo "1,2,3"|awk -F, '{{split($0,arr,",")};if ("4" in arr){print "found it"}}'
c82a1446be6c:~ decostad$ echo "1,2,3"|gawk --profile -F, '{{split($0,arr,",")};if ("4" in arr){print "found it"}}'
c82a1446be6c:~ decostad$ cat awkprof.out