Skip to content

Instantly share code, notes, and snippets.

View rohankhudedev's full-sized avatar

Rohan Khude rohankhudedev

View GitHub Profile
@rohankhudedev
rohankhudedev / currency_converter.php
Last active February 25, 2017 20:19
currency converter google finance calculator can be for all language - php
//I have used google finance calculator for this purpose
function convertCurrency($amount, $from, $to){
$url = "https://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
$data = file_get_contents($url);
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return round($converted, 3);
@rohankhudedev
rohankhudedev / global phone no.regex
Created February 7, 2017 06:16
regex for global to identify pattern for common phone number
i used regex which support varitey of global phone numbers
/^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/gm
Positive -
+42 555.123.4567
+1-(800)-123-4567
+7 555 1234567
+7(926)1234567
@rohankhudedev
rohankhudedev / most_common.py
Last active February 25, 2017 20:25
Most common element in a list - python
#!/bin/python3
#lst is list
def most_common(lst):
return max(set(lst), key=lst.count)
@rohankhudedev
rohankhudedev / redirect_to_mobile_site.html
Last active March 16, 2017 17:50
Redirect desktop site to mobile site using javascript.
/*If you have two different sites, one for mobile and another for desktop. When any user try to visit your desktop site
from mobile, then use below code on your desktop website in index.html or import this below code as external JS.*/
// Add below code in your head tag
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
@rohankhudedev
rohankhudedev / form.html
Last active October 6, 2020 18:02
submit form using simple ajax using post method
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).on('submit','form#smsform',function(e){
e.preventDefault();
@rohankhudedev
rohankhudedev / my_install.sh
Last active October 15, 2019 07:16
Install necessary packages using own shell script
#!/bin/sh
#NOTE : update below links for package URL for all wget URL before proceed
#NOTE : Before running do `chmod +x my_install.sh` && sudo ./my_install.sh
# Update System
sudo apt-get -y update
sudo apt-get dist-upgrade -y
##attempt to correct a system with broken dependencies in place.
sudo apt-get -f install
@rohankhudedev
rohankhudedev / laravel-compress-image.php
Created February 8, 2018 07:58
Laravel - compress image using tinypng API
//Get API KEY from https://tinypng.com/developers
try
{
\Tinify\setKey("W2zSUtK-Up2aS8Q6kQ-ndeHOL06SGHVz");
//TinyPNG Compress Image
$filepath = public_path('images/' . "knowledge-tribe.png");
$source = \Tinify\fromFile($filepath);
$source->toFile($filepath);
} catch( \Tinify\AccountException $e )
{
@rohankhudedev
rohankhudedev / readme.md
Created February 16, 2018 17:48
Essential Social Media Meta Tags
<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />

<!-- Twitter Card data -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@publisher_handle"> <!--  Non-Essential, But Required for Analytics -->
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description less than 200 characters">
@rohankhudedev
rohankhudedev / opcache.ini
Last active October 13, 2024 22:20
Best Zend OpCache Settings / Tuning / Configurations
[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=512
@rohankhudedev
rohankhudedev / .htaccess
Last active August 9, 2024 17:28
Necessary Apache .htaccess Configuration: Performance and Security settings
## ~-~-~- How to use ~-~-~-
# You can directly download as use as it is.
# Everything is listed is only perfomance and security related lines
# Validate .htaccess from http://www.htaccesscheck.com/
# Disable Directory Browsing: Security
Options All -Indexes
# If a dir is a symbol link, follow the link