Skip to content

Instantly share code, notes, and snippets.

Jagan Reddy reddyonrails

View GitHub Profile
View formik-debug.js
{debug && (
<>
<pre style={{ textAlign: "left" }}>
<strong>Values</strong>
<br />
{JSON.stringify(values, null, 2)}
</pre>
<pre style={{ textAlign: "left" }}>
<strong>Values</strong>
<br />
View mapStateToProps-vs-Selector.js
// Store Redux
state = {
cars: {
carsById: {
1: { id: 1, name "Toyota" },
2: { id: 2, name "Lexus" },
3: { id: 3, name "Honda" }
}
}
};
View mapStateToProps-vs-Selector.js
// Store Redux
state = {
cars: {
carsById: {
1: { id: 1, name "Toyota" },
2: { id: 2, name "Lexus" },
3: { id: 3, name "Honda" }
}
}
};
@reddyonrails
reddyonrails / rspec_model_testing_template.rb
Created Nov 8, 2019 — forked from kyletcarlson/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@reddyonrails
reddyonrails / nested-redis.rb
Created Nov 6, 2019 — forked from Loupi/nested-redis.rb
Redis Nested Comments in Ruby
View nested-redis.rb
require 'redis'
require 'json'
class CommentsRepository
def initialize
@redis = Redis.new
end
def save(itemId, comment, parentId = nil)
@reddyonrails
reddyonrails / git
Last active Aug 20, 2019
Delete merged branches (locally)
View git
$ git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d && git remote prune origin
@reddyonrails
reddyonrails / FactoryBot
Created Sep 10, 2018
FactoryBot for development
View FactoryBot
`require 'factory_bot'`
`FactoryBot.find_definitions`
View async_generator.js
async function *getRecords() {
const initialResponse = await getRecords();
yield* initialResponse.data;
let nextPage = initialResponse.pagination_token;
while(nextPage) {
const response = await getRecords(nextPage);
yield* response.data;
nextPage = response.pagination_token;
}
View es6mixin.js
var Bar1 = base => class extends base {
componentWillMount(){
super.componentWillMount();
console.log('Bar1');
}
};
var Bar2 = base => class extends base {
componentWillMount(){
super.componentWillMount();
@reddyonrails
reddyonrails / self_chain.rb
Created Apr 15, 2018
use instance methods with self for method chaining
View self_chain.rb
class Module
def with_chain(&block)
m = Module.new
m.instance_eval(&block)
m.methods(false).each do |name|
define_method name do
m.method(name).call
self
end
You can’t perform that action at this time.