Skip to content

Instantly share code, notes, and snippets.

View zerolethanh's full-sized avatar
😀

LE VAN THANH zerolethanh

😀
View GitHub Profile
@zerolethanh
zerolethanh / firebase-hosting-main-push.yml
Created August 24, 2023 02:59
firebase hosting github workflows
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Hosting (main)
'on':
push:
branches:
- main
jobs:
build_and_deploy:
@zerolethanh
zerolethanh / SearchComponent.js
Last active February 10, 2021 13:22
search with fuse.js
import {Avatar, Input, Popover} from 'antd';
import React, {useState} from 'react';
import Fuse from 'fuse.js';
import {useGlobal} from 'reactn';
const {Search} = Input;
export default function SearchComponent() {
const [gPosts] = useGlobal('gPosts');
@zerolethanh
zerolethanh / AvatarEditor.js
Last active February 9, 2021 09:44
Update avatar using react-avatar-edit
import React, {useState} from 'react';
import dynamic from 'next/dynamic';
import {message, Modal} from 'antd';
import {auth, db, storage} from '../../../firebase/clientApp';
import isEmpty from 'lodash/isEmpty';
const Avatar = dynamic(() => import('react-avatar-edit'), {ssr: false});
function AvatarEditor({show, setShow, user}) {
const [data, setData] = useState(null);
@zerolethanh
zerolethanh / CFAuthProvider.js
Last active January 23, 2021 05:57
Giữ trạng thái đăng nhập của với firebase.
import React, {createContext, useEffect, useState} from 'react';
import {useGlobal} from 'reactn';
import {useAuthState} from 'react-firebase-hooks/auth';
import {useDocument} from 'react-firebase-hooks/firestore';
const CFAuthContext = createContext({});
const useUser = ({auth, firestore}) => {
const [gUser, setGUser] = useGlobal('user');
const [user, loading, error] = useAuthState(auth);
<p><a style="display: block; text-align: center; margin: auto; width: 120px; padding: 5px 10px; background: #ff7733; border-bottom: 5px solid #dd5500; color: #fff; font-weight: bolder; font-size: 0.8rem; border-radius: 10px; text-decoration: none;" href="http://amzn.asia/31AdXyo" target="_blank" onclick="ga('send', 'event', 'OutboundLink', 'click', 'PR_201703_wacom3_b2');">購入はこちらから</a></p>
// Production steps of ECMA-262, Edition 5, 15.4.4.21
// Reference: http://es5.github.io/#x15.4.4.21
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce
if (!Array.prototype.reduce) {
Object.defineProperty(Array.prototype, 'reduce', {
value: function(callback /*, initialValue*/) {
if (this === null) {
throw new TypeError( 'Array.prototype.reduce ' +
'called on null or undefined' );
}
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback/*, thisArg*/) {
var T, k;
if (this == null) {
throw new TypeError('this is null or not defined');
<?php
if (!function_exists('dbStartLog')) {
function dbStartLog()
{
app('db')->enableQueryLog();
}
}
if (!function_exists('dbEndLog')) {
function dbEndLog(Closure $closure = null)
{
@zerolethanh
zerolethanh / saveBlob.php
Last active March 11, 2017 06:58
saveBlob to public dir
<?php
if (!function_exists('saveBlob')) {
function saveBlob($blobdata = 'blobdata', $dir = 'blobdata')
{
//$blobdata head : data:image/jpeg;base64,
$blobdata = request($blobdata);
list($type, $blobdata) = explode(';', $blobdata);
list(, $blobdata) = explode(',', $blobdata);
$blobdata = base64_decode($blobdata);