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 / 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\";"
@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 / 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 / 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 / gitlab-markdown-toc-generator.js
Created January 14, 2016 16:49
For use on GitLab circa 14-01-2016. Injects a "Create ToC?" link under the project's name if Markdown style anchors are found on the page. Click the link and a Markdown compatable table of contents will appear in the browser's console! Copy-and-paste it into your Markdown (like README.md).
// ==UserScript==
// @name GitLab Markdown TOC Generator
// @namespace GLMdToCg
// @description For use on GitLab circa 14-01-2016. Injects a "Create ToC?" link under the project's name if Markdown style anchors are found on the page. Click the link and a Markdown compatable table of contents will appear in the browser's console! Copy-and-paste it into your Markdown (like README.md).
// @include *gitlab.com*
// @version 1
// @grant none
// ==/UserScript==
window.addEventListener(
@Data-ptr
Data-ptr / clone-all-heroku-apps.bash
Created January 14, 2016 18:10
Just authenticated to a Heroku login and want to quickly clone all the applications into their own directories? In a "one-liner?" Remember, you have to be authenticated, `$ heroku apps` should list the applications.
for HEROKU_APP in $(heroku apps | tail -n+2); do export REPO_DIR="heroku-${HEROKU_APP}"; if [ ! -d "$REPO_DIR" ]; then mkdir "$REPO_DIR"; cd "$REPO_DIR"; heroku git:clone ./ -a "${HEROKU_APP}"; cd ..; fi done
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rickshaw/1.5.1/rickshaw.min.css">
@Data-ptr
Data-ptr / WRGB-flashlight.ino
Last active June 10, 2017 02:57
Building a White, Red, Green, Blue Flashlight with NeoPixels and an ATTiny/85
// +---+
// | |
// | |
// |Neo|
// | |
// | |
// +---+
// | |
// | |
// |Pix|
@Data-ptr
Data-ptr / tilting.ino
Created March 11, 2018 23:21
Getting direction tilting (out of 360) from IMU (in this case the CurieIMU) and display as pixel on NeoPix ring
/*
* This is a modified version of the Visualize101.ino example sketch
* https://github.com/arduino-libraries/MadgwickAHRS/blob/master/examples/Visualize101/Visualize101.ino
*
* Modified starting March 10th, 2018 by Jane Hacker (JAH)
*
* XYZ_M = Macro
* xyz_g = Global
* xyz_t = Type
*
@Data-ptr
Data-ptr / soundmeter-exec.sh
Created April 19, 2018 21:32
Using soundmeter to trigger a script if the mic input is above $RMS Rms (when a loud sound is present)
PROG=hello.sh;RMS=100;soundmeter --trigger +$RMS --action exec --exec $PROG