Skip to content

Instantly share code, notes, and snippets.

View sonha's full-sized avatar

Simon sonha

  • Ha Noi
View GitHub Profile
@sonha
sonha / solve.php
Created May 11, 2018 17:49
solve.php
<?php
function solve1($file = "data.txt", $player = 1) {
$data = getData($file);
$data_end = end($data);
// var_dump($data_end);
// foreach ($data as $info) {
// if($info[0] == '1' && $info[1] == 'A') {
// $competitor_attack_history[] = $info;
// }
@sonha
sonha / Late_Static_Binding_2.php
Created February 20, 2017 08:43
Late_Static_Binding_2
<?php
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // Here comes Late Static Bindings
}
}
@sonha
sonha / Late_Static_Binding.php
Created February 20, 2017 08:41
Late_Static_Binding
<?php
class A
{
public static function who()
{
echo __CLASS__;
}
public static function test()
@sonha
sonha / react_prop.js
Created January 3, 2017 10:18
React Training : Prop 23
import React from 'react';
import ReactDOM from 'react-dom';
var List = React.createClass({
render: function () {
var titleText = 'Favorite ' + this.props.type;
if (this.props.children instanceof Array) {
titleText += 's';
}
return (
@sonha
sonha / react_prop_alert.js
Created January 3, 2017 09:48
React Training : Prop Again
import React from 'react';
import ReactDOM from 'react-dom';
var Button = React.createClass({
render: function () {
return (
<button onClick={this.props.talk}>
Click me!
</button>
);
@sonha
sonha / react_prop_2.js
Created January 3, 2017 09:33
React Training : Prop
import React from 'react';
import ReactDOM from 'react-dom';
var Greeting = React.createClass({
render: function () {
if (this.props.signedIn == false) {
return <h1>GO AWAY</h1>;
} else {
return <h1>Hi there, {this.props.name}!</h1>;
@sonha
sonha / react_prop.js
Created January 3, 2017 09:22
React Training : Prop
import React from 'react';
import ReactDOM from 'react-dom';
var Welcome = React.createClass({
render: function () {
if (this.props.name == 'Wolfgang Amadeus Mozart') {
return (
<h2>
hello sir it is truly great to meet you here on the web
</h2>
@sonha
sonha / react_prop.js
Created January 3, 2017 07:47
React Training : Prop
import React from 'react';
import ReactDOM from 'react-dom';
var PropsDisplayer = React.createClass({
render: function () {
var stringProps = JSON.stringify(this.props);
return (
<div>
<h1>CHECK OUT MY PROPS OBJECT</h1>
@sonha
sonha / react_this.js
Created January 3, 2017 02:43
React Training : This element
import React from 'react';
import ReactDOM from 'react-dom';
var MyName = React.createClass({
// name property goes here:
name: 'Simon Ha - Ha Anh Son',
render: function () {
return <h1>My name is {this.name}</h1>;
}
@sonha
sonha / react_component_render_function.js
Created December 29, 2016 10:04
React Training : render function
import React from 'react';
import ReactDOM from 'react-dom';
var friends = [
{
title: "Yummmmmmm",
src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-monkeyweirdo.jpg"
},
{
title: "Hey Guys! Wait Up!",