Skip to content

Instantly share code, notes, and snippets.

View phuochau's full-sized avatar
👨‍💻

Hau Vo phuochau

👨‍💻
View GitHub Profile
@phuochau
phuochau / config.yml
Last active September 24, 2017 13:01
CircleCI 2.0 configuration for Phoenix project
# Phoenix CircleCI 2.0 configuration file
#
# Modify configuration for Ecto in config/test.exs like below:
#
# config :project, Project.Repo,
# adapter: Ecto.Adapters.Postgres,
# username: System.get_env("DATA_DB_USER"),
# password: System.get_env("DATA_DB_PASS"),
# hostname: System.get_env("DATA_DB_HOST"),
# database: "project",
@phuochau
phuochau / absinthe_partitions_sample.ex
Last active October 19, 2017 22:47
Sample for using partitions (types, queries, mutations) in absinthe. It's very useful for big app or umbrella app.
# Types
defmodule Auth.GraphQL.Schema.Account do
use Absinthe.Schema.Notation
object :account do
field :id, :string
field :email, :string
field :password, :string
field :insert_at, :string
field :updated_at, :string
open -a Google\ Chrome --args --disable-web-security --user-data-dir
@phuochau
phuochau / README.md
Created October 23, 2017 13:04 — forked from bomberstudios/README.md
Loading a Cocoa Framework in a Sketch Plugin

This is what Craft does:

function loadFramework(pluginRoot) {
  if (NSClassFromString('PanelsManager') == null) {
    var mocha = [Mocha sharedRuntime];
    return [mocha loadFrameworkWithName:'Panels' inDirectory:pluginRoot];
  } else {
    return true;
 }
@phuochau
phuochau / UIHelper.js
Last active October 25, 2017 23:48
Better runAfterInteractions for React Native
import { InteractionManager } from 'react-native';
export const runAfterInteractions = (f) => {
let called = false;
const timeout = setTimeout(() => { called = true; f(); }, 500);
InteractionManager.runAfterInteractions(() => {
if (called) return;
clearTimeout(timeout);
f();
});
@phuochau
phuochau / test_helper.exs
Last active October 25, 2017 23:50
Load .ex module in unit testing in Elixir
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Sharing.Repo, :manual)
## load helpers, support
Code.load_file("test/case/ecto.ex")
Code.load_file("test/support/absinthe_helper.ex")
@phuochau
phuochau / absinthe_helper.ex
Last active October 25, 2017 23:51
Absinthe Helper for Elixir
defmodule Test.Support.AbsintheHelper do
def mutation_skeleton(query) do
%{
"operationName" => "",
"query" => "#{query}",
"variables" => ""
}
end
def query_skeleton(query, query_name) do
import React, { Component } from 'react'
import {
View,
InteractionManager
} from 'react-native'
export default class Screen extends Component {
constructor (props) {
super(props)
this.state = {
@phuochau
phuochau / sample_geo_fire_and_firebase.js
Last active March 6, 2018 04:51
This is an example for Geofire and Firebase
const { user, profiles } = this.state
const swipedProfiles = await this.getSwiped(uid)
const geoFireRef = new GeoFire(firebase.database().ref('geoData'))
const userLocation = [user.geolocation.latitude, user.geolocation.longitude]
const geoQuery = geoFireRef.query({
center: userLocation,
radius: distance
})
geoQuery.on('key_entered', async (uid, location, distance) => {
log(uid + ' at ' + location + ' is ' + distance + 'km from the center')