head -n 100 filename.txt > smallfile.txt
tail -n 100 filename.txt > smallfile.txt
#!/bin/bash | |
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$') | |
do | |
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes | |
if [ $? -ne 0 ]; then | |
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint." | |
exit 1 # exit with failure status | |
fi | |
done |
$ cat /var/log/couchdb/couch.log | |
[Fri, 30 Jan 2015 12:47:35 GMT] [info] [<0.31.0>] Apache CouchDB has started on http://127.0.0.1:5984/ | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - DELETE /test_suite_db/ 200 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - PUT /test_suite_db/ 201 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - PUT /test_suite_db/abd79b2753f1a4148bbc4c98d602e591 201 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - PUT /test_suite_db/abd79b2753f1a4148bbc4c98d602e591 201 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - DELETE /test_suite_db/abd79b2753f1a4148bbc4c98d602e591?rev=2-c5242a69558bf0c24dda59b585d1a52b 200 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - GET /test_suite_db/undefined 404 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192.168.1.145 - - PUT /test_suite_db/abd79b2753f1a4148bbc4c98d602e342 201 | |
[Fri, 30 Jan 2015 12:47:41 GMT] [info] [<0.110.0>] 192. |
var Hapi = require('hapi'); | |
var PORT = process.env.PORT || 3000; | |
var server = new Hapi.Server(); | |
server.connection({ | |
port: PORT | |
}); | |
server.route({ |
If you have an array $a = array( 0, 1, 2, 3, 4 );
, how do you extract the value 3 from the array?
If you have an array $a = array( "zero"=>0, "one"=>1, "two"=>2, "three"=>3, "four"=>4 );
, how do you extract the value 3 from the array?
If you have the following array, how do you extract the value 3 from the array?
In my git
development, I have an origin
repository with a single branch that reflects our currently-deployed production code, and my own repository on my own machine. I develop features and bugfixes in their own branches. With help from several places around the internet (which I'm afraid I've forgotten), I've developed these git
aliases to help smooth out my workflow.
[alias]
sync = "!f() { echo Syncing this branch with master && git checkout master && git pull --ff-only && git checkout - && git rebase --committer-date-is-author-date --preserve-merges master; }; f"
release = "!f() { BRANCH=$(git rev-parse --abbrev-ref HEAD); FF=\"--no-ff\"; if [ $(git log --pretty=oneline master..HEAD | wc -l) -eq "1" ]; then FF="--ff"; fi; echo \"Sending changes from '$BRANCH' to origin. $FF\"; git checkout master && git merge $FF $BRANCH && ssh ORIGIN_SERVER 'cd ORIGIN_DIR && git pull --ff-only MY_REMOTE master'; }; f"
git sync
will grab all changes from origin
into master
and then rebase your
I was working on a JSON API (for IconCMO) and realized that it'd be nice to be able to see the output of the API in my editor. In particular, I not only wanted the JSON output pretty-printed, but also wanted to highlight a few specific keys of the output, as that's what my code was focusing on.
Most editors let you execute shell commands in one way or another, and display their output. Here's the command I used (the URL is local-only) and its output:
OUTPUT=$(curl --request POST --data '{"Auth": {"Phone": "5555555555", "Username": "JoePUser", "Password": "password"}, "Request": {"Module": "payroll", "Section": "payment_method_form"} }' --header 'Content-type:application/json' --silent https://david.iconcmo.com/api/); echo $OUTPUT | jq '.payment_method_form.test'; echo $OUTPUT
{
To update Fedora 18 against Heartbleed, you'll need to roll your own RPMs since 18 is no longer supported. (Consider CentOS?)
Here's what worked for me, based heavily on the CentOS guide on rebuilding RPMs. Your mileage may vary. I did have things like gcc
and make
already installed.
$ sudo yum install rpm-build
$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
$ cd /tmp
$ wget http://mirrors.kernel.org/fedora/updates/18/SRPMS/openssl-1.0.1e-37.fc18.src.rpm
Assuming Sugar.js is installed, you can run this to add a before
method to all functions.
Function.extend( {
before: function( func ) {
// TODO: could add ability to output function name (via this.toString() and a regex)
// TODO: could add ability to modify arguments before getting passed to function
var that = this;
return function() {
var args = Array.create( arguments );