Skip to content

Instantly share code, notes, and snippets.

Ken John Siosan kenmasters

Block or report user

Report or block kenmasters

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
We couldn’t find that file to show.
View PHP: Parsing an image sent as base64 encoded
$base64_image = 'contents_of_base64_sample.txt';
if (preg_match('/^data:image\/(\w+);base64,/', $base64_image)) {
$data = substr($base64_image, strpos($base64_image, ',') + 1);
$extension = getImageExtension($base64_image);
$image = base64_decode($data);
// construct filename with file_extension
$image_name = $this->auth_user->id.$this->auth_user->user1.time().'.'.$extension;
@kenmasters
kenmasters / geocoding-google.js
Created Sep 23, 2019
Geocoding address using google
View geocoding-google.js
//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 Mar 28, 2019
Laravel5.7 Login Redirect base from User Role(Spatie/Laravel-Permission package)
View LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
View jQuery Date Picker: End date should not be less than start date.
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)
}
});
View WP Filter: Modify Edit Profile url
add_filter( 'edit_profile_url', 'custom_profile_url', 10, 3 );
function custom_profile_url( $url, $user_id, $scheme ) {
if ( !current_user_can('subscriber') ) return;
return '';
}
# IMPORTANT NOTES: What the function does above is removing the link on the Edit Profile if the current loggedin user role is `subscriber`.
View GFORM: Dynamically populate select field choices
# References:
# https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
# https://docs.gravityforms.com/gf_field_select/
add_filter( 'gform_pre_render_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_pre_validation_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_pre_submission_filter_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_admin_pre_render_45', 'disable_ADA_ACA_transactions' );
function disable_ADA_ACA_transactions( $form ) {
View WP: Adding custom rewrite rule
#
add_action( 'init', 'gta_rewrite_add_rewrites' );
function gta_rewrite_add_rewrites()
{
add_rewrite_rule('agent/?([^/]*)', 'index.php?pagename=agent&agentID=$matches[1]', 'top');
}
add_filter('query_vars', 'gta_query_vars');
@kenmasters
kenmasters / GFORM: GFAPI::get_entries + pagination
Created Mar 16, 2018
List gravityform entries using GFAPI class + pagination
View GFORM: GFAPI::get_entries + pagination
# http://inlinedocs.gravityhelp.com/class-GFAPI.html
# https://docs.gravityforms.com/getting-started-with-the-gravity-forms-api-gfapi/
# working code
# notes: we are to going to lists submitted entries of the current loggedin user.
$form_ids = [19, 20, 21, 22, 23, 24, 25, 26]; // accepts single or array of form id's.
$search_criteria = array(
'field_filters' => array(
'mode' => 'any',
@kenmasters
kenmasters / Common-Currency.json
Created Dec 8, 2017 — forked from Fluidbyte/Common-Currency.json
Common Currency Codes in JSON
View Common-Currency.json
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
You can’t perform that action at this time.