Skip to content

Instantly share code, notes, and snippets.

View nemrow's full-sized avatar

Jordan Nemrow nemrow

  • Woflow
  • San Francisco
View GitHub Profile
def valid_triangle?(a, b, c)
all_sides = [a,b,c]
all_sides_sorted = all_sides.sort
max_num = all_sides_sorted[2]
if (all_sides_sorted[0] == 0 or all_sides_sorted[1] == 0 or all_sides_sorted[2] == 0)
elsif (all_sides_sorted[0] == max_num and all_sides_sorted[1] == max_num and all_sides_sorted[2] == max_num)
return true
elsif ((all_sides_sorted[0] * all_sides_sorted[0]) + (all_sides_sorted[1] * all_sides_sorted[1]) == (all_sides_sorted[2] * all_sides_sorted[2]))
return true
else
@nemrow
nemrow / gist:5215581
Last active December 15, 2015 06:19
I am working on this challenge: "The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?" and my solution is clearly terrible! It takes about 10 seconds to produce this answer (which is correct), and when I tried to plug in the number 600851475143 (which is what they want), it actually crashe…
def is_prime(int)
i = 2
while i < int
if int % i == 0
return false
i = int
end
i += 1
end
end
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@nemrow
nemrow / index.html
Last active December 18, 2015 11:18 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@nemrow
nemrow / zoo.js
Last active December 18, 2015 11:19 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
var Zoo = {
init: function(animals){
this.animals = animals;
},
bipeds : function(){
function livingThing(options){
this.name = options.name;
this.sex = options.sex;
this.alive = true;
}
function Person(options){
livingThing.call(this, options);
this.children = [];
this.wife;
function Mammal(options){
this.name = options.name;
this.sex = options.sex;
this.alive = true;
}
function Person(options){
Mammal.call(this, options);
this.children = [];
this.wife;
@nemrow
nemrow / birthdate-picker-component.js.coffee
Last active August 29, 2015 14:09
Ember component for datepicker
# components/split-date-selector.js.coffee
Teleborder.SplitDateSelectorComponent = Ember.Component.extend
change: ->
selects = @$().find('select')
month = selects.filter('[name="month"]').val()
day = selects.filter('[name="day"]').val()
year = selects.filter('[name="year"]').val()
currentDate = moment(new Date(year, month, day))
@set('date', new Date(currentDate.toISOString())) if currentDate
@nemrow
nemrow / birth-date-picker.hbs
Last active August 29, 2015 14:09
Ember Birth Date Picker Component Template
<!-- templates/components/split-date-selector.hbs -->
<div class="form-group">
<label class=" col-sm-3 control-label">
Birth Date
</label>
<div class="col-sm-5">
<div class="date-field">
{{input 'month' as='select'
collection='monthOptions'
class ProjectsController < ApplicationController
def create
Project.create(project_params)
end
def project_params
params.require(:project).permit(
:name,
:tags [
:id,