Skip to content

Instantly share code, notes, and snippets.

View Thunderbird7's full-sized avatar
🏠
Working from home

Yuttana K. Thunderbird7

🏠
Working from home
View GitHub Profile
import { NativeModules } from 'react-native'
import Config from 'config.json'
const environment = NativeModules.RNConfig.buildEnvironment
const getAPIURL = () => {
console.log('Current ENV: ', environment)
return Config[environment].apiURL
}
export default {
// environment configure
{
"development": {
"apiURL": "https://myapi-dev.company.com",
"codepushKey": "YOUR_KEY"
},
"staging": {
"apiURL": "https://myapi-staging.company.com",
"codepushKey": "YOUR_KEY"
},
// RNConfig.h
#import <React/RCTBridgeModule.h>
@interface RNConfig : NSObject<RCTBridgeModule>
@end
// RNConfig.m
#import "RNConfig.h"
#define kEnvironment "BuildEnvironment"
import ApolloClient, { createNetworkInterface } from 'apollo-client'
export default function client() {
const networkInterface = createNetworkInterface({
uri: 'https://localhost/graphql'
})
const apolloClient = new ApolloClient({ networkInterface })
return apolloClient
}
@Thunderbird7
Thunderbird7 / ApolloQueryAction.js
Last active January 11, 2017 14:37
Apollo Query Redux
// Apollo Client query in Action...
import apolloClient from './client'
import gql from 'graphql-tag'
const client = apolloClient()
export function getMyProfile() {
const myQuery = {
query: gql`
query {
profile {
// แสดงเฉพาะสิ่งที่สำคัญ
// ...
import { graphql } from 'react-apollo'
import gql from 'graphql-tag';
class App extends Component {
// ...
render() {
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import App from './App'
import ApolloClient, { createNetworkInterface } from 'apollo-client'
import { ApolloProvider } from 'react-apollo'
const networkInterface = createNetworkInterface({
uri: 'http://graphql-swapi.parseapp.com'
})
/* split page by page with key */
{
// key for page 1
"page1": [ /* key for page 1 */
{ /* form type input */
"type": "textfield",
"payload": {
"label": "Name",
"placeholder": "your name"
}

#การใช้ Git ฉบับรีบร้อน

##Git Git เป็น revision control แบบ distributed (หมายความว่าไม่มีศูนย์กลาง) และ แบบ non-linear history (หมายความว่ามีประวัติการเปลี่ยนแปลงแบบไม่ใช่เส้นตรง) ดังนั้นทำให้คอนเซปต์ของ Git นั้นต่างจาก revision control รุ่นก่อนหน้าหลายอย่าง

ต่อไปจะอธิบายย่อๆเรื่องคำสั่ง Git โดยอิงกับการทำงานใน GitHub เป็นสำคัญ (Git มีวิธีใช้พลิกแพลงมากมาย ไปศีกษาการใช้อื่นได้ด้วยการไป Google เอาเอง)

##clone

สมมุติว่ามี repository แห่งนีงใน GitHub เช่น https://github.com/norsez/projectA

@Thunderbird7
Thunderbird7 / RegExHelper.Swift
Created March 8, 2016 03:45
Regular Expression helper in Swift 2 / match, replace with your pattern!
//
// Regex.swift
// Jitta
//
// Created by Yuttana Kungwon on 3/6/2559 BE.
// Copyright © 2559 Jitta Company. All rights reserved.
//
import Foundation