Skip to content

Instantly share code, notes, and snippets.

View nasrulhazim's full-sized avatar
🎯
Focusing

Nasrul Hazim Bin Mohamad nasrulhazim

🎯
Focusing
View GitHub Profile
@jeffochoa
jeffochoa / EloquentSortableServiceProvider.php
Last active June 9, 2021 01:33
Laravel Eloquent pagination and column sorting using macros
<?php
namespace App\Providers;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
class EloquentSortableServiceProvider extends ServiceProvider
{
image: ubuntu:zesty
services:
- mariadb
variables:
MYSQL_DATABASE: smsclub_old
MYSQL_ROOT_PASSWORD: root
before_script:
@claytonrcarter
claytonrcarter / README.md
Last active June 8, 2023 05:42
Share named routes between Laravel and Javascript

Share named routes between Laravel and Javascript

This is a 2-part technique to share named routes between Laravel and Javascript. It uses a custom artisan command to export your named routes to JSON, and a Javascript route() helper to lookup the route and fill in any parameters. Written for Laravel 5.3; not tested in 5.4.

Installation

1. Install RouteJson.php

Copy RouteJson.php into your app as app/Console/Commands/RouteJson.php

@akutaktau
akutaktau / index.php
Last active March 29, 2017 06:17
Trigger which version Whatsapp to sent messages
<?php
/**
Thanks stackoverflow
*/
function getOS($user_agent) {
$os_array = array(
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
@alienxp03
alienxp03 / malaysia_holidays.json
Created January 6, 2017 06:41
Malaysia 2017 Holidays (including states)
[
{
"name": "New Years Day",
"date": "01/01/2017",
"states": [
"Kuala Lumpur",
"Labuan",
"Malacca",
"Negeri Sembilan",
"Pahang",
@shah253kt
shah253kt / json
Created November 28, 2016 20:52
JSON file containing Swift Code of all banks in Malaysia (Last Update: 29th November 2016)
[
{
"ID": "1",
"Bank or Institution": "AFFIN BANK BERHAD",
"City": "KUALA LUMPUR",
"Branch": "",
"Swift Code": "PHBMMYKL"
},
{
"ID": "2",
@natsu90
natsu90 / gist:6787b254929355c34e63
Last active March 27, 2024 21:54
Installing PDO Informix
1. Installing Informix Client SDK for Linux x86_64
1.1 Download Informix Client SDK 3.70 for Linux x86_64 from IBM website, https://www-01.ibm.com/marketing/iwm/tnd/search.jsp?rs=ifxdl
1.2 Extract the file, `cd /opt/informix; tar -xvf clientsdk.3.70.FC8DE.LINUX.tar`
1.3 Start installation, `./installclientsdk`, install all
2. Installing PDO Informix
@hassansin
hassansin / eloquent-cheatsheet.php
Last active May 5, 2024 05:53
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@jwage
jwage / .php_cs
Last active May 3, 2023 06:42
php-cs-fixer git pre commit hook
<?php
return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
'short_array_syntax',
'ordered_use',
])
;
@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing