Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Arup Rakshit aruprakshit

🏠
Working from home
Block or report user

Report or block aruprakshit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aruprakshit
aruprakshit / mapDispatchToProps.md
Created Nov 20, 2018 — forked from heygrady/mapDispatchToProps.md
Redux containers: mapDispatchToProps
View mapDispatchToProps.md

Redux containers: mapDispatchToProps

This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps argument of the connect function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps can take.

View reduxSelectorPattern.md

Redux Selector Pattern

Imagine we have a reducer to control a list of items:

function listOfItems(state: Array<Object> = [], action: Object = {}): Array<Object> {
  switch(action.type) {
    case 'SHOW_ALL_ITEMS':
      return action.data.items
    default:
View database.yml
development:
adapter: postgresql
encoding: utf8
database: campflame_development
pool: 5
host: ''
test:
adapter: postgresql
encoding: utf8
@aruprakshit
aruprakshit / 000_postgresql_fancy_datatypes
Created Oct 8, 2015 — forked from pcreux/000_postgresql_fancy_datatypes
Postgresql fancy datatypes with Rails / ActiveRecord. Run it with `rake`!
View 000_postgresql_fancy_datatypes
# Postgresql fancy datatypes!
* array
* hstore (=~ hash)
* json
* jsonb
Philippe Creux - [@pcreux](http://twitter.com/pcreux)
@aruprakshit
aruprakshit / multiple_ssh_setting.md
Last active Aug 29, 2015 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
View chain-of-responsibility.rb
class PurchaseApprover
# Implements the chain of responsibility pattern. Does not know anything
# about the approval process, merely whether the current handler can approve
# the request, or must pass it to a successor.
attr_reader :successor
def initialize successor
@successor = successor
end
View visitor_pattern_example.rb
class CarElement
def accept(visitor)
raise NotImpelementedError.new
end
end
module Visitable
def accept(visitor)
visitor.visit(self)
end
View encoding-line-break-test.rb
#!/usr/bin/ruby -w
FILE_NAME = "x"
printf "%-20s %p\n%-20s %p\n",
"Default external", Encoding.default_external,
"Default internal", Encoding.default_internal
# p File.instance_methods.grep(/enc|opt/)
View db.rake
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
View delete-heroku-apps.sh
for app in $(heroku apps); do heroku apps:destroy --app $app --confirm $app; done
You can’t perform that action at this time.