Skip to content

Instantly share code, notes, and snippets.

View conradwt's full-sized avatar
🎯
Focusing

Conrad Taylor conradwt

🎯
Focusing
View GitHub Profile
@conradwt
conradwt / pattern_matching.erl
Created March 3, 2017 00:43
1.15 - Variables and patterns in practice
-module(pattern_matching).
-export([xor_1/2, xor_2/2, xor_3/2, max_three/3, how_many_equal/3]).
% Exclusive or
% In the previous video step on pattern matching we saw two ways of defining “exclusive or”. Give at least three others. You might find it useful to know that:
%
% =/= and == are the operations for inequality and equality in Erlang;
%
% not is the Erlang negation function; and,
%
@conradwt
conradwt / second.erl
Created February 28, 2017 22:51
Functional Programming Erlang - 1.9 - My first Erlang program
-module(second).
-export([hypotenuse/2,perimeter_right_triangle/2,area_right_triangle/2]).
% Using the function square from first.erl, define a function that gives the
% size of the hypotenuse of a right-angled triangle given the lengths of the
% two other sides.
hypotenuse(A,B) ->
math:sqrt(A*A + B*B).
@conradwt
conradwt / user.ex
Created February 23, 2016 01:17
Programming Phoenix
defmodule Rumbl.User do
use Rumbl.Web, :model
schema "users" do
field :name, :string
field :username, :string
field :password, :string, virtual: true
field :password_hash, :string
timestamps
@conradwt
conradwt / gist:5f6ca01c5a373222c032
Created June 9, 2015 17:53
Blocmetrics Checkpoint [6]: Info. Curl Response
$ curl -v -H "Accept: application/json" -H "Origin: http://registered_application.com" -H "Content-Type: application/json" -X POST -d '{"name":"foobar"}' http://localhost:3000/api/events
* Trying ::1...
* Connected to localhost (::1) port 3000 (#0)
> POST /api/events HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.42.1
> Accept: application/json
> Origin: http://registered_application.com
> Content-Type: application/json
> Content-Length: 17
@conradwt
conradwt / hello_world_with_vim.rb
Created May 16, 2015 19:50
Checkpoint [6]: Sublime Text Assignment
[11:32] [~] $ vim hello_world_with_vim.rb
[12:42] [~] $ cat hello_world_with_vim.rb
def hello_world
puts "hello world, vim is cool!"
end
@conradwt
conradwt / mkmf.log
Created August 14, 2014 15:04
Nokogiri install fails because of missing lzma symbols
have_header: checking for iconv.h... -------------------- yes
"gcc -o conftest -I/opt/rbenv/versions/2.1.2/include/ruby-2.1.0/x86_64-linux -I/opt/rbenv/versions/2.1.2/include/ruby-2.1.0/ruby/backward -I/opt/rbenv/versions/2.1.2/include/ruby-2.1.0 -I. -I/usr/include -I/root/2.1.2/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -L. -L/opt/rbenv/versions/2.1.2/lib -Wl,-R/opt/rbenv/versions/2.1.2/lib -L/usr/lib -Wl,-R/usr/lib -L. -L/root/2.1.2/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/opt/rbenv/versions/2.1.2/lib -L/opt/rbenv/versions/2.1.2/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
@conradwt
conradwt / learningchef-week-4
Last active August 29, 2015 14:05
learningchef-week-4
$ knife bootstrap URL -x root -P Password -N module3 -r "recipe[apache]"
Connecting to uvo1ilefd4schorqxfc.vm.cld.sr
uvo1ilefd4schorqxfc.vm.cld.sr Starting first Chef Client run...
uvo1ilefd4schorqxfc.vm.cld.sr [2014-08-11T15:52:48-04:00] WARN:
uvo1ilefd4schorqxfc.vm.cld.sr * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
uvo1ilefd4schorqxfc.vm.cld.sr SSL validation of HTTPS requests is disabled. HTTPS connections are still
uvo1ilefd4schorqxfc.vm.cld.sr encrypted, but chef is not able to detect forged replies or man in the middle
uvo1ilefd4schorqxfc.vm.cld.sr attacks.
uvo1ilefd4schorqxfc.vm.cld.sr
uvo1ilefd4schorqxfc.vm.cld.sr To fix this issue add an entry like this to your configuration file:
@conradwt
conradwt / gist:04673b81ffffefd88dbb
Created July 31, 2014 09:45
certificate verify failed
$ rails new fashionfreelance -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
Using from /Users/conradwt/.railsrc
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
#define kFirechatNS @"https://<your-firebase-subdomain>.firebaseio.com/"
- (void)addUser:(NSString *)aUser toChannel:(NSString *)aChannel
{
Firebase * currentUserReference = [self.firebase childByAutoId];
NSString * path = [NSString stringWithFormat:@"matches/channels/%@/users/%@/", aChannel, [currentUserReference name]];
[[self.firebase childByAppendingPath:path] setValue: @{ @"user_id" : aUser,
@"firebase_id" : [currentUserReference name],
#import <Firebase/Firebase.h>
#define kFirechatNS @"https://<your-firebase>.firebaseio.com/"
@interface SomethingViewController ()
@property (nonatomic, strong) Firebase* firebase;
- (void)startFirebaseEvents;
- (void)enterChannel;