Skip to content

Instantly share code, notes, and snippets.

View vpivo's full-sized avatar

Victor Pivo vpivo

View GitHub Profile
@vpivo
vpivo / fb
Created July 21, 2014 17:50
FizzBuzz Code Golf
1.upto(100) { |i| puts i%3==0?i%5==0?"FizzBuzz":"Fizz":i%5==0?'Buzz':i}
@vpivo
vpivo / Time
Created December 4, 2013 09:12
Time Problem Solution?
1.9.3p448 :015 > j.deadline_at = DateTime.parse('04 Dec 2013 09:30:00' ) <- setting time with DateTime object
=> Wed, 04 Dec 2013 09:30:00 +0000
1.9.3p448 :016 > reload!
Reloading...
=> true
1.9.3p448 :017 > j.deadline_at
=> Wed, 04 Dec 2013 01:30:00 PST -08:00 <- Mongo Mapper assumes it is in UTC, reformats it into a Time object.
1.9.3p448 :018 > j.deadline_at = Time.parse('04 Dec 2013 09:30:00' ) <- setting time with Time
=> 2013-12-04 09:30:00 -0800
1.9.3p448 :019 > j.save!
@vpivo
vpivo / js
Created August 22, 2013 21:16
ryans words
var readline = "The rain in Spain falls mainly on the plain.";
## L should be downcase
var LongestWord = function(sen) {
var words = sen.split(" ");
var longest = 0;
for (i = 0; i <= words.length; i++) {
if (longest.length < words[i].length) {
longest = words[i];
@vpivo
vpivo / testing
Last active December 21, 2015 05:08
Rspec, Factory Girl, Faker and Capybara Questions and cheat sheet.
1. Should I shoulda-matchers in place of something like:
expect(Contact.new(firstname: nil)).to have(1).errors_on(:firstname)
2. When should I use let(:variable) {something} vs. using variable = something
expect(Contact.new(lastname: nil)).to have(1).errors_on(:lastname)
Assertions
.to
.to_be
@vpivo
vpivo / twitter_gem.txt
Created May 28, 2013 16:46
Notes for Twitter Gem
http://blog.assimov.net/blog/2010/12/18/twitter-integration-with-omniauth-and-devise-on-rails-3/
@vpivo
vpivo / index.html
Last active December 17, 2015 19:19 — 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>
@vpivo
vpivo / zoo.js
Last active December 17, 2015 16:28 — forked from dbc-challenges/zoo.js
function assert(test, message) {
if (!test) {
throw "ERROR: " + message;
}
return true;
}
function Animal(name, legs){
this.name = name;
this.legs = legs;
@vpivo
vpivo / ActiveRecordAss.rb
Created May 20, 2013 22:19
Renaming an association
class Game < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :winner, :class_name => "User"
end
class User < ActiveRecord::Base
has_and_belongs_to_many :games
validates :name, :uniqueness => true
end
@vpivo
vpivo / backup
Last active December 17, 2015 12:58 — forked from dbc-challenges/jquery_quiz.js
/* 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.
*/