Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dhamaniasad's full-sized avatar
🏠
Working from home

Asad Dhamani dhamaniasad

🏠
Working from home
View GitHub Profile
@Widdershin
Widdershin / ssr.md
Last active March 8, 2024 11:21
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@blankg
blankg / WebViewBridge.js
Last active July 12, 2022 06:53
For RN >= 0.57 please look at https://github.com/blankg/rn-webview-bridge-sample-new/blob/master/resources/index.html. Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
* A sample project that uses the bridge is available here https://github.com/blankg/rn-webview-bridge-sample
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*
* The API is designed to be similar to the Cordova exec API so migration to it should be almost seamless.
* The API also provides solution to a React-Native WebView bug in iOS which causes sending consecutive postMessage calls to override each other.
@zcaceres
zcaceres / Eyeballing-This.md
Last active August 17, 2023 23:38
Understanding Binding and 'this' in Javascript by zach.dev

How to Eyeball Your ‘This’ Context in Javascript

The early programmer struggles with the Javascript keyword this. But understanding your this context is easier than it seems.

This is all about where a function is invoked. Often, early programmers worry about where the function was declared. Perhaps the function was declared in a specific file or a particular object. Surely this changes it's this!

Nope.

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@kirilkirkov
kirilkirkov / gist:b13baec4b5142a527399693f8829547d
Created June 21, 2016 07:20
Difference between png-Interlaced, jpg-progressive AND png-non-Interlaced, jpg-baseline
Interlaced image loads an early degraded version of the whole image as soon as possible and then progressively renders the image to clear state.
Non-interlaced image will load up in tiles showing clear image in each tile as it progresses to load in the image.
For .jpg the interlaced = progressive and not interlaced = baseline.
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@srph
srph / oauth.js
Created February 21, 2016 13:50
axios: interceptor which includes your oauth token in every request as an Authorization header
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
@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

module.exports = {
up: function (queryInterface, Sequelize) {
return [
queryInterface.addColumn('User', 'name', {
type: Sequelize.STRING
}),
queryInterface.addColumn('User', 'nickname', {
type: Sequelize.STRING,
})
];