Skip to content

Instantly share code, notes, and snippets.

View Data-ptr's full-sized avatar

Data*Ptr Data-ptr

View GitHub Profile
@Data-ptr
Data-ptr / regexanalysis.sh
Created December 15, 2015 04:04
Ideas for output of a Perl/Bash/RegEx analyzer
####
### e = escaped (for BASH)
### E = escaped (for PERL)
### L = Litteral - The character is stripped of any special meaning
### q = Quoting (for BASH) - When escaping a characters special meaning is otherwise not possible
####
## eEL eEL qq qq eEL eEL eEL L EL e e E E E E E eEL eELe E E e
perl -n -e "m/(url[^\\/]+(?:(?:\\/(?"'!'"Fonts)[^\\/)]*?)*?\\/([^\\/]+?(jpg|jpeg|gif|png|svg)))[^)]*\))/ig; print \"\$.\t\$1\t\turl\('\\/images\\/\$2')\n\n\";" index.css
## A B C D D C E F FEB A
## + + + + - - + + ___ _
@Data-ptr
Data-ptr / regexcramedbash.sh
Created December 14, 2015 05:27
An example of PCRE (Perl Compatible Regular Expressions)—well it is the actual Perl RE Engine... Like, Perl... Anyway...—quoted and escaped for Bash. One way at least.
perl -i.bak -p -e "s/url[^\\/]+(?:(?:\\/(?"'!'"Fonts)[^\\/)]*?)*?\\/([^\\/]+(jpg|jpeg|gif|png|svg)))[^)]*/url\('\\/images\\/\$1'/g" index.css
## Mods for bash! ^ ^ ^^ ^^ ^ ^ ^ ^ ^ ^ don't make shell variable
## | | | | | | | | + double-escaped
## | | | | | | | + double-escaped
## | | | | | | + double-escaped
## | | | | | + double-escaped
## | | | | + double-escaped
## | | + don't make "event" (end d-quote, start s-quote use, `!` [ becomes literal 'casue of s-quote ], end s-quote, restart d-quote)
## | + double-escaped
@Data-ptr
Data-ptr / scrubeea7.sh
Created December 13, 2015 13:40
Find all files with a string in their filename ("eea7" used here), and remove that string
find . -type f -name \*eea7\* -execdir bash -c 'mv "{}" "$(echo {} | sed "s/eea7//")"' \;
@Data-ptr
Data-ptr / package.partial.json
Created December 2, 2015 20:43
Silly, fantastical example of a way to install packages globally with NPM from package.json
"config": {
"globalDependencies": [
"node-pre-gyp",
"node-inspector",
"grunt-cli",
"sequelize-cli"
],
"node_inline": "node -e",
"gd_install": "c=require('child_process');e=process.env;Object.keys(e).filter(function(v){return v.indexOf('globalDependencies_')+1}).forEach(function(i){c.spawn('npm',['install','-g',e[i]],{stdio:'inherit'})})",
"root_check": "if [ 'root' != `whoami` ];then GD_SUDO=\"sudo -E\";fi; $GD_SUDO $npm_package_config_node_inline \"$npm_package_config_gd_install\";"