Skip to content

Instantly share code, notes, and snippets.

View gurdasnijor's full-sized avatar
🤠

Gurdas Nijor gurdasnijor

🤠
View GitHub Profile
@nkbt
nkbt / .eslintrc.js
Last active May 11, 2024 13:03
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@nelix
nelix / actions.js
Created March 16, 2015 02:03
No callbacks
import { Actions } from 'flummox';
export default class TodoActions extends Actions {
constructor(db) {
super();
this.db = db;
}
async create(model) {
(ns datascript-to-datomic-util
(:require [datascript :as d]))
;;;; a utility to help with a datomic-datascript roundtrip process involving:
;;; 1. export some data from a datomic database and transact into a datascript instance.
;;; 2. perform one or more transactions against datascript.
;;; 3. transact the sum of all changes made against datascript back into datomic in a single tx
;;; this namespace contains two public functions:
;;; listen-for-changes: listen to datascript transactions and build up a record of changes
@Schniz
Schniz / async-route.js
Last active August 25, 2016 05:11
Async react router component for using webpack chunks like Instagram guys do. work in progress.
/** @jsx React.DOM */
var React = require('react');
var handlers = {};
var AsyncRoute = function(req) {
return React.createClass({
getInitialState: function() {
return {
myComponent: handlers[req]
@brigand
brigand / _readme.md
Last active January 9, 2021 16:09
ImmutableJS macros for SweetJs

These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].

The most interesting being the Map literal

var map = im{"foo": "bar", "baz": "quux"};

This compiles to the 2d array version of Immutable.Map.

@latentflip
latentflip / gf.md
Last active April 14, 2021 03:29
vim, gf, and node

Vim, gf and node.

So, I just learned that gf exists. If your cursor is over a path in vim, and you type gf, it'll open that file/dir in a new buffer. You can also open in a new window/tab as detailed here.

In node, it'd be great if you could jump to a required file, huh? Trouble is, typically you don't put the .js on your require('./path/to/a/js/file'). No matter, vim has your back, just add set suffixesadd+=.js to your .vimrc and vim will try adding .js and see if it can find that file instead.

If you do a lot of spelunking in node_modules, it'd be great if you could jump to the directory of a required npm module too, right? A la, require('my-awesome-module'). Well, you can add set path+=$PWD/node_modules to your .vimrc too, and vim will add node_modules to the path, and jump to it's directory in node_modules (caveat: you must have opened vim from your project root for this too work).

For your cmd+c convenience:

@irvinebroque
irvinebroque / hotLoadServer.js
Last active August 29, 2015 14:10
Server-side React-Router v0.11 + React-Hot-Loader
// This little dev server is basically a wrapped express server that 'hot loads' our javascript for super fancy and fast live reload in development
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var port = process.env.HOT_LOAD_PORT || 3001;
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true
@gaearon
gaearon / observeStore.js
Last active May 19, 2022 10:55
Wait for some condition to become true on a Flux store, useful for react-router async transition hooks
// Usage example:
//
// willTransitionTo(transition, params, query, callback) {
// observeStore(DraftStore, s => s.isLoaded()).then(() => {
// if (DraftStore.isMissingTitle()) {
// transition.redirect('composeDraft', params);
// }
// }).finally(callback);
// }
@sebmarkbage
sebmarkbage / react-terminology.md
Last active January 9, 2023 22:47
React (Virtual) DOM Terminology
@gaearon
gaearon / createAsyncPage.jsx
Last active April 25, 2023 09:06
Webpack's async code splitting with React Router
'use strict';
var React = require('react');
function createAsyncHandler(getHandlerAsync, displayName) {
var Handler = null;
return React.createClass({
displayName: displayName,