Skip to content

Instantly share code, notes, and snippets.

View toddnestor's full-sized avatar

Todd D Nestor toddnestor

View GitHub Profile
@toddnestor
toddnestor / erlang-fibonacci.erl
Created December 7, 2016 07:58
Fibonaccie sequence in erlang
-module(fibonacci).
-export([process/1]).
process(1) ->
[0];
process(2) ->
[0,1];
process(N) ->
lists:append(process(N - 1), [ lists:last(process(N - 1)) + lists:last(process(N - 2) ) ] ).
-module(numbers).
-export([fib/1, triangle_numbers/1, triangle_number/1, bsearch/2, pair_sum/2]).
fib(1)->
[0];
fib(2)->
[0,1];
fib(N)->
PrevFibs = fib(N-1),
lists:append(PrevFibs, [ lists:nth(length(PrevFibs) - 1, PrevFibs) + lists:last(PrevFibs) ] ).
<?php
function forceDownload()
{
$file_name = "/some/directory/not/publicly/available/" . $_GET['file'];
$file = file_get_contents( $file_name );
if( !empty($file) )
{
@toddnestor
toddnestor / template_method_arguments.rb
Created May 3, 2017 22:20
class for extracting arguments from a string
# This class is solely used for extracting arguments from a string
# It is used to process the arguments input to template_methods in the CMS content areas
# It handles arguments that are comma separated, inside or outside of quotes
# Like normal arguments to a programming function if something is inside a quote it will
# all be part of the same argument and commas inside of quotes are part of that argument
# rather than used to separate it from another argument. It also takes into account backslashes
# so 'I\'m an argument' will properly be processed
#
# For example link("http://google.com", 'Google is fun to use, really it is')
# It will result in the arguments:
require 'net/ssh'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: ruby permission.rb [-h some-host-option -a lock -u garion]"
%i{host user action}.each do |option|
opts.on("-#{option[0]}VALUE", "--#{option}=VALUE") do |value|
import {fetchAuthSession} from '@aws-amplify/auth';
const baseUrl = 'http://localhost:3000'; // process?.env?.REACT_APP_API_DOMAIN || '';
// makes a get request, called index because it typically is used to retrieve a collection
// of models, like index of the products for a search
export const index = <DataType = {}>(path: string) => {
return request<DataType[]>({
url: path,
method: 'GET',