Skip to content

Instantly share code, notes, and snippets.

@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.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
#!/bin/tcsh
# A small example program for using the new getopt(1) program.
# This program will only work with tcsh(1)
# An similar program using the bash(1) script language can be found
# as parse.bash
# Example input and output (from the tcsh prompt):
# ./parse.tcsh -a par1 'another arg' --c-long 'wow\!*\?' -cmore -b " very long "
# Option a
@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 / 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 / .inputrc
Created January 13, 2014 20:17
based on tips from [HackerNews](https://news.ycombinator.com/item?id=7051091)
set completion-ignore-case On
set bell-style none
set editing-mode vi
$if mode=vi
set keymap vi-command
"gg": beginning-of-history
"G": end-of-history
set keymap vi-insert
"jj": vi-movement-mode
@morganp
morganp / .rtorrent.rc
Created January 8, 2014 19:55
rtorrentrc move data upon download completion
# Torrents go in ~/Torrents
# Incomplete Downloads in ~/Incomplete
# Upon Completion Data is moved to ~/Seeding
schedule = watch_directory_standard,10,10,"load_start=~/Torrents/*.torrent,d.set_directory=~/Incomplete/,d.set_custom1=~/Seeding/
#Move upon download completion.
system.method.set_key =event.download.finished,move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-n,$d.get_base_path=,$d.get_custom1="
@morganp
morganp / gist:8323194
Created January 8, 2014 19:41
rtorrent.rc
##
## .rtorrent.rc
##
## All the Possible commands
## http://libtorrent.rakshasa.no/wiki/RTorrentCommandsRaw
##
## Main Examples
## http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks
## http://wiki.rtorrent.org/RtorrentScripting
max_peers = 40
@morganp
morganp / find_notcontaining.rb
Last active December 19, 2015 15:18
Old blogpost had formatting destroyed by google.
#!/usr/bin/env ruby
#Array of Files containing matching text
matchingFiles = []
## Build list of matching files
Dir.foreach("./") do |x|
if File.file?(x)
begin
file = File.new(x, "r")
@morganp
morganp / pension_planner.rb
Created July 11, 2013 11:44
Pension Planner, Compound interest with annual payments, annual payments can increase linearly overtime (%). Initial statement, how much you currently have in your plan. Years to calculate over. The lower we can get this and still get the final value you require for retirement the sooner we can retire. **Retiring sooner will mean more money is r…
#!/usr/bin/env ruby
# encoding: UTF-8
require 'pp'
statement = [1000.0] ## Pounds starting balance
years = 20 ## How many statement calculations
interest_rate = 0.04 ## Decimal ie 10% is 0.10
annual_payment = 1000 ## Pounds
payment_increase = 0.02 ## increase payments by %2 (0.02) a year.