This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, session, redirect, url_for | |
import urllib | |
import requests | |
app = Flask(__name__) | |
app.secret_key = 'iwonttellyou' | |
redirect_uri = 'http://localhost:5000/callback' | |
client_id = '' # get from https://code.google.com/apis/console | |
client_secret = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.well-inverse { | |
min-height: 20px; | |
padding: 19px; | |
margin-bottom: 20px; | |
background-color: #ffffff; | |
border: 1px solid #e3e3e3; | |
-webkit-border-radius: 4px; | |
-moz-border-radius: 4px; | |
border-radius: 4px; | |
/* -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.05); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write this snippet inside the Knockout viewModel | |
// getting all the comments from the server | |
$.getJSON("comments.php", function(commentModels) { | |
var t = $.map(commentModels.comments, function(item) { | |
return new Comment(item); | |
}); | |
self.comments(t); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write this under Knockout viewModel | |
// This is an example to send all the users comments to the server | |
// Basic Example we can fit it for other purposes as well | |
self.save = function() { | |
return $.ajax({ | |
url: "comments.php", | |
contentType: 'application/json', | |
type: 'POST', | |
data: JSON.stringify({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Change these | |
define('API_KEY', 'Your App API KEY' ); | |
define('API_SECRET', 'Your App API SECRET' ); | |
define('REDIRECT_URI', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']); | |
define('SCOPE', 'r_fullprofile r_emailaddress rw_nus' ); | |
// You'll probably use a database | |
session_name('linkedin'); | |
session_start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from dd/mm/yyyy to yyyy/mm/dd format of dates | |
f = open('testdate.txt') | |
i = f.read() | |
print i | |
date = i.split("\n") | |
print date | |
convDate = [] | |
for adate in date: | |
if '/' in adate: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Following Program would work as Lexical Analyser | |
# | |
# Write a C/C++ program which reads a program written | |
# in any programming language (say C/C++/Java) and then perform | |
# lexical analysis. The output of program should contain the | |
# tokens i.e. classification as identifier, special symbol, delimiter, | |
# operator, keyword or string. It should also display the number of | |
# identifiers, special symbol, delimiter, operator, keyword, strings | |
# and statements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is the correct program | |
import re | |
import urllib2 | |
# get_next_target() takes a page and checks for the positions of the links | |
def get_next_target(page): | |
match=re.findall(r'[\w.-]+@[\w.-]+',page) | |
if match: | |
return match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a web crawler | |
''' | |
A crawler is a program that starts with a url on the web (ex: http://python.org), fetches the web-page corresponding to that url, and parses all the links on that page into a repository of links. Next, it fetches the contents of any of the url from the repository just created, parses the links from this new content into the repository and continues this process for all links in the repository until stopped or after a given number of links are fetched. | |
''' | |
# urllib2 for downloading web pages | |
import urllib2 | |
# get_next_target() takes a page and checks for the positions of the links it finds from '<a href=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!flask/bin/python | |
from flask import Flask, jsonify, abort, request, make_response, url_for | |
from flask.ext.httpauth import HTTPBasicAuth | |
app = Flask(__name__, static_url_path = "") | |
auth = HTTPBasicAuth() | |
@auth.get_password | |
def get_password(username): | |
if username == 'miguel': |
OlderNewer