Skip to content

Instantly share code, notes, and snippets.

@mix5003
mix5003 / convert.php
Created December 6, 2020 09:47
Script for convert images to WebP
<?php
function convertDir($path){
// echo "Search In $path\n";
$items = scandir($path);
foreach($items as $item){
if($item === '.' || $item === '..'){
continue;
}
@mix5003
mix5003 / Extension.cpp
Last active April 3, 2021 16:21
this is Artikash/Textractor extension for receive text in threads to clipboard
#include "Extension.h"
#include <functional>
#include <thread>
#include <mutex>
#include <unordered_set>
#include <QMainWindow>
#include <QLayout>
#include <QPushButton>
@mix5003
mix5003 / nginx-angular.conf
Created June 12, 2019 04:26
(net tested) another way to force user to reload new module
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
keepalive_timeout 620s;
location / {
try_files $uri /index.html;
@mix5003
mix5003 / nginx-angular.conf
Created May 12, 2019 11:18
Nginx Config for Angular
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
keepalive_timeout 620s;
location / {
try_files $uri /index.html;
@mix5003
mix5003 / fread_memory.php
Created November 10, 2017 04:34
fread make a var use memory equals to buffer length. even if it has only few bytes
<?php
ini_set('memory_limit', '256M');
// create file
@mkdir('tmp_file');
for($i=0;$i<300;$i++){
file_put_contents("tmp_file/{$i}.txt", $i);
}
@mix5003
mix5003 / README.md
Last active March 14, 2017 02:36
May be add virtual field to access state name in woocommerce
  1. add new code to functions.php
  2. use billing_state_readable instead of billing_state
@mix5003
mix5003 / LineExtendSocialite.php
Last active July 31, 2021 03:44
Line service provider for laravel socialite.
<?php
namespace SocialiteProviders\Line;
use SocialiteProviders\Manager\SocialiteWasCalled;
class LineExtendSocialite
{
/**
* Register the provider.
@mix5003
mix5003 / AlbumNav.jsx
Created December 11, 2016 13:37
Why activeClassName not actived
{this.props.albums.map(album => (
<li key={`album-nav-${album.id}`}>
<Link
to={`/albums/${album.id}`}
activeClassName="active"
>
{album.name} (<TotalPhotoInAlbum albumId={album.id} loadingText="?" />)
</Link>
</li>
))}
@mix5003
mix5003 / data.php
Created May 7, 2016 06:24
array_search vs foreach_loop sample
<?php
$max = 10000;
//Source : https://en.wikipedia.org/wiki/Association_of_Southeast_Asian_Nations#ASEAN_six_majors
$datas = ['Indonesia','Thailand','Malaysia','Philippines','Singapore','Vietnam'];
//Source : https://gist.github.com/DHS/1340150
//$datas = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivo
@mix5003
mix5003 / Create.php
Created April 3, 2016 09:50
Example Logic
<?php
//Just a dummy
$customer = CustomerRepo::first();
$products = ProductRepo::limit(3)->get(); //return array of products
$order = new Order();
$order->setCustomer($customer);
$order->setProducts($products);
$dm->persist($order);