Skip to content

Instantly share code, notes, and snippets.

View erlangparasu's full-sized avatar

Erlang Parasu erlangparasu

View GitHub Profile
import 'package:flutter/material.dart';
const Color color = Colors.black;
void main() => runApp(
Container(
color: Colors.yellow,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
textDirection: TextDirection.ltr,
@erlangparasu
erlangparasu / tips-improve-php-performance.txt
Last active October 2, 2021 04:53
tips improve php performance
Use opcache
Avoid string concatenations in loops
Avoid function tests in loop conditionals
Avoid using relative paths
Avoid using period for "echo" function
Avoid using double quotes for long strings without variables
Avoid using include_once
Use GZIP compression
Optimize system logs
=== faster than ==
@erlangparasu
erlangparasu / broker.js
Created October 1, 2021 13:39 — forked from jedi4ever/broker.js
xsub , xpub example in nodejs
var pubListener = 'tcp://127.0.0.1:5555';
var subListener = 'tcp://127.0.0.1:5556';
var hwm = 1000;
var verbose = 0;
// The xsub listener is where pubs connect to
var subSock = zmq.socket('xsub');
subSock.identity = 'subscriber' + process.pid;
subSock.bindSync(subListener);
apt update
apt install libzmq-ffi-perl
git clone git://github.com/mkoppanen/php-zmq.git
cd php-zmq
phpize7.4 && ./configure

Install Supervisor with sudo apt-get install supervisor in Unix or brew install supervisor in Mac OSX. Ensure it's started with sudo service supervisor restart in Unix or brew services start supervisor in Mac OSX.

In Unix in /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

In Mac OSX first run supervisord -c /usr/local/etc/supervisord.ini and in /usr/local/etc/supervisor.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread in Unix and with: brew services restart supervisor in MAc OSX . And start using those changes with: sudo supervisorctl update.

@erlangparasu
erlangparasu / setphp
Last active March 5, 2021 15:59
set php version ubuntu
/usr/bin/php
/usr/bin/php-cgi
/usr/bin/php-config
/usr/bin/phpdbg
/usr/bin/phpize
@erlangparasu
erlangparasu / .php_cs.laravel.php
Created January 5, 2021 10:51 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => null]
https://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work/46271#46271
-- Laravel default tables
CREATE TABLE `cache` (
`key` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`expiration` int(11) NOT NULL,
UNIQUE KEY `cache_key_unique` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
CREATE TABLE `migrations` (
<?php
namespace main;
define("BACKEND_SOCKET", '<where the unix socket>');
define("BASE_URL", '<where this file located>');
function exit_500($msg) {
$msg = rtrim($msg, "\n") . "\nDebug trace:\n";
foreach(debug_backtrace() as $trace) {