Skip to content

Instantly share code, notes, and snippets.

View SalahHamza's full-sized avatar

Hamza SalahHamza

View GitHub Profile
@SalahHamza
SalahHamza / concurrent-mode-suspense.js
Last active January 15, 2022 18:53
Concurrent Mode Suspense example
/**
* The issues I found are the following:
* 1) No 'fallback', the benefit of suspense is to render as early as possible.
* 2) The component fetching the data should "suspend", fetching user profile in a useEffect
* Doesn't do that.
* 3) The suspense should wrap the componenet fetching the data (i.e. SuspensefulUserProfile).
*
* Extra notes:
* - Making a request for each profile separately is definitely something to be avoided,
@SalahHamza
SalahHamza / 0-github-actions.md
Created December 8, 2020 17:43 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@SalahHamza
SalahHamza / ID.js
Created November 20, 2019 20:08
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@SalahHamza
SalahHamza / import_heroku_pg.md
Created September 13, 2019 16:21
Import a Heroku PG dump into local machine

Import a Heroku PG dump into local machine

Follow these 4 simple steps in your terminal (Heroku Dev Center): Create a backup copy of your database:

$ heroku pg:backups capture DATABASE_NAME

Download the copy from Heroku (to your local machine) using curl:

$ curl -o latest.dump `heroku pg:backups public-url`
@SalahHamza
SalahHamza / heroku_pg_db_reset.md
Created August 28, 2019 03:32 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate

@SalahHamza
SalahHamza / heroku_pg_db_reset.md
Created August 28, 2019 03:32 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate

@SalahHamza
SalahHamza / RAILS_CHEATSHEET.md
Created August 13, 2019 21:20 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

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

store = {
apple: {
price: 2,
quantity: 40
},
pineapple: { price: 3, quantity: 80},
strawberry: { price: 6, quantity: 60},
}