Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Get host ip4 of interface eth0/en0/eth1.
# For linux, eth0 inet.
ifconfig eth0 >/dev/null 2>/dev/null && ip -4 addr show scope global dev eth0| grep inet| awk '{print $2}' && exit 0
# For linux, eth1 inet.
ifconfig eth1 >/dev/null 2>/dev/null && ip -4 addr show scope global dev eth1| grep inet| awk '{print $2}' && exit 0
@manniru
manniru / README.md
Created April 26, 2020 08:50 — forked from maqnouch/README.md
Signal Installation Steps

Signal Server Installation Guide

Author: Aqnouch Mohammed aqnouch.mohammed@gmail.com

Abstract

This paper is a quickstart for anyone aims to setup a working Signal Server.

What Is Signal

Signal is an encrypted instant messaging and voice calling application for Android. It uses the Internet to send one-to-one and group messages, which can include images and video messages, and make one-to-one voice calls. Signal uses standard phone numbers as identifiers and end-to-end encryption to secure all communications to other Signal users.

$count_query = clone $query;
$arr = $count_query->execute()->fetchAllAssoc('id', \PDO::FETCH_ASSOC);
$sum_array = array_sum(array_column($arr, 'amount'));
print('<pre>' . print_r($sum_array, TRUE) . '</pre>'); exit();
<?php
namespace Drupal\system\Controller;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\system\SystemManager;
/**
sudo nano ~/.zshrc
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
export PATH
source ~/.zshrc
https://stackoverflow.com/questions/18305909/get-previous-array-key-in-associative-array
$keys = array_keys($entries[0]);
echo "<table><tr><th>".implode("</th><th>", $keys)."</th></tr>";
foreach ($entries as $order) {
if (!is_array($order))
continue;
echo "<tr><td>".implode("</td><td>", $order )."</td></tr>";
}
echo "</table>";
exit();
@manniru
manniru / php_long_string_to_assocaite_array.php
Last active May 1, 2024 12:26
Explode a string to associative array without using loops
$content = $request->getContent();
$chunks = array_chunk(preg_split('/(&|=)/', $content), 2);
$result = array_combine(array_column($chunks, 0), array_column($chunks, 1));
print('<pre>' . print_r($result, TRUE) . '</pre>'); exit();
@manniru
manniru / drupal9_union_all.php
Created June 10, 2020 18:22
DRUPAL 9 UNION ALL
<?php
$query_1 = $this->database->select('_remita', 'rm')
->fields('rm', [
'id','uid','datetime','head','subhead','merchantId','address','details','status',
]);
$query_1->addField('rm', 'serviceTypeId', 'serviceId');
$query_1->addField('rm', 'rrr', 'refno');
$query_1->addField('rm', 'payerName', 'name');
$query_1->addField('rm', 'payerPhone', 'phone');
@manniru
manniru / _payments.sql
Last active May 1, 2024 12:25
MYSQL CREATE VIEWS WITH 3 TABLES
CREATE VIEW _payments AS
SELECT id, user_id as uid, 'Remita' as channel, datetime, head, subhead, merchantId, serviceTypeId as serviceId,rrr as refno, payerName as `name`, payerPhone as phone, payerEmail as email, address, details, totalAmount as amount, `status`
,(select head_name from _sub_heads sh where sh.head_code = rm.head limit 1) as head_name
,(select subhead_name from _sub_heads sh where sh.subhead_code = rm.subhead limit 1) as subhead_name
FROM _remita rm
UNION ALL
SELECT id, uid, 'Interswitch' as channel, datetime, head, subhead, merchantId, ItemCode, ReferenceNumber, FirstName, phone, Email, address, details, Amount, `status`
,(select head_name from _sub_heads sh where sh.head_code = isw.head limit 1) as head_name
,(select subhead_name from _sub_heads sh where sh.subhead_code = isw.subhead limit 1) as subhead_name