Skip to content

Instantly share code, notes, and snippets.

View ragmha's full-sized avatar

Räghib Hasan ragmha

View GitHub Profile
@ragmha
ragmha / Event-stream based GraphQL subscriptions.md
Created May 15, 2019 18:52 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@ragmha
ragmha / App.js
Created January 6, 2019 11:02 — forked from shelldandy/App.js
nprogress with react-router in create-react-app
import React from 'react'
import { BrowserRouter as Router, Switch } from 'react-router-dom'
import routes from './routes'
import FancyRoute from './components/tools/FancyRoute'
const App = props =>
<Router>
<Switch>
{routes.map((route, i) =>
<FancyRoute key={i} {...route} />
@ragmha
ragmha / host-react-app-on-apache-server.md
Created December 18, 2018 17:24 — forked from ywwwtseng/host-react-app-on-apache-server.md
Host react application on Apache server

Host react application on Apache server

Step 1 : Create your app

$ npm install -g create-react-app 
$ create-react-app my-app

Step 2 : Build it for production

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at [email protected] or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

@ragmha
ragmha / tinder.js
Created May 23, 2018 20:45 — forked from osanyin/tinder.js
Tinder auto-swipe
var likebutton = $('.recsGamepad__button--like')
function swipe() { likebutton.click() }
setInterval(swipe, 150)
@ragmha
ragmha / README.md
Created February 16, 2018 19:45 — forked from jesstelford/README.md
Starving the Event Loop with Microtasks

Starving the Event Loop with microtasks

"What's the Event Loop?"

Sparked from this twitter conversation when talking about doing fast async rendering of declarative UIs in Preact

These examples show how it's possible to starve the main event loop with microtasks (because the microtask queue is emptied at the end of every item in the event loop queue). Note that these are contrived examples, but can be reflective of situations where Promises are incorrectly expected to yield to the event loop "because they're async".

  • setTimeout-only.js is there to form a baseline
@ragmha
ragmha / *state-machine-component.md
Created September 14, 2017 12:21 — forked from developit/*state-machine-component.md
265b lib for building pure functional state machine components. https://npm.im/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@ragmha
ragmha / express-server-side-rendering.md
Created September 7, 2017 18:33 — forked from joepie91/express-server-side-rendering.md
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
import webpack from 'webpack';
import { resolve } from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ProgressBarPlugin from 'progress-bar-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import combineLoaders from 'webpack-combine-loaders';
import { getIfUtils, removeEmpty } from 'webpack-config-utils';
import autoprefixer from 'autoprefixer';