Skip to content

Instantly share code, notes, and snippets.

@dprea
dprea / png_encoding_reference.md
Last active February 14, 2016 23:18
PNG File Encoding and Reading

Extending the correct answer from SigTerm, here is some background of why you got the effect you did for opening a PNG file in text mode:

The PNG format explains its 8-byte file header as follows:

The first eight bytes of a PNG file always contain the following values:

   (decimal)              137  80  78  71  13  10  26  10
   (hexadecimal)           89  50  4e  47  0d  0a  1a  0a
 (ASCII C notation) \211 P N G \r \n \032 \n
@dprea
dprea / IIFE - Encapsulation Reference.markdown
Last active February 12, 2016 04:44
IIFE - Encapsulation Reference
@dprea
dprea / click_workable_items.js
Created February 9, 2016 08:44
Small jQuery Script for finding Workable.com Links
/**
* Makes the Workable Job Items(.whr-item) Clickable
*
* @author: Dustin Rea
*/
var whrClickable = function() {
setTimeout(function() {
jQuery('.whr-item').click(function() {
window.location = jQuery(this).find('.external').attr('href');
return false;
@dprea
dprea / GMAP_Data_Store_Locator.md
Created February 8, 2016 16:31
Google Maps API
@dprea
dprea / JS Function Declaration vs Expression.markdown
Last active February 8, 2016 02:20
JS Function Declaration vs Expression
@dprea
dprea / autovim.sh
Last active January 27, 2016 21:06
Shell Script - Open Vim then Write Text then Save and Quit Vim
# Uses Vim to create a text file (file.txt) with text 'hello'
# Save and quit Vim
vim file.txt -c '$put =\'hello\' -c 'wq'
# -----------------------------------------------------------------------------------------
# SOURCE http://stackoverflow.com/questions/5978108/open-vim-from-within-bash-shell-script
# -----------------------------------------------------------------------------------------
# vim -c
# -c => pass ex commands.
# Example: vim myfile.txt -c 'wq' to force the last line of a file to be newline terminated
# (unless binary is set in some way by a script)
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@dprea
dprea / import_json_appsscript.js
Created January 25, 2016 03:25 — forked from chrislkeller/import_json_appsscript.js
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@dprea
dprea / linux-count-files-in-dir.md
Created January 22, 2016 04:27
Linux Commands - Count Files in directory
$ find . -type f | wc -l

Explanation: find . -type f finds all files ( -type f ) in this ( . ) directory and in all sub directories, the filenames are then printed to standard out one per line.

This is then piped | into wc (word count) the -l option tells wc to only count lines of its input.

Together they count all your files.

@dprea
dprea / article.server.model.js
Last active January 17, 2016 15:39
MEAN.js 0.4.2 - Mongoose.js Discriminator Schemas
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
/**
* Article Schema