Skip to content

Instantly share code, notes, and snippets.

View hrishimittal's full-sized avatar

Hrishi Mittal hrishimittal

View GitHub Profile
@amite
amite / functional-setstate.js
Last active September 18, 2017 09:14
Immutable Updates to nested data with setState in React
// Functional setState (Recommended)
this.setState(prevState => {
const newState = {
...prevState.data,
transactions: [...data, prevState.data.transactions]
}
return { data: newState }
})
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 6, 2023 22:04
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@dirkgroenen
dirkgroenen / gist:07c3e8e4bc7e08bc3232ae0bdd6a0ba5
Last active July 8, 2023 05:13 — forked from wrburgess/gist:5528649
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@ryanflorence
ryanflorence / rails-ey.jsx
Last active February 2, 2018 22:01
Rail-ey style routes
const lookup = (namespace) => {
// if you really want rails-style indirection, you'd
// need an app container that could look up modules
// by strings.
}
const Resources = ({ namespace }) => {
const Layout = lookup(namespace, 'layout')
return (
<Route path={`/${namespace}`} render={() => (
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@mdang
mdang / RAILS_CHEATSHEET.md
Last active April 13, 2024 15:36
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

buttonHTML = """<button type="button" class="attach" data-action="x-attach">Attach Files</button>"""
fileInputHTML = """<input type="file" multiple>"""
$(Trix.config.toolbar.content).find(".button_group.block_tools").append(buttonHTML)
$(document).on "trix-action-invoke", ($event) ->
if $event.originalEvent.actionName is "x-attach"
editorElement = $event.target
editorElement.focus()
@hrishimittal
hrishimittal / Equity.md
Last active March 1, 2024 21:13 — forked from isaacsanders/Equity.md
Joel Spolsky's Totally Fair Method to Divide Up The Ownership of Any Startup

This is a post by Joel Spolsky, originally posted on answers.onstartups.com in response to a question. You can find a copy here.

Forming a new software startup, how do I allocate ownership fairly?

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea

@patio11
patio11 / annual-prepay.md
Last active February 23, 2024 11:16
Appointment Reminder Annual Pre-pay copy (2014)

Notes

This is the latest version of an email which I send periodically, offering customers the opportunity to pre-pay for SaaS in return for a discount. The benefits to the SaaS company are better cash flow and reduced churn rate. The benefits to the customer are, well, in the email. This genre of email has produced hundreds of thousands of dollars in pre-pays for some companies I work with, and it rarely requires any more work than this example.

I've put $79 is as a placeholder for the cost of the user's plan. We calculate that for each account, naturally, along with the billing contact's name.

Subject: Save $79 on Appointment Reminder (and get a tax write-off) Formatting: 100% plain text. Gmail automatically links up the central link. From: Patrick McKenzie (Appointment Reminder) patrick@appointmentreminder.org

@stevegraham
stevegraham / active_jerbz.rake
Created December 4, 2014 15:47
Run ActiveJobs with Sneakers
require 'sneakers/runner'
task :environment
namespace :sneakers do
desc "Start processing jobs with all workers"
task :work => :environment do
silence_warnings do
Rails.application.eager_load! unless Rails.application.config.eager_load
end