Skip to content

Instantly share code, notes, and snippets.

View mkwiatkowski's full-sized avatar

Michal Kwiatkowski mkwiatkowski

View GitHub Profile
@rickyPanzer
rickyPanzer / introducing-help-form.md
Last active September 7, 2015 04:12
Introducing Help Forum

A couple of us mentors created Help Forum, which is Stack Overflow, but for the student and mentor community. If interested sign up at the site here https://help-forum.wearementors.io and email at me (richardrpanzer@gmail.com) so I can approve you.

##Introductory Message

Hi fellow students and mentors,

My name is Ricky. I am a Rails and iOS mentor here at Bloc. As a mentor, I've been guiding my students to several different channels for help. For my students, two strategies have been the most helpful: Google && Stack Overflow and Curriculum specific slack groups. The Bloc Hacker Group on Facebook, Bloc Overflow, and Basecamp have also proven helpful.

Google and Stack Overflow
@benedikt
benedikt / Howto.md
Last active January 4, 2016 06:09
Setting up AppSignal on Shelly Cloud

Setting up AppSignal on Shelly Cloud

To set up AppSignal on Shelly Cloud, you first have to add both the dotenv-rails and the appsignal gem to your Gemfile. Make sure that the dotenv-rails gem is the very first gem in your Gemfile as it will set up important environment variables as soon as it is required.

# Gemfile

source 'https://rubygems.org'

gem 'dotenv-rails'
@randalmaile
randalmaile / Bloccit - Favoriting
Last active January 2, 2016 01:49
Bloccit - Favoriting
## Requirements:
1. users need to opt-in or opt-out of receiving emails from Bloccit;
2. need a model to know which posts a user has favorited;
3. need to add a "Favorite" button on the posts/show.html.erb view to allow users to flag a post as a "favorite"
4. need to create email notifications when a new comment is added to a favorited post.
### Favoriting functionality:
1. Enable email_permissions on the User model: rails g migration AddEmailPermissionsToUser email_permissions:boolean
a. in migration file, add: , default: false to the :boolean symbol in the add_column method
@randalmaile
randalmaile / Bloccit - Topics and Posts
Last active December 31, 2015 21:49
Bloccit - Topics and Posts
The whole point of building this piece of the app is to organize the posts - into **topics**
1. First off is to create the **model** with attributes that make sense - :name, :description, and :public
$ **rails g Topic name:string description:string public:boolean** (don't forget to associate the attributes w/ column types)
2. One of the requirements is to have the public attribute set to true automatically in the db, so change the migration file:
add **public: default:** true to t.boolean :public
3. $ **rails db:migrate**
4. Now you have to add a foreign key to your posts table and index the posts table as well:
a. $ **rails g migration AddTopicToPosts topic_id:integer:index**
3. Now you need to think about associations and tweek your models: TOPICS have 1-many relationship w/ POSTS, so:
@jordanhudgens
jordanhudgens / gist:8033986
Last active February 4, 2022 09:51
Functional Programming Exercises
### Generate an array of numbers, from 1 to 10:
(1..10).to_a
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
### Generate an array of letters from 'a' to 'g':
("a".."g").to_a
# ⇒ ["a", "b", "c", "d", "e", "f", "g"]
### Generate an array of double letters from 'aa' do 'gg':
("a".."g").to_a.map {|i| i * 2}
@randalmaile
randalmaile / Bloccit - Seed Data
Last active December 31, 2015 05:19
Bloccit - Seed Data
1. In this checkpoint, you'll install a Gem named Faker to help generate development data automatically.
2. Run: rake db:seed to seed the database w/ some random data.
3. Look at some of your data by running "rails c" and:
a. p = Post.find(3)
b. p.comments.count
@randalmaile
randalmaile / Loops checkpoint
Last active December 30, 2015 18:19
Loops checkpoint
# Each loop (non-assignment practice)
[1] pry(main)> a = ["red", "blue", "green"]
=> ["red", "blue", "green"]
[2] pry(main)> a.each do |color|
[2] pry(main)* p "The color is #{color}"
[2] pry(main)* end
"The color is red"
"The color is blue"
"The color is green"
@randalmaile
randalmaile / Arrays Checkpoint
Last active December 30, 2015 17:59
Arrays Checkpoint
# ARRAY DEFINITION
def new_array(a,b,c,d)
#return an array consiting of the arguments here
$new_array = [a,b,c,d]
end
def first_and_last(a)
$first_and_last = [a.first, a.last]
end
@randalmaile
randalmaile / Reading RSpec Tests checkpoint
Last active December 30, 2015 15:59
Reading RSpec Tests checkpoint
def link_to(text, address)
p "<a href='#{address}'>#{text}</a>"
end
describe "link_to" do
it "should return a valid link for Bloc" do
link_to("Bloc", "http://www.bloc.io").should eq("<a href='http://www.bloc.io'>Bloc</a>")
end
it "should return a valid link for Google" do
link_to("Google", "http://www.google.com").should eq("<a href='http://www.google.com'>Google</a>")
@sevos
sevos / value_object.rb
Last active December 28, 2015 16:39
This is just an idea of value objects API and dirty implementation for Ruby. A frankenstein created from merge of Struct's and OpenStruct's APIs. It supoprts mandatory and optional fields. It raises exceptions if API of value object is misused. Feel free to comment and refactor the implementation!
# TODO: ValueObject should be immutable. Setter should return new instance.
class ValueObject < Struct
def self.new(*fields)
all_fields, optional_fields = if fields.last.is_a?(Hash)
optional_fields = fields.pop
[fields + optional_fields.keys, optional_fields]
else
[fields, {}]
end