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 / 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 / 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 / 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 / drupal-plugins.info
Last active April 9, 2018 09:34
Useful modules in every drupal projects
Date
Webform
Entity API
Libraries API
Views
Google Analytics
Backup and Migrate
Views Slideshow
Context
Media
@rohankhudedev
rohankhudedev / indian-states-cities.json
Created September 5, 2018 10:25
Indian 36 states and 5741 cities and town in json format. Based on source https://github.com/hiiamrohit/Countries-States-Cities-database.
{"AN":["Bombuflat","Garacharma","Port Blair","Rangat"],"AP":["Addanki","Adivivaram","Adoni","Aganampudi","Ajjaram","Akividu","Akkarampalle","Akkayapalle","Akkireddipalem","Alampur","Amalapuram","Amudalavalasa","Amur","Anakapalle","Anantapur","Andole","Atmakur","Attili","Avanigadda","Badepalli","Badvel","Balapur","Bandarulanka","Banganapalle","Bapatla","Bapulapadu","Belampalli","Bestavaripeta","Betamcherla","Bhattiprolu","Bhimavaram","Bhimunipatnam","Bobbili","Bombuflat","Bommuru","Bugganipalle","Challapalle","Chandur","Chatakonda","Chemmumiahpet","Chidiga","Chilakaluripet","Chimakurthy","Chinagadila","Chinagantyada","Chinnachawk","Chintalavalasa","Chipurupalle","Chirala","Chittoor","Chodavaram","Choutuppal","Chunchupalle","Cuddapah","Cumbum","Darnakal","Dasnapur","Dauleshwaram","Dharmavaram","Dhone","Dommara Nandyal","Dowlaiswaram","East Godavari Dist.","Eddumailaram","Edulapuram","Ekambara kuppam","Eluru","Enikapadu","Fakirtakya","Farrukhnagar","Gaddiannaram","Gajapathinagaram","Gajularega","Gajuvaka","Ganna
@rohankhudedev
rohankhudedev / readme.md
Last active February 25, 2019 12:56
host laravel in server without manipulating structure and without artisan
  • Before cloning project on server run below command. ref
$ umask 0022
  • Then clone your project
  • Run composer update ```$ composer update`
  • Give required permissions
$ chmod 0777 -R storage/
@rohankhudedev
rohankhudedev / multi-lingual-validation-msgs-formvalidator-net.js
Last active October 1, 2019 18:39
Multi Lingual form validation messages for http://www.formvalidator.net/. Note - validation messages commented in english is not being translated. Google translator used to translate validation messages
var english = {
errorTitle: 'Form submission failed!',
requiredFields: 'You have not answered all required fields',
requiredField: 'This field is required',
// badTime: 'You have not given a correct time',
badEmail: 'You have not given a correct e-mail address',
badTelephone: 'You have not given a correct phone number',
// badSecurityAnswer: 'You have not given a correct answer to the security question',
// badDate: 'You have not given a correct date',
lengthBadStart: 'The input value must be between ',