Skip to content

Instantly share code, notes, and snippets.


Faethon faethonm

  • Loopup
  • San Francisco
View GitHub Profile
View form.erb
<div class="row ">
<div class="field">
<%= f.label :start_time %>
<%= f.time_select :start_time, ignore_date: true %>
faethonm / shippable.yml
Created Apr 27, 2016
An example shippable.yml that should enable any rails 5 project
View shippable.yml
language: ruby
- 2.3.0
- CI_REPORTS=shippable/testresults COVERAGE_REPORTS=shippable/codecoverage
- sudo apt-get -y update
- sudo apt-get -y install libpq-dev
# ensure the test output and coverage dirs are created
faethonm / min_differences.rb
Created Dec 18, 2015
If X and Y are two strings of equal length N, then the difference between them is defined as the number of indices i where the i-th character of X and the i-th character of Y are different.
View min_differences.rb
def distance(a,b)
a.split('').zip(b.split('')).select{|a,b| a!=b}.count
def min_differences(a,b)
distances = (0..(b.length - a.length)).map do |index|
b_sub = b[index...a.length+index]
faethonm / lucky_strings.rb
Created Dec 18, 2015
A string is called lucky if no two consecutive characters are equal. How many lucky strings can you get by reordering letters in a given string *s*? *s* itself counts, too, if it is lucky. 1 <= length(*s*) <= 10 *s[i]* is in 'a'..'z' Example 1 input: "ab" output: 2 Two lucky strings - "ab" and "ba". Example 2 input: "aaab" output: 0 It's impossi…
View lucky_strings.rb
def permutations(string)
permutations = string.split('')
def lucky_strings(string)
permutations(string).select{|s| s.squeeze == s}.count
lucky_strings('ab') #=> 2
lucky_strings('aaab') #=> 0
faethonm / QueueWith2Stacks
Created Mar 9, 2014
Queue Implementation using 2 stacks. Includes implementation of get minimum
View QueueWith2Stacks
import java.util.Collections;
import java.util.Stack;
public class QueueWith2Stacks {
private Stack<Integer> stack1 =null;
private Stack<Integer> stack2 =null;
private ArrayList<Integer> minList =null;