Skip to content

Instantly share code, notes, and snippets.

View andreconghau's full-sized avatar

andre andreconghau

  • Software Engineer
  • việt nam
View GitHub Profile
var p = window.location.protocol + '//'
// current location must return 200 OK for this GET
window.location = window.location.href.replace(p, p + 'logout:password@')
@andreconghau
andreconghau / composer-dev.json
Created June 6, 2017 07:54
Fix composer update fail
"config": {
"preferred-install": "dist",
"disable-tls": true,
"secure-http": false,
"autoloader-suffix": "Drupal8"
},
"repositories": [
{
"packagist": false
},
@andreconghau
andreconghau / random_array_by_probality.php
Created June 27, 2017 12:20
Random một array và lấy ra item với xác xuất cố định.
<?php
function weightedRand($stream) {
$pos = mt_rand(1,array_sum(array_keys($stream)));
$em = 0;
foreach ($stream as $k => $v) {
$em += $k;
if ($em >= $pos)
return $v;
}
@andreconghau
andreconghau / CaculateTaxBySalary.php
Created June 27, 2017 23:25
Return Tax base on Salary
<?php
class TaxSalary
{
// Input 1000000.
function salary($gross_local)
{
if (!is_numeric($gross_local) && floatval($gross_local)) {
die ('Please input is must type Numeric.');
}
@andreconghau
andreconghau / Configuration.php
Created August 30, 2017 08:37
Class config with Singleton parttern
<?php
class Configuration {
private static $instance;
private function __construct($configuration) {/* */}
public static function getInstance() {
if (self::$instance === null) {
self::$instance = new Configuration();
}
return self::$instance;
}
@andreconghau
andreconghau / reactjs-day1.html
Last active December 23, 2018 08:38
ReactJs day 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
<link type="text/css" rel="stylesheet"
href="https://gist.githubusercontent.com/auser/2bc34b9abf07f34f602dccd6ca855df1/raw/40c5e7c8cad4c6920fed940fc31cbb63abd94c29/timeline.css">
@andreconghau
andreconghau / react-child-component.js
Created December 28, 2018 07:47
Ex about Child Component
class Header extends React.Component {
render() {
return (
<div className="header">
<div className="fa fa-more"></div>
<span className="title">Timeline</span>
<input
type="text"
className="searchInput"
placeholder="Search ..."/>
@andreconghau
andreconghau / reactjs-props-demo-activities.js
Created December 28, 2018 09:24
Build activities with comment user
class Header extends React.Component {
render() {
return (
<div className="header">
<div className="fa fa-more"></div>
<span className="title">{this.props.title}</span>
<input
type="text"
className="searchInput"
placeholder="Search ..."/>
@andreconghau
andreconghau / reactjs-lock.js
Created December 30, 2018 07:41
State to set timer
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = this.getTime();
}
componentDidMount() {
this.setTimer();
}
@andreconghau
andreconghau / customer_account_login.xml
Created March 5, 2019 06:13
Magento 2 login register one page
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.main.title">