Skip to content

Instantly share code, notes, and snippets.

View hazeim254's full-sized avatar

Hazem Mohamed hazeim254

View GitHub Profile
@hazeim254
hazeim254 / kubeadm.sh
Created May 24, 2025 06:10
Install kubeadm on ubuntu
#!/bin/sh
sudo modprobe br_netfilter
sudo sysctl -w net.ipv4.ip_forward=1
#!/bin/bash
# I choose CRI-O because it is easier to install and needs less installation
# Also, versioning seems to match kubernetes version so less confusion about versions
export CRIO_VERSION='v1.33'
@hazeim254
hazeim254 / anonymous_validation.php
Last active September 15, 2021 18:01
You can use anonymous classes to create a new validation rule
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Rule as RuleContract;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ContractTermRequest extends FormRequest
{
@hazeim254
hazeim254 / RussianCaching.php
Created February 11, 2016 07:03
Russian Caching inspired by Jeffry Way's class with an addition for local environmen
<?php
namespace App;
use Cache;
class RussianCaching
{
/**
* A list of model cache keys.
*
* @param array $keys
*/
@hazeim254
hazeim254 / date-range.js
Last active January 3, 2016 04:52
A simple way to calculate date ranges start and end suitable for date fields
var DateRange = {
today: function(){
var currentDay = new Date();
var date = currentDay.getFullYear() + '-' + this.addZero(parseInt(currentDay.getMonth() + 1)) + '-' + this.addZero(currentDay.getDate());
return {from: date, to: date};
},
yesterday: function() {
var dayBefore = new Date();
dayBefore.setDate(dayBefore.getDate() - 1);
var date = dayBefore.getFullYear() + '-' + this.addZero(parseInt(dayBefore.getMonth() + 1)) + '-' + this.addZero(dayBefore.getDate());
@hazeim254
hazeim254 / pagination.blade.php
Last active December 31, 2015 13:32
Standard Laravel 5.x pagination partial
{{--$paginator Must be an instance of \Illuminate\Contracts\Pagination\LengthAwarePaginator--}}
@if ($paginator->lastPage() > 1)
<?php
$mod = 8;
/** @var \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator */
$page = $paginator->currentPage();
if ($paginator->lastPage() < $mod) {
$start = 1;
@hazeim254
hazeim254 / excel-column-convert.php
Created August 3, 2015 11:33
Simple functions to convert between column number and column names in Excel
<?php
/**
* Converts the column number to proper Excel column format
*
* @param $number column number to be converted
*
* @return Returns Excel column name
*/
function excelConvertToCell($number)
{