Skip to content

Instantly share code, notes, and snippets.

View pajamaw's full-sized avatar

PJ Wickwire pajamaw

View GitHub Profile
@pajamaw
pajamaw / passtoken.sol
Last active September 6, 2017 23:12
Solidity Notes from Meetup
pragma solidity ^0.4.11;
contract PassToken {
// so in order to sell tokens for an ICO you'll need to know how many
// to sell
// so let's say that we want to sell 1 million tokens
// 1 eth -> 10 tokens
// so we'll have 100,000 eth by the end
0x37e748739D4ab6915fA9C3755F23Ddf7Ee771d67
@pajamaw
pajamaw / Alphasights_technical_challenge.md
Created June 9, 2016 17:28 — forked from tadast/Alphasights_technical_challenge.md
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency. Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If David is a friend of Oliver, Oliver is always a friend of David as well.
  • The interface should list all members with their name, short url and the number of friends e.g. Alan http://goo.gl/3io1P (3)
@pajamaw
pajamaw / test6.rb
Created March 22, 2016 14:29
test5
testing
@pajamaw
pajamaw / test5.rb
Created March 22, 2016 14:29
test5
testing
@pajamaw
pajamaw / count_sentences.rb
Created January 9, 2016 00:15
How to count sentences
def count_sentences
self.scan(/[^\.!?]+[\.!?]/).map(&:strip).count
end
@pajamaw
pajamaw / key_for_min.rb
Created January 6, 2016 17:28
Ugly way to return the key of the lowest hash value
def key_for_min_value(name_hash)
new_name_hash = name_hash.sort_by do |key, value|
value
end
just_names = new_name_hash.collect do |x,y|
x
end
just_names.first
end
@pajamaw
pajamaw / benchmark.rb
Created January 5, 2016 22:51
Testing Benchmark Speeds
Benchmark.bm do |bm|
bm.report { first_approach }
bm.report { alternative_approach }
end
@pajamaw
pajamaw / both.rb
Created January 5, 2016 19:07
How to identify and list out individual elements of arrays that are in both
def both_elements(array1)
array2 = []
intersection = array1 & array2
if !intersection.empty?
intersection[i]
else
nil
end
end