Skip to content

Instantly share code, notes, and snippets.

View tacitphoenix's full-sized avatar

Samson Ondiek tacitphoenix

View GitHub Profile

To create anchor links that jump down to different sections of a README (as in an interactive table of contents), first create a heading:
#Real Cool Heading

The anchor link for that heading is the lowercase heading name with dashes where there are spaces. You can always get the anchor name by visiting the README on Github.com and clicking on the anchor that appears when you hover to the left of the heading. Copy everything starting at the #:
#real-cool-heading

Wherever you want to link to your Real Cool Heading section, put your desired text in brackets, followed by the anchor link in parentheses:
[Go to Real Cool Heading section](#real-cool-heading)

@tacitphoenix
tacitphoenix / maven-uber-jar
Created November 6, 2019 15:03
Allow maven package to create an uber/fat/executable jar file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
12 + 12
"12 + 12"
"12" + "12"
"I" * 5
# '12' + '12'
# 5 * "I"
# "12" + 12
# "2" * "5"
a : String
import yaml
class LensCreds:
def __init__(self, env):
with open('./credentials.yml') as fp:
creds = yaml.load(fp)
self.consumer_key = creds[env]['consumer_key']
self.consumer_secret = creds[env]['consumer_secret']
self.token = creds[env]['parse_token']
self.token_secret = creds[env]['parse_token_secret']
@tacitphoenix
tacitphoenix / index_tests.erl
Created March 8, 2017 12:55
Erlang MOOC week two assignment tests
-module(index_tests).
-include_lib("eunit/include/eunit.hrl").
% compile: c(index_tests).
% run: index_tests:test().
% define test variables
-define(Contents, ["Four score and seven years ago our fathers brought",
"forth on this continent, a new nation, conceived in Liberty,",
"that we should do this.",[]]).
@tacitphoenix
tacitphoenix / index.erl
Created March 8, 2017 12:52
Erlang MOOC week two homework assignment
-module(index).
-export([get_file_contents/1,show_file_contents/1,get_file_word_index/1,get_file_word_count/1]). % main functions to export
-export([word_index/1,word_count/1,words/1,word_lists/1,word_parse/1,nodup/1,nopunc/1,nocap/1,nocomm/1,remove/2,count/2,range_format/1]). % helpers exported for testing
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
% Get the contents of a text file into a list of lines.
@tacitphoenix
tacitphoenix / erlang_mooc_week_one_tests
Last active February 27, 2017 18:23
Unit Test for the first week assignment of the Erlang MOOC
-module(assignment_one_tests).
-include_lib("eunit/include/eunit.hrl").
perimeter_test() -> ?assert(assignment_one:perimeter({triangle, {3,4,5}}) == 12),
?assert(assignment_one:perimeter({right_triangle, {3,4}}) == 12),
?assert(assignment_one:perimeter({square, {4,4}}) == 16),
?assert(assignment_one:perimeter({rectangle, {4,5}}) == 18).
area_test() -> ?assert(assignment_one:area({right_triangle, {3,4}}) == 6),
?assert(assignment_one:area({square, {5,5}}) =:= 25),
@tacitphoenix
tacitphoenix / Elixir Keyword Lists
Created August 27, 2016 09:48
Elixir Keyword Lists
Elixir Keyword Lists are a list of two item tuples where the first element of a tuple is an atom
iex(2)> k1 = [{:a, 1}, {:b, 2}, {:c, 3}, {:d, 4}]
[a: 1, b: 2, c: 3, d: 4]
iex(4)> k1 = [a: 1, b: 2, c: 3, d: 4] #a spoonful of sugar
[a: 1, b: 2, c: 3, d: 4]
iex(5)> k1 ++ {:b, 1} #not what we want
[{:a, 1}, {:b, 2}, {:c, 3}, {:d, 4} | {:b, 1}]
defmodule Prime do
def run(n), do: Stream.iterate(1, &(&1 + 1)) |> Stream.filter(&(filter(&1))) |> Enum.take(n)
def filter(n) when n < 4, do: true
def filter(n), do: Enum.map(2..div(n,2), &(not(rem(n,&1) == 0))) |> Enum.all?
end
Ruby
start - irb
help - help, then String, String#<TAB>, String.chop
clear - CTRL+L, system(‘clear’)
load file - require “./name.rb” (run keep functions), source “./name.rb” (run keep functions and variables)
exit - exit
Elixir
start - iex
help - h e.g h String, h String.<TAB>, String.chop