Skip to content

Instantly share code, notes, and snippets.

Avatar

Hamza SalahHamza

View GitHub Profile
@SalahHamza
SalahHamza / concurrent-mode-suspense.js
Last active Jan 15, 2022
Concurrent Mode Suspense example
View concurrent-mode-suspense.js
/**
* 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 Dec 8, 2020 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis
View 0-github-actions.md

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.
View reset.css
/* 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 Nov 20, 2019 — forked from gordonbrander/ID.js
ID - a unique ID/name generator for JavaScript
View ID.js
// 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 Sep 13, 2019
Import a Heroku PG dump into local machine
View import_heroku_pg.md

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 Aug 28, 2019 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?
View heroku_pg_db_reset.md

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 Aug 28, 2019 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?
View heroku_pg_db_reset.md

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 Aug 13, 2019 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet
View RAILS_CHEATSHEET.md

Ruby on Rails Cheatsheet

Architecture

Create a new application

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

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