Skip to content

Instantly share code, notes, and snippets.

@lelandrichardson
lelandrichardson / react-native.js
Last active July 21, 2022 17:56
React Native flow types
declare var __DEV__: boolean;
declare module 'react-native' {
declare type Color = string | number;
declare type Transform =
{ perspective: number } |
{ scale: number } |
{ scaleX: number } |
@sakti
sakti / INSTALL.rst
Last active March 29, 2020 18:21 — forked from jensens/INSTALL.rst
sentry setup with docker-compose

In order to run this image do: docker-compose up -d to get all up. On first run DB initialization and initial user setup is done like so:

First start a bash in the container: docker-compose exec sentry /bin/bash. Then, inside bash, do sentry upgrade wait until it asks you for an inital user. When finished exit the bash.

When in doubt check with docker-compose ps if all went fine.

@knowbody
knowbody / App.js
Last active September 11, 2023 09:31
Check internet connection in React Native app
// quick snippet to check the connection in your RN app
// dispatches an `setIsConnected` action every time the NetInfo changes (on/off network)
componentDidMount() {
const dispatchConnected = isConnected => this.props.dispatch(setIsConnected(isConnected));
NetInfo.isConnected.fetch().then().done(() => {
NetInfo.isConnected.addEventListener('change', dispatchConnected);
});
}
@nulltask
nulltask / trapezoid.js
Created February 15, 2012 12:53
trapezoid image transform with node-canvas
/**
* Trapezoid
* - Image transforming class.
*
* Heavily inspired from:
* http://www.leven.ch/canvas/perspective.html
*/
/**
* Module dependencies.
@stephenmcd
stephenmcd / slumber_django_testclient.py
Created February 8, 2012 04:58
Subclass of ``slumber.API`` that patches ``requests.request`` with Django test client compatible HTTP requests.
from collections import namedtuple
from django.test import TestCase
from requests.auth import HTTPBasicAuth
import slumber
class SlumberTestClientAPI(slumber.API):
"""
Subclass of ``slumber.API`` that patches ``requests.request``
@gordonbrander
gordonbrander / LiveCollection.js
Created December 27, 2011 19:40
Backbone Live Collections w/ Streaming and Automatic Duplicate Handling
var LiveCollection = (function (_, Backbone) {
var Collection = Backbone.Collection;
// Define a Backbone Collection handling the details of running a "live"
// collection. Live collections are expected to handle fetching their own
// data, rather than being composed from separate models.
// They typically add new models instead of resetting the collection.
// A custom add comparison makes sure that duplicate models are not
// added. End result: only new elements will be added, instead
// of redrawing the whole collection.
//
@mattheworiordan
mattheworiordan / gist:1037984
Created June 21, 2011 14:35
Backbone patch to defer update method requests when new create requests are not complete on a model
(function() {
Backbone.Model.prototype._save = Backbone.Model.prototype.save;
Backbone.Model.prototype.save = function(attrs, options) {
var that = this;
if (!options) { options = {}; }
if (this.savingNewRecord) {
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well
_(['success','error']).each(function(event) {
// convert all callbacks to a single array of callbacks)