Skip to content

Instantly share code, notes, and snippets.

@morganp
morganp / edit_post
Created March 1, 2014 19:27
Helpful script for launching Octopress posts in an editor. just `edit_post vim`
#!/bin/bash
editor="mvim"
post_path="source/_posts/"
for OUTPUT in $(ls $post_path | grep $1)
do
file_list="$file_list $post_path$OUTPUT"
done
@morganp
morganp / exportFilter.lua
Last active August 29, 2015 13:58
Lightroom Export Filter Plugin, Work in progress
-- Lightroom Lua Plugin for export filter
-- Page 49 to 51 of the SDK guide
-- http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/photoshoplightroom/pdfs/lr5/lightroom-sdk-guide.pdf
function SimpleExternalToolFilterProvider.postProcessRenderedPhotos(
functionContext, filterContext )
-- Optional: If you want to change the render settings for each photo
-- before Lightroom renders it
local renditionOptions = {
filterSettings = function( renditionToSatisfy, exportSettings )
exportSettings.LR_size_maxHeight = 400
@morganp
morganp / compile.sh
Created June 12, 2014 08:45
Opt parsing in C
#!/bin/sh
gcc optparse_example.c -o optparse_example
gcc optparse_long_example.c -o optparse_long_example
@morganp
morganp / pass_file_pointer.c
Created June 12, 2014 10:37
Function returns File Pointer
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//static FILE *Sfile;
static int Sfile_open=0;
FILE *Open_Sfile(char *modname){
char file_name[256];
FILE *Sfile;
@morganp
morganp / compile
Created June 12, 2014 11:14
Functions return file pointer main and function split over files.
#!/bin/sh
gcc file_example_main.c file_example.c -o file_example
@morganp
morganp / c_mkdir_example.c
Created June 16, 2014 13:13
Folder creation with C (mkdir)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
//## include <sys/stat.h> required for mkdir
// gcc c_mkdir_example.c -o c_mkdir_example
// c_mkdir_example
// ls -l
main () {
@morganp
morganp / .vimrc
Created August 15, 2014 13:49
Vim disable cursors the smart way
noremap <Up> :echo 'Use k'<CR>
noremap <Down> :echo 'Use j'<CR>
noremap <Left> :echo 'Use h'<CR>
noremap <Right> :echo 'Use l'<CR>
@morganp
morganp / dlg_stock_calc.rb
Last active August 29, 2015 14:07
Stocks and share calculator fetches current DLG price
#!/usr/bin/env ruby
## Install Gem
# gem install stock_quote
require "stock_quote"
## Get price of DLG.DE stocks
stock = StockQuote::Stock.quote("DLG.DE").ask
@morganp
morganp / iphone6.rb
Last active August 29, 2015 14:22
iPhone 6 contracts cost analysis
#!/usr/bin/env ruby
# Direct Purchase Cost
iphone16 = 539
iphone64 = 619
puts "Memory upgrade costs #{iphone64 - iphone16 }"
# £5 a month PAYG on Three
@morganp
morganp / disp2.m
Created July 15, 2015 22:09
Display with auto concationation and numeric converion to strings
function disp2( varargin )
%DISP2 Similar to disp but ...
% But no requirment for [] string concatination,
% Numerics automatically converted to strings.
str = '';
for i=1:length(varargin)
element = varargin(i); element = element{:};
if isnumeric(element)