Skip to content

Instantly share code, notes, and snippets.

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

Mohd Hafiz xmhafiz

🏠
Working from home
View GitHub Profile
@EnesKaraosman
EnesKaraosman / RandomColor.swift
Last active May 9, 2024 22:41
Generatin random color in SwiftUI & UIKit
#if canImport(UIKit)
import UIKit
extension UIColor {
static var random: UIColor {
return UIColor(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
@afiqiqmal
afiqiqmal / SoapRequest.php
Last active August 8, 2019 12:08
Soap Request Using PHP which focus on SOAP using WSSE Security and Basic Authenticattion
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 28/02/2018
* Time: 9:30 AM
*/
namespace App\Library;
@bantic
bantic / upload.swift
Created December 9, 2017 19:10
upload UIImage to server with swift
func saveImage(image: UIImage, name:String) {
let req = NSMutableURLRequest(url: NSURL(string:"http://127.0.0.1:3001/")! as URL)
let ses = URLSession.shared
req.httpMethod="POST"
req.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type")
req.setValue(name, forHTTPHeaderField: "X-FileName")
let jpgData = UIImageJPEGRepresentation(image, 1.0)
req.httpBodyStream = InputStream(data: jpgData!)
let task = ses.uploadTask(withStreamedRequest: req as URLRequest)
task.resume()
@afiqiqmal
afiqiqmal / SocialController.php
Last active January 12, 2024 03:25
Example usage of Socialite with one Controller in Laravel
<?php
namespace App\Http\Controllers;
use App\Traits\SocialUsers;
use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
class SocialController extends Controller
{
@afiqiqmal
afiqiqmal / helpers.php
Last active January 17, 2018 13:32
Helper function for focusing on Laravel Storage. Easier to save and get files
<?php
if (! function_exists('store_file')) {
/**
* @param $file
* @param string $disk
* @param bool $add_time
* @param bool $replace_space
* @param null $prefix
@darrarski
darrarski / CustomIntensityVisualEffectView.swift
Last active March 17, 2025 10:15
UIVisualEffectView subclass that allows to customise effect intensity
// MIT License
//
// Copyright (c) 2017 Dariusz Rybicki Darrarski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@nasrulhazim
nasrulhazim / get-all-public-holidays-for-malaysia-states.md
Last active October 4, 2023 08:08
Get All Public Holidays for Malaysia States

Get All Public Holidays for Malaysia States

Installation

  1. Install PhantomJs
    • For Ubuntu 16.04, click here
  2. Install CasperJS
    • install globally: npm install -g casperjs

Usage

@alexaubry
alexaubry / Heroku-Vapor-Docker-Tutorial.md
Last active December 26, 2022 12:03
How to run Vapor with Docker in Heroku

How to run Vapor with Docker in Heroku

In this tutorial you'll learn how to run a Vapor server in a Docker container on Heroku.

Recently, Heroku added the ability to run Docker images on their Runtime. You can use this system instead of the traditional buildpack-based system for various reasons, mainly for having more control over the environment your server will run on.

Prerequisites

To complete this tutorial, you'll need:

@drewjoh
drewjoh / Cors.php
Created June 13, 2016 22:47
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@sohayb
sohayb / ArrayDeepCopy.swift
Last active October 25, 2024 04:07
Array deep copy in Swift
//Protocal that copyable class should conform
protocol Copying {
init(original: Self)
}
//Concrete class extension
extension Copying {
func copy() -> Self {
return Self.init(original: self)
}