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 / ubuntu-apt-get-install-php.sh
Last active October 23, 2021 02:29
ubuntu php sudo apt-get install php7.0 php7.1 php7.2 php7.3 php7.4
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-get install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https
sudo update-ca-certificates
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install \
php7.0 \
php7.0-bcmath \
php7.0-bz2 \
@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.

public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
}
// Ref: https://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java/140861#140861
@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]
@erlangparasu
erlangparasu / NetworkUtilsAcceptSelfSignedSslCert.java
Last active December 6, 2020 10:59
OkHttp Accept Self-signed SSL Certificate
// package ... ;
/**
* Copyright (C) 2014 Square, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0