Skip to content

Instantly share code, notes, and snippets.

View moetanahy's full-sized avatar

Mahamad El Tanahy moetanahy

View GitHub Profile
@sebastiaanluca
sebastiaanluca / Controller.php
Last active March 7, 2023 23:51
A HasMany relation sync method implementation using macros
<?php
$business->locations()->sync([1, 42, 16, 8]);
@ANSCoder
ANSCoder / Propertywrapper.swift
Last active May 6, 2020 20:56
Propertywrapper for UserDefaults in Swift
private protocol AnyOptional{
var isNil: Bool { get }
}
extension Optional: AnyOptional{
var isNil: Bool { self == nil }
}
@propertyWrapper
@jotaelesalinas
jotaelesalinas / Laravel-MakeConfig.php
Last active July 11, 2025 13:01
Laravel make:config artisan command
<?php
/*
* Run this artisan command before:
* php artisan make:command MakeConfig
*/
namespace App\Console\Commands;
use Illuminate\Console\Command;
@ulcuber
ulcuber / .phpcs.xml
Created October 27, 2019 10:27
PSR12 laravel phpcs config
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
<description>The Laravel Coding Standards</description>
<file>app</file>
<file>config</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>
@joaoescribano
joaoescribano / binance.py
Created July 25, 2019 16:44
Binance login + wallet check + captcha solver
#!/usr/bin/env python3
# Usage:
# ./binance.py <email> <senha> <otp> <wallet to test json>
from solver import PuzleSolver
import calendar
import json
import os
import pyotp
@voku
voku / code_check_git_hook.php
Created December 10, 2018 23:05
A pre-commit-hook example with Code Sniffer + Code Fixer + PHPStan
#!/usr/bin/php
<?php
/**
* //
* // add something like this in your "composer post-update-cmd && post-install-cmd"
* //
* echo "\n\n";
* echo "Run force \"code_check_git_hook.php\" as pre-commit-hook ...";
* $force_pre_commit_hook_cmd = 'ln -sf YOUR_PATH_TO_CODE_CHECK_SCRIPTS/code_check_git_hook.php YOUR_PATH_TO_PROJECT_ROOT/.git/hooks/pre-commit';
@whoisryosuke
whoisryosuke / ApiController.php
Created July 28, 2018 00:55
Laravel - API - Base Controller with standard API methods (index/store/etc) and authorization middleware ++ Extended controller and the necessary properties
<?php
namespace KushyApi\Http\Controllers;
use Illuminate\Http\Request;
use Spatie\QueryBuilder\QueryBuilder;
use KushyApi\Http\Controllers\Controller;
abstract class ApiController extends Controller
{
@cgarnier
cgarnier / MailhogTestHelper.php
Last active November 29, 2024 16:02 — forked from v-jacob/MailTestHelper.php
Mailhog PHPUnit Test Helper
<?php
use GuzzleHttp\Client;
trait MailTestHelper
{
/**
* @var \GuzzleHttp\Client
*/
protected $mailService;
@lattner
lattner / async_swift_proposal.md
Last active October 30, 2025 15:46 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@kunikullaya
kunikullaya / Date+Extension.swift
Created January 18, 2017 05:21
Date Extension for Swift
import Foundation
extension Date {
func toString(format: String = "yyyy-MM-dd") -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.dateFormat = format
return formatter.string(from: self)
}