Skip to content

Instantly share code, notes, and snippets.

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

espressoByte tajulasri

🏠
Working from home
View GitHub Profile
@tajulasri
tajulasri / sample.py
Created July 17, 2017 16:24
replace content to all files by supply from input source text
#!/usr/local/bin/python
import os
import sys
import errno
from datetime import datetime
from time import time
rootdir = os.getcwd()
@tajulasri
tajulasri / sample.json
Last active July 21, 2017 15:56
sample data
[
{"hash": "37db6a0332040106ebce1a1854ecf5cd", "range_control": 1, "state": 1, "time": "00:00", "type": "light", "day": 1},{"hash": "e21d57a8ca98f301a63b0423f5cc7338", "range_control": 1, "state": 0, "time": "00:00", "type": "fans", "day": 1},{"hash": "63abc299cccd5ec9900a0457bb859152", "range_control": 30, "state": 1, "time": "00:00", "type": "aircond", "day": 1},{"hash": "493a4b2b18488ce51e24222fb22e4398", "range_control": 0, "state": 1, "time": "00:00", "type": "plug", "day": 1},{"hash": "37db6a0332040106ebce1a1854ecf5cd", "range_control": 3, "state": 1, "time": "00:39", "type": "light", "day": 1},{"hash": "e21d57a8ca98f301a63b0423f5cc7338", "range_control": 3, "state": 0, "time": "00:39", "type": "fans", "day": 1},{"hash": "63abc299cccd5ec9900a0457bb859152", "range_control": 25, "state": 0, "time": "00:39", "type": "aircond", "day": 1},{"hash": "493a4b2b18488ce51e24222fb22e4398", "range_control": 0, "state": 0, "time": "00:39", "type": "plug", "day": 1},{"hash": "37db6a0332040106ebce1a1854ecf5cd", "rang
@tajulasri
tajulasri / MakeTransformerCommand.php
Last active August 19, 2017 07:35
Make transformer command laravel
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Class User extends Model {
public function applications()
{
return $this->belongsToMany(Application::class,'user_applications')->withPivot('application_status_id');
}
}
@tajulasri
tajulasri / Model.php
Created September 22, 2017 16:21
Sample of meta programming
<?php
/**
* example of meta programming using php
*/
class Argument {
public $attributes = [];
public function __construct($attributes = [])
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
<?php
interface HasherContract
{
public function encrypt($string);
}
class Aes implements HasherContract{
public function encrypt($string)
@tajulasri
tajulasri / fab.py
Last active June 5, 2020 02:34
Fabric python for laravel php deplopment setup
from fabric.api import *
'''
fabric python laravel vps setup
pip install fabric
1. Save as fabfile.py
2. fab deploy
@tajulasri
tajulasri / sample.php
Last active March 3, 2018 06:17
workers min max pages problem 1
<?php
/*
This is to solve pagination dividing for each workers for asyncronous feature in API request to third party endpoint with
large response data.
*/
function get_min_max_page($totalPages = 0,$workers = 1) {
$maximumPage = $totalPages / $workers;
@tajulasri
tajulasri / my.cnf
Created March 12, 2018 16:24 — forked from sr75/my.cnf
Optimized my.cnf for mysql server when setting up physical servers or vps. Configured for 2GB of memory allocated to the mysql process. Adjust connections and max memory for larger setups with more available memory.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the