Skip to content

Instantly share code, notes, and snippets.

View kayalshri's full-sized avatar

Giri Raj kayalshri

View GitHub Profile
# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# This file is licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the specific
@kayalshri
kayalshri / pythonsimplesolutions.py
Last active March 15, 2019 12:08
Interview QA in python
## Get Number of unique elements in a list
x = ['f', 'e', 'e', 'f', 'f']
# output: {'e': 2, 'f': 3}
# Solution
o = {i:x.count(i) for i in x}
print(o)
#-----------------------------------------------------------------------------------------------------
## Get Number of unique elements in dict
@kayalshri
kayalshri / sendsmsinaws.py
Created March 15, 2019 08:55
SMS Send via AWS
def sendSMS(clientId,msg):
cmd = """wget "https://nxyz.com/LATEST/001?module=profile&clientId=%s" -O clientprofile.json""" % clientId
os.system(cmd)
dataDict = None
with open('clientprofile.json') as bIN:
dataDict = json.load(bIN)
mobile = dataDict.get('mobile')
mstatus = dataDict.get('phoneStatus')
## Validate Mobile Status
if mstatus == 0:
@kayalshri
kayalshri / uniqueelements.py
Created March 15, 2019 07:29
Python :: Count Unique Elements
## Problem : Get Number of unique elements in a list
x = ['f', 'e', 'e', 'f', 'f']
# output {'e': 2, 'f': 3}
##Solution
o = {i:x.count(i) for i in x}
print(o)
## Problem : Get Number of unique values in a dict
@kayalshri
kayalshri / thirukural
Created April 3, 2014 08:50
Thirukural with Meanings read from JSON
<script type="text/javaScript">
$(document).ready(function(){
$.getJSON("http://getthirukural.appspot.com/api/2.0/kural/<?php echo $start;?>-<?php echo $end;?>?appid=m8gzum7bzuank&format=json&jsoncallback=?", function(data){
var result="";
$.each(data.KuralSet.Kural, function(i,Kural){
result += "#"+Kural.Number+"<br>"+Kural.Line1+"<br>"+Kural.Line2+"<br><span class='label-warning'> "+Kural.Translation+"</span><br><BR>";
});
$('#ptable').html(result);
});
@kayalshri
kayalshri / credit_card_validate.php
Created April 25, 2014 12:57
Credit Card Validation
<?php
function checkSum($ccnum) {
$checksum = 0;
for ($i=(2-(strlen($ccnum) % 2)); $i<=strlen($ccnum); $i+=2)
{
$checksum += (int)($ccnum{$i-1});
}
for ($i=(strlen($ccnum)% 2) + 1; $i<strlen($ccnum); $i+=2)
{
$digit = (int)($ccnum{$i-1}) * 2;
@kayalshri
kayalshri / googlepagespeed.php
Created April 8, 2014 10:12
Google Page Speed online test api
<?php
$search_url = (@$_GET['url']) ? : "http://ngiriraj.com/pincode/";
$api_key = "xxxxxxxxxxxxxxxxxxx";
//https://console.developers.google.com/
$speed_url = "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=".$search_url."&key=".$api_key;
print "URL : <BR>".$search_url;
$ch = curl_init ($speed_url);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@kayalshri
kayalshri / Geni oauth connect in PHP
Created April 2, 2013 12:53
Geni connect by using oauth in php
<?php
/*
@author : Giriraj Namachivayam
@date : Apr 2, 2013
@demourl : http://ngiriraj.com/socialMedia/oauthlogin/geni.php
@document : http://ngiriraj.com/work/geni-connect-by-using-oauth-in-php/
@license : Free to use,
@History : V1.0 - Released oauth 2.0 service providers login access
@oauth2 : Support following oauth2 login
Bitly
@kayalshri
kayalshri / stocktwits php oauth authenticate
Created April 1, 2013 10:54
stocktwits php oauth authenticate
<?php
/*
@author : Giriraj Namachivayam
@date : Mar 20, 2013
@demourl : http://ngiriraj.com/socialMedia/oauthlogin/stocktwits.php
@document : http://ngiriraj.com/work/stocktwits-connect-by-using-oauth-in-php/
@license : Free to use,
@History : V1.0 - Released oauth 2.0 service providers login access
@oauth2 : Support following oauth2 login
Bitly
@kayalshri
kayalshri / meetup php oauth autheticate
Created April 1, 2013 10:29
meetup php oauth autheticate
<?php
/*
@author : Giriraj Namachivayam
@date : Mar 20, 2013
@demourl : http://ngiriraj.com/socialMedia/oauthlogin/meetup.php
@document : http://ngiriraj.com/work/meetup-connect-by-using-oauth-in-php/
@license : Free to use,
@History : V1.0 - Released oauth 2.0 service providers login access
@oauth2 : Support following oauth2 login
Bitly