Skip to content

Instantly share code, notes, and snippets.

@aynm142
aynm142 / ClassMethod.py
Created February 5, 2017 20:41
Example
class Rectangle:
def __init__(self, side_a, side_b):
self.side_a = side_a
self.side_b = side_b
def __repr__(self):
return "Rectangle(%.1f, %.1f)" % (self.side_a, self.side_b)
class Circle:
@aynm142
aynm142 / models.py
Last active February 20, 2017 20:23
from django.db import models
from django.template.defaultfilters import slugify
from transliterate import translit
class Category(models.Model):
name = models.CharField(max_length=128)
views = models.IntegerField(default=0)
likes = models.IntegerField(default=0)
slug = models.SlugField(unique=True)
@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
<!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 / 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(
<?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 / AvailabilityRQ.json
Created March 5, 2018 15:20
Hotelbeds AvailabilityRQ
{
"stay": {
"checkIn": "2018-03-15",
"checkOut": "2018-03-17"
},
"hotels": {
"hotel": [
"165",
"357",
@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 / 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 / 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();