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
/* jQuery selector to match exact text inside an element | |
* http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html | |
* :containsExact() - case insensitive | |
* :containsExactCase() - case sensitive | |
* :containsRegex() - set by user ( use: $(el).find(':containsRegex("/(red|blue|yellow)/gi")') ) | |
*/ | |
$.extend( $.expr[":"], { | |
containsExact: $.expr.createPseudo ? | |
$.expr.createPseudo(function(text) { | |
return function(elem) { |
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
1. Class selector - .<classname> | |
2. Id selector - #<id> | |
3. Scope selector - .<classname><space>.<dusra_classname> | |
4. Immediate child selector - .<classname>">".<child_classname> | |
5. Attribute selector - [<attributename>='<value>'] OR [<attributename>] | |
6. Tag selector - "<tagname>" | |
7. DOM element - Directly pass the element to jquery function | |
8. Multiple element - separate selectors using <comma> |
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
read -d '' SLACK_PAYLOAD_DATA << EOF | |
{ | |
"channel": "#channel", | |
"username": "Bot", | |
"text": "Message by _$(id -un)@$(hostname -f)_.", | |
"icon_emoji": ":poop:", | |
"attachments": [ | |
{ | |
"fields": [ | |
{ |
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 all methods on an object | |
function getOwnMethods(obj) { var props = Object.getOwnPropertyNames(obj); return props.filter(function(prop) { return obj[prop] && obj[prop].constructor && obj[prop].call && obj[prop].apply; }); } | |
// Example Object | |
var Module = { str: "a string", array: [1, 2, 3, 4], alpha: function() { return this; }, beta: function() { return this; }, delta: function() { return this; } }; console.log( getOwnMethods(Module) ); // > ["delta", "alpha", "beta"] |
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
du --all --one-file-system / | awk '{if($1 > 102400) print int($1/1024) "MB" " " $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
function buf () | |
{ | |
local filename=$1 | |
local filetime=$(date +%Y%m%d_%H%M%S) | |
cp -a "${filename}" "${filename}_${filetime}" | |
} |
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
function myip () | |
{ | |
res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') | |
echo -e "Your public IP is: ${echo_bold_green} $res ${echo_normal}" | |
} | |
myip |
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 | |
if [ "$(uname)" == "Darwin" ]; then | |
# Do something under Mac OS X platform | |
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then | |
# Do something under GNU/Linux platform | |
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then | |
# Do something under Windows NT platform | |
fi |
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
netstat -an |grep 445 |grep LISTEN | |
# From a bash script how can I quickly find out whether a port 445 is open/listening on a server. | |
# | |
# I have tried a couple of options, but I want something quick: | |
# 1. lsof -i :445 (Takes seconds) | |
# 2. netstat -an |grep 445 |grep LISTEN (Takes seconds) | |
# 3. telnet (it doesn't return) | |
# 4. nmap, netcat are not available on the server | |
# |
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
module OS | |
def OS.windows? | |
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil | |
end | |
def OS.mac? | |
(/darwin/ =~ RUBY_PLATFORM) != nil | |
end | |
def OS.unix? |