Skip to content

Instantly share code, notes, and snippets.

View truongluu's full-sized avatar
🏠
Working from home

Lưu Xuân Trường truongluu

🏠
Working from home
View GitHub Profile
@truongluu
truongluu / html5-video-streamer.js
Created July 6, 2016 06:30 — forked from paolorossi/html5-video-streamer.js
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@truongluu
truongluu / woo-endpoint-custom.php
Created July 19, 2017 07:02 — forked from neilgee/woo-endpoint-custom.php
WooCommerce Endpoint Order and Rename - My Account Page v2.6+
<?php
/*
Plugin Name: WooCustom My Account
Plugin URI: http://wpbeaches.com/
Description: WooCustom - add a custom area in my-account
Author: Neil Gee
Version: 1.0.0
Author URI: http://wpbeaches.com
License: GPL-2.0+
@truongluu
truongluu / conditional_effects.ts
Created May 2, 2019 04:08 — forked from vespertilian/conditional_effects.ts
Two options for conditional ngrx effects
@Effect()
selectAndLoadStore$: Observable<Action> = this.actions$
.ofType(storeActions.SELECT_AND_LOAD_STORE)
.withLatestFrom(this.store.select(ngrx.storeState))
.map(([action, storeState]) => [action.payload, storeState])
.switchMap(([storeName, storeState]) => {
const existsInStore = Boolean(storeState.urlNameMap[storeName]);
return Observable.if(
() => existsInStore,
Observable.of(new storeActions.SetSelectedStore(storeName)),
@truongluu
truongluu / same-effect-multiple-actions.ts
Created May 2, 2019 06:07 — forked from praveenpuglia/same-effect-multiple-actions.ts
Same effect for multiple actions - ngrx effects
@Effect({dispatch: false})
entityCreationSuccess$: Observable<Action> = this.actions$.pipe(
ofType(UserActions.CREATE_USER_SUCCESS, PostActions.CREATE_POST_SUCCESS),
tap(action => {
this.router.navigate(['../'], {relativeTo: this.route})
})
);
removeBurger$: Observable<any> = this.actions$
.ofType('[Menu Page] Add burger')
.switchMap((action: menuActions.AddBurger | details.AddBurger) => {
const p = action.payload;
return this.burgerService.addBurger(p.id)
.mergeMap(res => [
new burgers.Load(), // refresh burger list
public function search(Request $request)
{
if($request->has('text') && $request->input('text')) {
// Search for given text and return data
$data = $this->searchMovies($request->input('text'));
$moviesArray = [];
// If there are any movies that match given search text "hits" fill their id's in array
if($data['hits']['total'] > 0) {
@truongluu
truongluu / PlaceHolderFastImage.js
Last active March 30, 2020 03:30
PlaceHolderFastImage.js
import React, { PureComponent } from 'react';
import FastImage from 'react-native-fast-image';
import { PLACEHOLDER_IMAGE } from '../const/app';
export default class PlaceHolderFastImage extends PureComponent {
constructor(props) {
super(props);
this.state = {
loading: true,
hasError: false
@truongluu
truongluu / layouts.ts
Created April 27, 2020 13:49 — forked from xxRockOnxx/layouts.ts
React Native Navigation with react-native-vector-icons
interface Layouts {
[name: string]: LayoutRoot;
}
const layouts: Promise<Layouts> = new Promise(resolve => {
Promise.all([
Icon.getImageSource("people"),
Icon.getImageSource("message")
]).then(icons => {
resolve({
@truongluu
truongluu / multiple_ssh_setting.md
Created June 16, 2020 06:46 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@truongluu
truongluu / multi-level-group-by.js
Created June 17, 2020 03:33 — forked from fatihky/multi-level-group-by.js
multi level group by, lodash, collections
const _ = require('lodash')
function genrows(groups, groupKey) {
return _.toPairs(groups)
.map(([key, data]) => ({[groupKey]: key, data}))
}
function gengroups(arr, iteratee, key) {
const grouped = _.groupBy(arr, iteratee)
return genrows(grouped, key)