Skip to content

Instantly share code, notes, and snippets.

Avatar
✔️
Verified

Mohamed Ziata WaKeMaTTa

✔️
Verified
View GitHub Profile
@WaKeMaTTa
WaKeMaTTa / migration.rb
Last active Apr 17, 2020
Rails migration with foreign key cascade
View migration.rb
class UpdateForeignKey < ActiveRecord::Migration[5.0]
def change
add_reference :posts, :users, index: true, foreign_key: { on_delete: :cascade }
end
end
View spec.rb
# Use TDD principles to build out name functionality for a Person.
# Here are the requirements:
# - Add a method to return the full name as a string. A full name includes
# first, middle, and last name. If the middle name is missing, there shouldn't
# have extra spaces.
# - Add a method to return a full name with a middle initial. If the middle name
# is missing, there shouldn't be extra spaces or a period.
# - Add a method to return all initials. If the middle name is missing, the
# initials should only have two characters.
#
@WaKeMaTTa
WaKeMaTTa / .gemrc
Created Aug 16, 2016 — forked from jch/.gemrc
gemrc example
View .gemrc
# http://docs.rubygems.org/read/chapter/11
---
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
sources:
- http://gems.rubyforge.org/
- http://rubygems.org/
backtrace: true
@WaKeMaTTa
WaKeMaTTa / hash_serializer.rb
Created Jun 16, 2016
app/serializers/hash_serializer.rb
View hash_serializer.rb
# app/serializers/hash_serializer.rb
class HashSerializer
def self.dump(hash)
hash.to_json
end
def self.load(hash)
hash = ActiveSupport::JSON.decode(hash) if hash.is_a? String
(hash || {}).with_indifferent_access
end
View capybara_cheat_sheet.md

Navigating

visit("/projects")
visit(post_comments_path(post))

Clicking links and buttons

@WaKeMaTTa
WaKeMaTTa / bug_report_enum_and_paper_trail.rb
Last active May 16, 2016
Bug report : Enum and PaperTrail
View bug_report_enum_and_paper_trail.rb
# Issues https://github.com/airblade/paper_trail/issues/798
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
View error.sh
Unable to download https://www.atom.io/api/packages/linter-plus-eslint/versions/0.4.0/tarball: 400 Bad Request Repository inaccessible
@WaKeMaTTa
WaKeMaTTa / syntax-type-1.jsx
Created Jan 12, 2016
Which syntax is more better to use?
View syntax-type-1.jsx
class MoviesApp extends Component {
render() {
var initialRoute = {name: 'search'};
return (
<Navigator
style={styles.container}
initialRoute={initialRoute}
configureScene={() => Navigator.SceneConfigs.FadeAndroid}
renderScene={RouteMapper}
/>
View gist:ee0d9ca166703ee1a86d
https://plus.google.com/hangouts/_/ytl/sSPRzi9D_lX1WoXVxtDJp5fm0IB0NLBXy-hFehGfzAs=?hl=es_ES&authuser=0