Skip to content

Instantly share code, notes, and snippets.

View ktmcodelabs's full-sized avatar

Sujan Byanjankar ktmcodelabs

View GitHub Profile
@ktmcodelabs
ktmcodelabs / Laravel-Scheduler-Windows.md
Created February 22, 2024 08:36 — forked from Splode/Laravel-Scheduler-Windows.md
Laravel Scheduler on Windows

Run Laravel Scheduled Tasks on Windows

The following are instructions for running scheduled tasks defined in a Laravel project on Windows. The Laravel documentation provides instructions for running scheduled tasks using cron jobs on Linux systems. However, cron jobs are not available on Windows. The built-in Windows Task Scheduler can be used to run scheduled tasks instead.

Create a Scheduled Task

  1. Open Task Scheduler
  2. Select Create Task...
  3. Give the task a name and description
  4. To run the task in the background, select Run whether the user is logged on or not and check the Hidden checkbox.
@ktmcodelabs
ktmcodelabs / send_mail_notification.php
Last active April 7, 2022 10:22
Wordpress send mail notification method with wp_mail()
<?php
function send_mail_notification($message)
{
$from_name = get_option('blogname');
$subject = "Message from User";
$to = "[email protected]";
$headers[] = 'Content-Type: text/html; charset=UTF-8';
$headers[] = "From: $from_name <[email protected]>";
wp_mail($to, $subject, $message, $headers);
}
@ktmcodelabs
ktmcodelabs / wordpress_handle_cutom_contac_form.php
Last active April 7, 2022 10:22
Wordpress method to handle custom contac form submission
<?php
function handle_custom_contact_form()
{
global $wpdb;
$params = $_POST;
$table_name = $wpdb->prefix . 'contact_requests';
$query = $wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table_name));
if (!$wpdb->get_var($query) == $table_name) {
/*create table if not exists*/
$sql = "CREATE TABLE {$table_name} (
@ktmcodelabs
ktmcodelabs / contact_page_template.php
Created April 7, 2022 10:13
Wordpress custom contact form page template
// contact_page_template.php
<?php
/*
* Template Name: Contact Form
* Template Post Type: page
*/
get_header();
?>
@ktmcodelabs
ktmcodelabs / custom_contact.php
Last active April 7, 2022 10:21
Wordpress custom form handler method
<?php
add_action('admin_post_nopriv_custom_contact_form', 'handle_custom_contact_form'); //for non logged in users
add_action('admin_post_custom_contact_form', 'handle_custom_contact_form'); // for logged in users
function handle_custom_contact_form()
{
global $wpdb;
$params = $_POST;
$table_name = $wpdb->prefix . 'contact_requests';
@ktmcodelabs
ktmcodelabs / axios.refresh_token.1.js
Created March 22, 2022 07:23 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@ktmcodelabs
ktmcodelabs / gist:7f463fe775fecaa614a89bdd77b0d894
Created February 9, 2022 10:14 — forked from lgalaz/gist:aec80abd40350161ff63
Server sent events with Laravel
Using nginx version: nginx/1.6.2 and Laravel 5
In the controller:
use Symfony\Component\HttpFoundation\StreamedResponse;
- - - - - - Some method - - - - - - - - -
$response = new StreamedResponse();
$response->headers->set('Content-Type', 'text/event-stream');
$response->headers->set('Cache-Control', 'no-cache');
$response->setCallback(
function() {
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],

How to install OCI8 in windows

Instantclient Version 12.2.0.1.0

Xampp
php 7.2.4
Windows 10

Step 1

Download OCI8 2.1.8 - 7.2 Thread Safe (TS) x86

@ktmcodelabs
ktmcodelabs / gist:123e0f055affaf3ebc52076a1ec9782d
Created June 16, 2020 08:48 — forked from dustyf/gist:b6e72a7a7fd05de9598e
Example WordPress Simple JSON Endpoint Plugin
<?php
/**
* Plugin Name: WDS GIF API
* Plugin URI: http://webdevstudios.com
* Description: Adds a Custom Post Type to store GIFs and an API JSON Endpoint to access GIFs by a tag.
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/