Skip to content

Instantly share code, notes, and snippets.

edmangimelli / backup_db_to_s3.rake
Last active Jan 12, 2019
rails rake task for backing up heroku database to s3 bucket
View backup_db_to_s3.rake
# this gist was inspired by hopsoft's
# and a snippet given to me by mckbeardy on Midwest Dev Chat (Zach Mckenzie)
# put this file in lib/tasks
# your_rails_project/lib/tasks/backup_db_to_s3.rake (or whatever you want to name it)
# usage:
# rails db:backup_to_s3

A Small Example of the Convenience of Currying

A while back I made a helper function:

export const accessor = (obj, defaultValue = null) => x => _.get(obj, x, defaultValue);

Pretty straightforward. It's just a function which creates a custom version of lodash's get for a specific object. Great for react.

View statuses_of_yester_year
:shipit: using computers to answer deep questions
e='ve';r='y'; r=a=>c=>e<=c<=a<=r; i='s'; r`aviol`(i) ? true : false
🐙 ☕☕☕☕☕☕

I've recently started wrapping the inside of my recursive functions to protect them against renaming/passing:

For instance, say you have:

let factorial = n => {
  if (n == 1) return 1;
  return n * factorial(n-1);

can't stand typing target.value; love type ellipses?

const Input = props => {
  const onChange = props.onChange && (({target}) => props.onChange(target.value));
  return <input {...{...props, ...onChange && {onChange}}} />;


# ls aliases
# in the context of the current directory
# l list everything
# ld list just the directories
# lf list just the files
# ^^^ these can be coupled with some modifiers.
# modifier examples:
View Ruby - Using Ampersand in Front of an

When giving a block to a method, I think of it as sending a special proc argument.

You can send regular positional arguments, or kwargs, and you can also send 1 special proc argument.

When you use the literal syntax:

some_method { |x| x.to_s }

it's called a block, though it's really just a special syntax for a proc (special syntax in that it ends up having an elevated status in the method body (see yield)).