Skip to content

Instantly share code, notes, and snippets.

View JoeyBurzynski's full-sized avatar
💭
Hacking away on @EdgeSEO tools.

Joey Burzynski JoeyBurzynski

💭
Hacking away on @EdgeSEO tools.
View GitHub Profile
@JoeyBurzynski
JoeyBurzynski / gist:37a433e2ed73c68f304390314b3d73f7
Created April 14, 2016 17:22 — forked from Mottie/gist:461488
Improved jQuery :contains() selector
/* 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) {
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>
@JoeyBurzynski
JoeyBurzynski / slack.sh
Created May 1, 2016 18:41 — forked from amberovsky/slack.sh
Slack incoming webhooks from bash (send notification to slack from shell)
read -d '' SLACK_PAYLOAD_DATA << EOF
{
"channel": "#channel",
"username": "Bot",
"text": "Message by _$(id -un)@$(hostname -f)_.",
"icon_emoji": ":poop:",
"attachments": [
{
"fields": [
{
@JoeyBurzynski
JoeyBurzynski / getOwnMethods.js
Created May 1, 2016 19:28
JavaScript: Get All Methods on an Object
// 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"]
@JoeyBurzynski
JoeyBurzynski / Asset.txt
Created May 1, 2016 19:35
Linux: Find All Files/Directories Over 100MB
du --all --one-file-system / | awk '{if($1 > 102400) print int($1/1024) "MB" " " $2 }'
@JoeyBurzynski
JoeyBurzynski / Asset.sh
Created May 1, 2016 19:37
Bash Scripts: Back Up File With Timestamp
function buf ()
{
local filename=$1
local filetime=$(date +%Y%m%d_%H%M%S)
cp -a "${filename}" "${filename}_${filetime}"
}
@JoeyBurzynski
JoeyBurzynski / Asset.sh
Created May 1, 2016 19:37
Bash Scripts: Echo IP Address (Internet Facing)
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
@JoeyBurzynski
JoeyBurzynski / Asset.sh
Created May 1, 2016 19:37
Bash Scripts: Detect Operating System
#!/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
@JoeyBurzynski
JoeyBurzynski / Asset.sh
Created May 1, 2016 19:38
Command Line: Determine If Port Is Open & Listening
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
#
@JoeyBurzynski
JoeyBurzynski / Asset.txt
Created May 1, 2016 19:38
Ruby: Determine Operating System
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?