Skip to content

Instantly share code, notes, and snippets.

View phucnguyenvn's full-sized avatar

Phuc Nguyen phucnguyenvn

  • HCMC Viet Nam
View GitHub Profile
@phucnguyenvn
phucnguyenvn / pool.py
Created January 14, 2020 07:32
Python multiprocessing with pool
# Read CSV file and convert to parquet, upload to S3
def csv_manipulation(self, merchant: str, directory: str):
temp = []
schema = pyarrow.schema(self.get_schema())
p = Pool(processes=self.limit_process)
for f in os.listdir(directory):
filepath = os.path.join(directory, f)
try:
with open(filepath, 'r', encoding='ISO-8859-1') as csvfile:
@phucnguyenvn
phucnguyenvn / cheatsheet-elasticsearch.md
Created October 30, 2019 06:35 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@phucnguyenvn
phucnguyenvn / GeneralModal.vue
Created August 21, 2019 07:28 — forked from blackfyre/GeneralModal.vue
Modals in Laravel Nova Tools
<template>
<modal @modal-close="handleClose">
<form
@submit.prevent="handleConfirm"
slot-scope="props"
class="bg-white rounded-lg shadow-lg overflow-hidden"
style="width: 460px"
>
<slot :uppercaseMode="uppercaseMode" :mode="mode">
<div class="p-8">
@phucnguyenvn
phucnguyenvn / saveImgBase64.php
Created July 18, 2019 09:31
Laravel Upload Base64 Image
protected function saveImgBase64($param, $folder)
{
list($extension, $content) = explode(';', $param);
$tmpExtension = explode('/', $extension);
preg_match('/.([0-9]+) /', microtime(), $m);
$fileName = sprintf('img%s%s.%s', date('YmdHis'), $m[1], $tmpExtension[1]);
$content = explode(',', $content)[1];
$storage = Storage::disk('public');
$checkDirectory = $storage->exists($folder);
<?php
use GuzzleHttp\Client;
class GetWeChatOpenId
{
protected function getWechatOpenId($token)
{
try {
$wechatOauthUrl = env('WECHAT_URL');
@phucnguyenvn
phucnguyenvn / read-text-file.php
Last active December 13, 2018 04:16
PHP read file
$head = fopen("file.txt", "r");
if ($head) {
while (($line = fgets($head)) !== false) {
// process the line read.
}
fclose($head);
} else {
// error opening the file.
}
@phucnguyenvn
phucnguyenvn / Javascript get url parameters
Last active June 15, 2018 06:15
Javascript get url parameters
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@phucnguyenvn
phucnguyenvn / Yii2 basic deployment htaccess
Last active June 15, 2018 06:15
Yii2 basic deployment htaccess
## Manual setting
### 1. step
#### create file {root}/.htaccess:
```
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
@phucnguyenvn
phucnguyenvn / tmux-cheatsheet.markdown
Created April 2, 2018 07:32 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname