Skip to content

Instantly share code, notes, and snippets.

View karthicksivakumar191194's full-sized avatar
🙂

Karthick Sivakumar karthicksivakumar191194

🙂
  • Chennai, India
View GitHub Profile
@karthicksivakumar191194
karthicksivakumar191194 / index.txt
Last active December 5, 2021 12:36
Deploy app to Github Pages with Github Actions
#1 npm install gh-pages --save-dev
#2
@karthicksivakumar191194
karthicksivakumar191194 / index.js
Created October 3, 2021 12:02
Convert all elements in an array to integer in JavaScript
var arr = ["1","2","3","4","5"];
arr = arr.map(Number);
console.log(arr)
@karthicksivakumar191194
karthicksivakumar191194 / bestseat.js
Last active October 3, 2021 08:27
Get Best Seats using JS
/**
* @description Callback on the file selection. On Upload
* - Check if their is seats available on the row
* - Check if best seats available in row
* @param {int} seatsNeeded - count of best seats needed in a row
* @param {int} allSeats - count of total seats in a row
* @param {number[]} bookedSeats - list of booked seats in a row
* @param {consecutive|non-consecutive} type - should we need consecutive or non-consecutive seats
* @returns {number[] | false} - list of best seats available or false
*/
@karthicksivakumar191194
karthicksivakumar191194 / index.php
Last active September 27, 2021 11:28
Helper to get railway time using PHP
<?php
function getRailwayTime($time){
$am = explode('am',str_replace(array('am','Am','aM', 'AM'),'am', $time));
$pm = explode('pm',str_replace(array('pm','Pm','pM', 'PM'),'pm', $time));
$output = 0;
if(isset($am[1])){
$output = $am[0];
}else if(isset($pm[1])){
if((int)$pm[0] > 0){
@karthicksivakumar191194
karthicksivakumar191194 / index.php
Last active September 24, 2021 13:06
Get next dates excluding blocked dates & weekends using PHP
<?php
function getNextDates($blockDates, $countOfNextDatesToShow = 0)
{
//date format - 'Y-m-d'
//strtotime(" +1 day") - add 1 to current date
//strtotime(" +1 weekday") - add 1 to current date execulding saturday & sunday
$_blockDates = [];
$nextDates = array_fill(0, $countOfNextDatesToShow, "");
foreach ($blockDates as $date)
@karthicksivakumar191194
karthicksivakumar191194 / index.css
Created May 4, 2021 18:40
Scrolling to a element inside a scrollable DIV with pure Javascript
div {
height: 200px;
width: 100px;
border: 1px solid black;
overflow: auto;
}
p {
height: 80px;
background: blue;
@karthicksivakumar191194
karthicksivakumar191194 / react-hook-form.js
Last active February 8, 2021 15:57
React Hook Form handle server error & set previous values to form fields
//React Hook Form - handle server error
import { useForm } from "react-hook-form";
import { useMutation } from "react-query";
import axios from "axios";
const Login = () => {
const [userData, setUserData] = useState({});
const { register, handleSubmit, errors, setError } = useForm();
//create a div with id
<div id="snap-chat"></div>
//include the script to render the widget
<script>
!function(e,n,c,s,t,a,o){e.SnapChatGlobalName="sc",e.sc=e.sc||function(){(e.sc.q=e.sc.q||[]).push(arguments)},e.sc.l=1*new Date,a=n.createElement(c),o=n.getElementsByTagName(c)[0],a.async=1,a.src="https://karthicksivakumar191194.github.io/snapchat/snapchat_bundle.js",o.parentNode.insertBefore(a,o)}(window,document,"script");
sc("snap-chat");
</script>
// sc("snap-chat"); | arg1 - HTML ID(required)
API Gateway
API Gateway build with golang for managing license and with proxy to forward the request to micro service
https://api-gatewayy.herokuapp.com/
Add the License Key to Headers with key name "LicenseKey"
Test License Key:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDE5OTI2NTUsImxpY2Vuc2VfZG9tYWluIjoiYXBpLWdhdGV3YXl5Lmhlcm9rdWFwcC5jb20ifQ.L1tMC7I3KWfHtFunAGyieBlvxcJQjUOEt_2BcDVom_o
@karthicksivakumar191194
karthicksivakumar191194 / laravel-cron-server-code.txt
Last active September 7, 2020 16:13
Server snippet for laravel CRON JOB
Go to your terminal, ssh into your server, cd into your project and run this command.
crontab -e
This will open the server Crontab file, paste the code below into the file, save and then exit.
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
//Do not forget to replace /path/to/artisan with the full path to the Artisan command of your Laravel Application.