Skip to content

Instantly share code, notes, and snippets.

View auser's full-sized avatar

Ari auser

View GitHub Profile
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
# Old
[latStr, lngStr] = String.split(geo, ",")
{lat, _} = Float.parse(latStr)
{lng, _} = Float.parse(lngStr)
[bl, tr] = Geocalc.bounding_box([lat,lng], 10_000)
[lat1, lng1] = bl;
[lat2, lng2] = tr;
coords = "#{lat1}, #{lng1}, #{lat2}, #{lng2}"
# elixir
{:ok, pid} = Mongo.start(database: "test")
coll = "tags"
pipeline = [
%{'$project': %{ 'b': %{ '$in': ["b", ["a", "b", "c"]] } }},
%{'$match': %{ 'b': true }},
%{'$project': %{ 'b': 0 }}
]
Mongo.aggregate(pid, coll, pipeline) |> Enum.to_list
@auser
auser / rename.sh
Created December 29, 2016 09:42 — forked from nerdyworm/rename.sh
rename a phoenix project
#!/bin/bash
set -e
CURRENT_NAME="CurentName"
CURRENT_OTP="current_name"
NEW_NAME="NewName"
NEW_OTP="new_name"
/**
* Small helper to split an array into groups of various size
*
* Usage:
* group([1, 2, 3, 4, 5], 2) # -> [[1, 2], [3, 4], [5]]
* group([1, 2, 3, 4], 5) # -> [[1, 2, 3, 4]]
**/
let group = (arr, numPerGroup) => {
if (arr.length <= 0) return [];
let groups = [];
import React, { Component } from 'react';
import {
Text,
View,
TouchableOpacity,
ActivityIndicator,
Navigator
} from 'react-native';
import {GoogleSignin} from 'react-native-google-signin';
import Firestack from 'react-native-firestack'
@auser
auser / app.js
Last active September 22, 2016 21:59
import React from 'react'
import { Provider } from 'react-redux'
import { AppRegistry } from 'react-native';
import App from './containers/App'
import {
configureStore
} from './redux/configureStore'
const {store, actions} = configureStore();
/*
* A small wrapper to turn a prototype, callback object
* to a chainable api using promises.
*
* Usage:
* var Klass = function() {}
* Klass.prototype.log = function(msg, cb) {
* console.log(msg);
* cb();
* }
// config/development.js
module.exports = {
NAME: 'FirestackDemo.dev',
firestack: {
apiKey: "XXXXXXXX",
authDomain: "your-auth-domain.firebaseapp.com",
databaseURL: "https://your-database-url.firebaseio.com",
storageBucket: "your-storage-bucket.appspot.com",
}
}
import {createConstants, createReducer} from 'redux-module-builder'
import {createApiHandler, createApiAction} from 'redux-module-builder/api'
/*
* Constants
*
* Basic constants can just be a name
* i.e. 'GET_ME'
* and api constants can be an Object
* i.e. { 'GET_UPCOMING': { api: true }}