Skip to content

Instantly share code, notes, and snippets.

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

Payam Naderi E1101

🏠
Working from home
View GitHub Profile
<?php
final class OrderLevelShippingCalculatorTest extends TestCase
{
public function testItEnsuresOrderIncludeShippingFeeCollection()
{
$order = SalesOrderBuilder::initialOrder();
$invoice = InvoiceBuilder::initialInvoice();
$calculator = $this->createCalculator(
CREATE TABLE order_info(
order_id INT NOT NULL,
product_id INT NOT NULL,
option_attribute VARCHAR(20),
option_value VARCHAR(20),
PRIMARY KEY(order_id,product_id,option_attribute,option_value)
);
INSERT INTO order_info VALUES
(1,10,'Colour','Red'),(1,10,'Size','Large'),(1,10,'Sleeve','Short'),
(2,10,'Colour','Blue'),(2,10,'Size','Small'),(2,10,'Sleeve','Long');
<?php
/**
* Reverse Words In Array Of Charachters
*
* @param array $input
*
* @return array
*/
function reverseWords(array $input) : array
{
@E1101
E1101 / usage.sh
Created November 18, 2018 10:38
Linux Resources Usage
####################################################################################################
# Usage.sh #
# Written by Ali Hallaji #
# If any bug, report me in my Github page at below #
# Free to use/edit/distribute the code below by #
# giving proper credit to Author #
# Link: https://github.com/ali-hallaji/system-usage-bash #
####################################################################################################
#! /bin/bash
# unset any variable which system may be using
@E1101
E1101 / resume.php
Created February 28, 2018 05:13
Resume Upload
<?php
$CHUNK = 8192;
try {
if (!($putData = fopen("php://input", "r")))
throw new Exception("Can't get PUT data.");
// now the params can be used like any other variable
// see below after input has finished
@E1101
E1101 / nth_prime.php
Created December 17, 2017 08:55
Get A Number In Prime Series By Index; The nTH Prime.
<?php
function getPrimingSeriesIndex($index)
{
if ( $index <= 0 )
return false;
if ($index == 1)
return 2;
<?php
public function postFile()
{
$file_url = "test.txt"; //here is the file route, in this case is on same directory but you can set URL too like "http://examplewebsite.com/test.txt"
$eol = "\r\n"; //default line-break for mime type
$BOUNDARY = md5(time()); //random boundaryid, is a separator for each param on my post curl function
$BODY=""; //init my curl body
$BODY.= '--'.$BOUNDARY. $eol; //start param header
$BODY .= 'Content-Disposition: form-data; name="sometext"' . $eol . $eol; // last Content with 2 $eol, in this case is only 1 content.
$BODY .= "Some Data" . $eol;//param data in this case is a simple post data and 1 $eol for the end of the data
@E1101
E1101 / parse_token.php
Created October 4, 2017 14:02
Parse Token From Request
<?php
/**
* As per the Bearer spec (draft 8, section 2) - there are three ways for a client
* to specify the bearer token, in order of preference: Authorization Header,
* POST and GET.
*
* @param ServerRequestInterface $request
*
* @return null|string Token
*/
@E1101
E1101 / curl_client.php
Created July 26, 2017 11:05
Curl Http Client
<?php
class Client
{
public function get($url, array $options = [])
{
$options = array_merge([ 'method' => 'get', 'url' => $url ], $options);
return $this->request($options);
}
public function post($url, array $data = [], array $options = [])
@E1101
E1101 / spam_list.txt
Created July 26, 2017 10:29
List Of SPAM Mail Server providers
0815.ru
0815.ru0clickemail.com
0815.ry
0815.su
0845.ru
0clickemail.com
0-mail.com
0wnd.net
0wnd.org
10mail.com