Skip to content

Instantly share code, notes, and snippets.

@sdvg
sdvg / hoodieClient.js
Created April 3, 2017 18:26
Hoodie with react native
import PouchDB from 'pouchdb-react-native';
import SQLite from 'react-native-sqlite-storage';
import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite';
import Hoodie from '@hoodie/client';
import appConfig from './appConfig';
const SQLiteAdapter = SQLiteAdapterFactory(SQLite); // eslint-disable-line new-cap
PouchDB.plugin(SQLiteAdapter);

GraphQL vs Firebase

With the variety of server-side technologies today, developers have a lot of choices when it comes to deciding what kind of backend to use for their next application.

In this article, we want to explore the differences between GraphQL and Firebase, two very popular server-side technologies.

Overview

Before diving into technical details, let's create some perspective on the two technologies and where they're coming from.

@wojteklu
wojteklu / clean_code.md
Last active March 14, 2026 07:57
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@wesbos
wesbos / commit-msg
Created July 4, 2016 18:55
ESLint 3.0 Git Pre Commit Hook
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.jsx\?$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
failed=0
for file in ${files}; do
@paulirish
paulirish / what-forces-layout.md
Last active March 15, 2026 16:37
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@Rich-Harris
Rich-Harris / makeObservable.js
Last active December 26, 2015 18:28
Utility for making observable objects
// Usage
// =====
//
// Create an observable object:
//
// obj = makeObservable();
// obj.set( 'foo', 'bar' );
//
// observer = obj.observe( 'foo', function ( newFoo, oldFoo ) {
// alert( 'foo changed from ' + oldFoo + ' to ' + newFoo ); // alerts 'foo changed from undefined to bar'
@AutoSponge
AutoSponge / array.js
Last active December 25, 2015 14:49
function-first curried natives and their array-first counterparts
(function (global, a, f) {
var list = ["map", "filter", "some", "every", "reduce", "reduceRight", "sort"];
function flip(fn) {
return function (that, arg) {
//use arguments length because arg could be falsey
return arguments.length > 1 ? fn.call( that, this, arg ) : fn.call( that, this );
// Copyright 2013 Simple Module Pattern
// @Authors - Luan Fagundes
// @Reference - BRAZILJS
$(function(){
'use strict';
var PUBLIC = {},
PRIVATE = {};
@luan03
luan03 / utils.js
Created August 13, 2013 14:34
Utils
// Copyright 2013 Javascript Utils
// @Authors - Luan Fagundes
// @Reference - http://devdocs.io/javascript/
// @Add - [strdate]
(function () {
'use strict';
var Module;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>fake ajax</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="fake.js"></script>
<script src="config.js"></script>
<script>