Skip to content

Instantly share code, notes, and snippets.

@anehkumar
anehkumar / gist:46e1405e0a651e3d102d2dce5f7e4ff8
Last active November 7, 2022 10:57
Step react-compound-slider
import React, { Component } from 'react'
import { Slider, Rail, Handles, Tracks, Ticks } from 'react-compound-slider'
const sliderStyle = {
position: 'relative',
width: '100%',
}
const railStyle = {
position: 'absolute',
@anehkumar
anehkumar / SearchWordInArrayOrObject.js
Last active September 6, 2021 05:01
Search Words in Array or Object Example Javascript React
let searchWord=(searchQuery, array, objectKey=null)=>{
return array.filter(d =>{
let data =objectKey? d[objectKey] : d //Incase If It's Array Of Objects.
let dataWords= typeof data=="string" && data?.split(" ")?.map(b=>b&&b.toLowerCase().trim()).filter(b=>b)
let searchWords = typeof searchQuery=="string"&&searchQuery?.split(" ").map(b=>b&&b.toLowerCase().trim()).filter(b=>b)
//let matchingWords = searchWords.filter(word=>dataWords.includes(word))
let matchingWords = searchWords.filter((word)=> dataWords.find(a =>a.includes(word)))
@anehkumar
anehkumar / gist:cbc08ac6c5f341610f6ea28e5c4ff0e3
Created September 29, 2020 08:16
Sace Upload File cakephp 3
<?php
if($this->request->is('post')){
$user_id = $this->Auth->user('id');
$data = $this->request->getData();
$location = WWW_ROOT."prescription/";
$allowed_ext = ['png' ,'jpg', 'jpeg'];
$filename = $data['image_file']['name'];
$temp = $data['image_file']['tmp_name'];
$size = $data['file']['size'];
<script>
var isMobile = false;
if (navigator.userAgent !== undefined) {
var userAgent = navigator.userAgent.toLowerCase();
var iPhoneIndex = userAgent.indexOf("iphone");
var iPadIndex = userAgent.indexOf("ipad");
var isIPhone = (iPhoneIndex !== -1 && iPadIndex === -1) || (iPhoneIndex !== -1 && iPhoneIndex < iPadIndex);
var isAndroid = userAgent.indexOf("android") !== -1 && userAgent.indexOf("mobile") !== -1;
var isOtherMobile = userAgent.match(/^.*?(ipod|blackberry|mini|windows\\sce|palm|phone|mobile|smartphone|iemobile).*?$/) != null;
isMobile = isIPhone || isAndroid || isOtherMobile;
<div id="chatbun10"></div>
<script type="text/javascript">
(function(d) {
var params =
{
id: "1",
wid: "10",
cb: (new Date()).getTime()
};
var qs = Object.keys(params).reduce(function(a, k){ a.push(k + '=' + encodeURIComponent(params[k])); return a},[]).join(String.fromCharCode(38));
@anehkumar
anehkumar / firebase_push_notification.php
Last active March 28, 2020 17:13
Send Firebase push notification android using php
<?php
function sendMessage($data, $target, $serverKey){
//FCM api URL
$rsp = [];
$url = 'https://fcm.googleapis.com/fcm/send';
//api_key available in Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key
$server_key = $serverKey;
$fields = array();
$fields['data'] = $data;
SafetyNet.getClient(MainActivity.this).verifyWithRecaptcha(SITE_KEY)
.addOnSuccessListener(MainActivity.this,
new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
@Override
public void onSuccess(SafetyNetApi.RecaptchaTokenResponse response) {
// Indicates communication with reCAPTCHA service was
// successful.
String userResponseToken = response.getTokenResult();
Log.e("response", userResponseToken);
if (!userResponseToken.isEmpty()) {
function getIndianCurrency(float $number)
{
$decimal = round($number - ($no = floor($number)), 2) * 100;
$hundred = null;
$digits_length = strlen($no);
$i = 0;
$str = array();
$words = array(0 => '', 1 => 'one', 2 => 'two',
3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six',
7 => 'seven', 8 => 'eight', 9 => 'nine',
@anehkumar
anehkumar / gist:1ea4e26a36ed8823068de565f4272f8f
Created November 22, 2018 11:33
Create time slot using php
// getTimeSlot(IntervalInMinutes, $startTime, $endTime)
function getTimeSlot($interval, $start, $end)
{
$start = new DateTime($start);
$end = new DateTime($end);
$start_time = $start->format('H:i');
$end_time = $end->format('H:i');
$i=0;
while(strtotime($start_time) <= strtotime($end_time)){
$start = $start_time;
@anehkumar
anehkumar / CountryDialCode.json
Created August 23, 2016 07:16
Country List with name and dial code
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"