Skip to content

Instantly share code, notes, and snippets.

View harshvladha's full-sized avatar
🎯
Focusing

Harsh Vardhan Ladha harshvladha

🎯
Focusing
View GitHub Profile
@harshvladha
harshvladha / reducer.py
Created December 9, 2016 19:07
Python MR Reducer
#!/usr/bin/env python3.4
from operator import itemgetter
import sys
current_word = None
current_count = 0
word = None
#mappers output and reducers input
@harshvladha
harshvladha / mapper.py
Created December 9, 2016 19:03
Python MR Mapper
#!/usr/bin/env python3.4
import sys
#input from STDIN
for line in sys.stdin:
#remove all trailing and leading whitespaces
line = line.strip()
#split line into words
words = line.split()
@harshvladha
harshvladha / socialloginplugin4.php
Created December 9, 2016 18:43
Social Login Plugin - Step - 4
<button>
<a href='login.php?type=logout'>Logout</a>
</button>
@harshvladha
harshvladha / socialloginplugin3.php
Created December 9, 2016 18:41
Social Login Plugin - Step -3
<?php
require 'init.php' //this path must be relative path to this file
require ROOT_DIR."libraries/functions/user_info.php"
echo "Full Name:".full_name();
echo "First Name:".first_name();
echo "Last Name:".last_name();
echo "User Id:".user_id();
echo "Profile Picture Link:".profile_pic_link();
echo "Gender:".gender();
echo "Email:".user_email();
@harshvladha
harshvladha / socialloginplugin2.php
Created December 9, 2016 18:39
Social Login Plugin Integration - Step - 2
<?php
require 'init.php'; //this path must be relative path to this file
require ROOT_DIR."libraries/functions/loggedin.php";
if(loggedIn()){
//user is logged in
}else{
//user is not logged in
}
?>
@harshvladha
harshvladha / socialloginplugin1.php
Created December 9, 2016 18:35
Social Login Plugin Integration - Step - 1
<button>
<a href='login.php?type=facebook'>Login Using Facebook</a>
</button>
@harshvladha
harshvladha / login_flow.py
Last active April 20, 2016 16:34
Simple "Facebook-Login" flow for django - without using any extra app (look last - settings.py file for details)
from django.http import HttpResponse
from django.views.generic import View
from django.views.generic.base import TemplateView, RedirectView
from {$APP_NAME}.models import UserProfile, OAuthProvider
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
import requests
BASE_URL = "http://straightmart.com/"
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define a_size(x) sizeof(x)/sizeof(x[0])