This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# This files shows some possible implementations of the Singleton pattern | |
# in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice | |
# in some cases. In this file I'm going to implement a simple logger. | |
# | |
## | |
# The first implementation that can come to our minds is to create a class | |
# that holds an instance as a class variable that can be accessed through |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
def initialize(attributes) | |
attributes.each do |attribute_name, attribute_value| | |
##### Method one ##### | |
# Works just great, but uses something scary like eval | |
# self.class.class_eval {attr_accessor attribute_name} | |
# self.instance_variable_set("@#{attribute_name}", attribute_value) | |
##### Method two ##### | |
# Manually creates methods for both getter and setter and then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
background: linear-gradient(270deg, #5e6de3, #00d29c, #ee5253, #f368e0, #ff9f43); | |
background-size: 1000% 1000%; | |
-webkit-animation: zar-gama-loading-bar 30s ease infinite; | |
-moz-animation: zar-gama-loading-bar 30s ease infinite; | |
-o-animation: zar-gama-loading-bar 30s ease infinite; | |
animation: zar-gama-loading-bar 30s ease infinite; | |
@-webkit-keyframes zar-gama-loading-bar { | |
0%{background-position:0% 50%} | |
50%{background-position:100% 50%} | |
100%{background-position:0% 50%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Dimensions, View, Text } from 'react-native'; | |
const screenWidth = Dimensions.get('screen').width; | |
const screenHeight = Dimensions.get('screen').height; | |
export default class Dimensions extends Component { | |
render() { | |
return ( | |
<View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, Text } from 'react-native'; | |
import MyAwesomeButton from './common/MyAwesomeButton'; | |
export default class ClickSome extends Component { | |
render() { | |
return ( | |
<View> | |
<MyAwesomeButton | |
buttonText="Click me!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, Text } from 'react-native'; | |
class User extends Component { | |
render() { | |
return ( | |
<View> | |
<Text>Username: {this.props.name}</Text> | |
<Text>Phone number: {this.props.phone}</Text> | |
<Image source={this.props.avatar} style={{ width: 200, height: 150 }} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View } from 'react-native'; | |
import Home from './Home'; | |
import Login from './Login'; | |
class App extends Component { | |
state = { | |
isLoggedIn: false | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, Text } from 'react-native'; | |
class Login extends Component { | |
render() { | |
const { containerStyle } = styles; | |
return ( | |
<View style={containerStyle}> | |
<Text>Hello from Login</Text> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { View, Text } from 'react-native'; | |
class Home extends Component { | |
render() { | |
const { containerStyle } = styles; | |
return ( | |
<View style={containerStyle}> | |
<Text>Hello from Home!</Text> |
NewerOlder