Skip to content

Instantly share code, notes, and snippets.

View zerolethanh's full-sized avatar

LE VAN THANH zerolethanh

View GitHub Profile
zerolethanh / firebase-hosting-main-push.yml
Created August 24, 2023 02:59
firebase hosting github workflows
View firebase-hosting-main-push.yml
# This file was auto-generated by the Firebase CLI
name: Hosting (main)
- main
zerolethanh / SearchComponent.js
Last active February 10, 2021 13:22
search with fuse.js
View SearchComponent.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 / AvatarEditor.js
Last active February 9, 2021 09:44
Update avatar using react-avatar-edit
View AvatarEditor.js
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 / CFAuthProvider.js
Last active January 23, 2021 05:57
Giữ trạng thái đăng nhập của với firebase.
View CFAuthProvider.js
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);
View button.css
<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="" target="_blank" onclick="ga('send', 'event', 'OutboundLink', 'click', 'PR_201703_wacom3_b2');">購入はこちらから</a></p>
View reduce.js
// Production steps of ECMA-262, Edition 5,
// Reference:
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' );
View forEach.js
// Production steps of ECMA-262, Edition 5,
// Reference:
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');
View dbLog.php
if (!function_exists('dbStartLog')) {
function dbStartLog()
if (!function_exists('dbEndLog')) {
function dbEndLog(Closure $closure = null)
zerolethanh / saveBlob.php
Last active March 11, 2017 06:58
saveBlob to public dir
View saveBlob.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);