Skip to content

Instantly share code, notes, and snippets.

@aynm142
aynm142 / database.py
Created August 23, 2018 13:01
database.py
import psycopg2 as pg
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
class Database:
def __init__(self, host='127.0.0.1', port='5432', username='postgres', password='', database=''):
self.host = host
self.port = port
self.username = username
self.password = password
@aynm142
aynm142 / facepalm.php
Created July 25, 2018 12:49
facepalm.php
public static function pnrAddMultiElements11(Request $request)
{
$params = new SimpleXMLElement('<PNR_AddMultiElements></PNR_AddMultiElements>');
$params->addChild('pnrActions');
$params->pnrActions->addChild('optionCode');
$params->pnrActions->optionCode = '0';
foreach ($request->get('travellers') as $traveller) {
$params->addChild('travellerInfo');
@aynm142
aynm142 / user.php
Created May 18, 2018 11:49
user.php
public function activateCode(Request $request)
{
$code = $request->get('promo_code');
if ($this->user->activation_code || $this->user->promo_code_first == $code || $this->user->promo_code_second == $code) {
return response()->json([], 405);
}
$referral = User::wherePromoCodeFirst($code)->first();
$referral_second = User::wherePromoCodeSecond($code)->first();
@aynm142
aynm142 / task.php
Last active May 16, 2018 12:05
task.php
public function newTasks(Request $request)
{
// callback for return all tasks
$returnResponse = function($tasks) {
$response = [];
foreach ($tasks as $task) {
$response[] = [
'id' => $task->id,
'package_name' => $task->package_name,
'title' => $task->title,
@aynm142
aynm142 / api.php
Last active April 27, 2018 10:33
CreateUser
public function createUser(Request $request): JsonResponse
{
$response = function ($user) {
return response()->json([
'token' => $user->token,
'promo' => $user->promo,
], 200);
};
$user = User::whereEmail($request->get('email'))->first();
@aynm142
aynm142 / AvailabilityRQ.json
Created March 5, 2018 15:20
Hotelbeds AvailabilityRQ
{
"stay": {
"checkIn": "2018-03-15",
"checkOut": "2018-03-17"
},
"hotels": {
"hotel": [
"165",
"357",
<?php
namespace App\Services\Hotelbeds\Hotel\Search;
use Amadeus\Client;
use Amadeus\Client\Params;
use Amadeus\Client\RequestOptions\Fare\MPDate;
use Amadeus\Client\RequestOptions\Fare\MPItinerary;
use Amadeus\Client\RequestOptions\Fare\MPLocation;
use Amadeus\Client\RequestOptions\Fare\MPPassenger;
@aynm142
aynm142 / api reg
Created October 20, 2017 17:34
api.php
/**
* @SWG\Post(
* path="/login/api",
* summary="Store new or update existing device",
* tags={"Login"},
* description="Store new or update existing device. <strong>Authorization header required</strong>",
* operationId="postDevice",
* consumes={"application/json", "application/x-www-form-urlencoded"},
* produces={"application/json"},
* @SWG\Parameter(
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
@aynm142
aynm142 / dsfdsfds
Created April 11, 2017 16:51
dsfsdfdsfds
var ATM = {
is_auth: false,
current_user:false,
current_type:false,
// all cash of ATM
cash: 2000,
// all available users
users: [
{number: "0000", pin: "000", debet: 0, type: "admin"}, // EXTENDED