Skip to content

Instantly share code, notes, and snippets.

View kenmasters's full-sized avatar

Ken John Siosan kenmasters

View GitHub Profile
@kenmasters
kenmasters / gist:4cdf592f5486432d7fb453a9ba86e3a9
Last active January 27, 2023 04:39
GravityForms Display month name instead of numbers 1-12
/**
* NOTE: This is a jQuery code used withing Blunova websites {GetAJob|CB|Docreko|OrderPayroll...}
* Place this code inside WP active themes js folder
*/
/**
* Tweak for Gravity Forms month name
* This will target all instance of date field month dropdown
*/
@kenmasters
kenmasters / A. INSTRUCTIONS.txt
Last active January 21, 2022 08:31
MAKE XAMPP SSL
Reference: https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/
1. Create folder named: `C:\xampp\apache\crt`
2. Create files and store those file inside the newly created folder.
2.1 cert.conf
2.2 make-cert.bat
3. Edit cert.conf and Run make-cert.bat
Change {{DOMAIN}} text using the domain we want to use, in this case site.test and save.
@kenmasters
kenmasters / gist:d58c1900e247309a93c571806dc1b279
Created June 28, 2021 03:11
LARAVEL CARBON DATE FROM FORMAT
CODE INPUT:
Route::get('sample', function(){
$date = '06-28-2021'; //@fromFormat" m-d-Y
$date2 = Carbon::createFromFormat('m-d-Y', $date)->format('Y-m-d'); //@toFormat" Y-m-d
return response()->json(['from:' => $date, 'to' => $date2]);
});
RESULT:
@kenmasters
kenmasters / gist:923d87d3feab4b8bbd35250fe1def9b8
Created June 2, 2021 11:32
Laravel: Upload file object to specific folder and set custom filename
if ($file = $request->file('inputFieldNameOfTypeFile')) {
$extension = $file->getClientOriginalExtension();
$filename = 'customFilename'.'.'.$extension;
$courier->tblColumn = Storage::putFileAs($foldername, $file, $filename); // return file absolute path only not the full url
}
@kenmasters
kenmasters / Postman POST PUT Requests.txt
Created March 21, 2021 15:21 — forked from ethanstenis/Postman POST PUT Requests.txt
How to make Postman work with POST/PUT requests in Laravel...
To make Postman work with POST/PUT requests...
https://laravel.com/docs/5.2/routing#csrf-x-csrf-token
In addition to checking for the CSRF token as a POST parameter, the Laravel VerifyCsrfToken middleware will also check for the X-CSRF-TOKEN request header.
1. Store the token in a "meta" tag at the top of your root view file (layouts/app.blade.php)...
<meta name="csrf-token" content="{{ csrf_token() }}">
** If using jQuery, you can now instruct it to include the token in all request headers.
$.ajaxSetup({
We couldn’t find that file to show.
Example: Uploading file to specific customer of a given ID.
$foldername = 'customers/customer-'.$customer->id;
$base64_image = $request->input('field_name'); // Image is sent as Base64
// Currently accepts image only
if (preg_match('/^data:image\/(\w+);base64,/', $base64_image)) {
$data = substr($base64_image, strpos($base64_image, ',') + 1);
$extension = getFileExtension($base64_image);
@kenmasters
kenmasters / geocoding-google.js
Created September 23, 2019 01:54
Geocoding address using google
//Geocode function for the origin location
function GoogleGeocode() {
geocoder = new google.maps.Geocoder();
this.geocode = function(address, callbackFunction) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var result = {};
result.latitude = results[0].geometry.location.lat();
result.longitude = results[0].geometry.location.lng();
callbackFunction(result);
@kenmasters
kenmasters / LoginController.php
Created March 28, 2019 00:23
Laravel5.7 Login Redirect base from User Role(Spatie/Laravel-Permission package)
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
From: <input type="text" id="txtFromDate" />
To: <input type="text" id="txtToDate" />
$(document).ready(function(){
$("#txtFromDate").datepicker({
numberOfMonths: 2,
onSelect: function(selected) {
$("#txtToDate").datepicker("option","minDate", selected)
}
});