Skip to content

Instantly share code, notes, and snippets.

View seyna's full-sized avatar

Wen Yi Chu seyna

View GitHub Profile
@seyna
seyna / request.py
Last active September 5, 2018 15:00
Python codes to get API content and send POST
import requests
import json
# an example url, which actually returns JSON
url = "https://crawler.goodfind.com.tw/d/E0pvWZk1"
# this is how to do HTTP GET
r = requests.get(url)
# print returned content
@seyna
seyna / MyNewContainer.js
Created April 18, 2018 07:04
add codes to fetch remote data and render it with spinner loading
import React, { Component } from 'react'
import { Alert, ListView, BackHandler, FlatList } from 'react-native' // add Alert and ListView
import { Container, Text, Header, Content, Form, Item, Input, Label, Button, Icon, Picker, List, ListItem, Thumbnail, Body, Spinner } from 'native-base';
import { connect } from 'react-redux'
// Add Actions - replace 'Your' with whatever your reducer is called :)
// import YourActions from '../Redux/YourRedux'
// Styles
// import styles from './Styles/MyNewContainerStyle'
@seyna
seyna / MyNewContainer.js
Created April 18, 2018 05:13
add form elements and trigger message alert after submitting successfully
import React, { Component } from 'react'
import { Alert, ListView, BackHandler } from 'react-native' // add Alert and ListView
import { Container, Text, Header, Content, Form, Item, Input, Label, Button, Icon, Picker } from 'native-base';
import { connect } from 'react-redux'
// Add Actions - replace 'Your' with whatever your reducer is called :)
// import YourActions from '../Redux/YourRedux'
// Styles
// import styles from './Styles/MyNewContainerStyle'
@seyna
seyna / MyNewContainer.js
Created April 13, 2018 15:53
for firebase practice
import React, { Component } from 'react'
import { Alert, ListView, BackHandler } from 'react-native' // add Alert and ListView
import { Content, Text } from 'native-base'
import { connect } from 'react-redux'
// Add Actions - replace 'Your' with whatever your reducer is called :)
// import YourActions from '../Redux/YourRedux'
// Styles
// import styles from './Styles/MyNewContainerStyle'
@seyna
seyna / StatusBar.js
Created April 13, 2018 15:51
for firebase practice
'use strict';
import React, {Component} from 'react';
const styles = require('./Styles/styles.js')
import ReactNative from 'react-native';
const { StyleSheet, Text, View} = ReactNative;
class StatusBar extends Component {
render() {
return (
<View>
@seyna
seyna / ListItem.js
Created April 13, 2018 15:51
for firebase practice
import React, {Component} from 'react';
const styles = require('./Styles/styles.js')
import ReactNative from 'react-native';
const { View, TouchableHighlight, Text } = ReactNative;
class ListItem extends Component {
render() {
return (
<TouchableHighlight onPress={this.props.onPress}>
<View style={styles.li}>
@seyna
seyna / ActionButton.js
Created April 13, 2018 15:50
for firebase practice
'use strict';
import React, {Component} from 'react';
import ReactNative from 'react-native';
const styles = require('./Styles/styles.js')
const constants = styles.constants;
const { StyleSheet, Text, View, TouchableHighlight} = ReactNative;
class ActionButton extends Component {
render() {
@seyna
seyna / styles.js
Created April 13, 2018 15:32
for firebase practice
const React = require('react-native')
const {StyleSheet} = React
const constants = {
actionColor: '#24CE84'
};
var styles = StyleSheet.create({
container: {
backgroundColor: '#f2f2f2',
flex: 1,
# in app/controllers/family_controller.rb
#
# find out if there is prize remained to draw
prize_remained_count = 65 - Lotterywinner.where(:prize_id => 1).size if pid == 1
prize_remained_count = 0 if pid == 2
prize_remained_count = 0 if pid == 3
prize_remained_count = 0 if pid == 4
if @user.puzzlepieces.where(:puzzle_id => pid).map(&:position_number).uniq.size == 8
if (cur<<position_number).uniq.size == 9 && prize_remained_count > 0 # important
@seyna
seyna / _puzzle_history.html.erb
Last active August 29, 2015 14:25
A possible way to fix error message
<div class="puzzle-history-container">
<% @user_lotteries.each do |lottery| %>
<% @user_get_pieces = @user_pieces.where(:lottery_id => lottery.id) %>
<div class="puzzle-history-title"><%= lottery.serial_number %></div>
<!-- START of a puzzle row -->
<div class="puzzle-box-row">