Skip to content

Instantly share code, notes, and snippets.

View hassanabidpk's full-sized avatar
🎯
Focusing

Hassan Abid hassanabidpk

🎯
Focusing
  • Singapore
View GitHub Profile
composer.json
-------------
{
"require": {
"facebook/php-sdk" : "*"
}
}
Phalcon Bootstrap index.php
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query
DjangoGirls - how we scored applications?
지원자 점수제에 대하여
각 지원자에 대하여 1점부터 5점까지 점수를 매겼습니다.
점수 부여 대상 항목은 다음과 같습니다.
• 워크샵 내용이 지원자에게 어떤 실질적인 이득을 주는가?
• 워크샵 내용을 가지고 지원자가 추후 다른 사람들에게 어떤 (현실적인) 도움을 줄 수 있는가?
@hassanabidpk
hassanabidpk / CursorRecyclerViewAdapter.java
Last active September 22, 2015 07:20 — forked from skyfishjy/CursorRecyclerViewAdapter.java
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@hassanabidpk
hassanabidpk / sujinlee_weather_yahoo.py
Created November 29, 2015 14:29 — forked from allieus/sujinlee_weather_yahoo.py
이수진님 날씨 스크립트 개선
# https://github.com/sujinleeme/my-python-journey/blob/master/PR4E/yahoo-weatherAPI.py
import requests
def get_weather(city):
baseurl = 'https://query.yahooapis.com/v1/public/yql'
yql_query = "SELECT * FROM weather.forecast WHERE woeid IN (SELECT woeid FROM geo.places(1) WHERE text='%s')" % city
params = {'q': yql_query, 'format': 'json'}
data = requests.get(baseurl, params=params).json()
Common Endpoints
  • Get list of all restaurants: /api/v1/
  • Get list of restaurants for particular location and type: /api/v1/ with params location and rtype
  • Sample Request: https://searchrestaurant.pythonanywhere.com/api/v1/?format=json&location=oslo&rtype=pizza
Response Values
  • In case of error you will get an error key with a status code
  • You will get an array of dicts eaching containing information about place(restaurant,coffee shop etc.)
from django.contrib.auth.models import User, Group
from rest_framework import serializers
from .models import Location,Restaurant
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
# required imports
def getRestaurantList(ilocation,query):
#....
# code implementation can be seen here https://github.com/hassanabidpk/searchrestaurant/blob/master/django/searchrestaurant/search/views.py
return result
class RestaurantList(APIView):
def get(self,request,format=None):
if "location" in request.GET and "rtype" in request.GET:
[
{"name":"Peppes Pizza",
"latitude":"59.911342",
"longitude":"10.749586",
"address":"Karl Johans gate 1 (Jernbanetorget) 0154 Oslo Norge",
"photo_url":"https://irs0.4sqi.net/img/general/455x300/1089036_6y6hN44be6KeNqnl8hjS-OaLpV6i0bF-h_yXQJ5nzEQ.jpg",
"phone_number":"+47 22 22 55 55",
"venue_id":"4b67301bf964a52038402be3",
"checkins":1025,
"r_type":"pizza",
let params = ["location": locationStr,"rtype": escapedRestaurantValue]
Alamofire.request(.GET, API_BASE_URL, parameters: params)
.responseJSON { response in
if let restaurants = response.result.value {
print("JSON: \(restaurants)")
if let error = restaurants["error"] {
print("No venue found | error :\(error)")
self.restaurantName.text = "Nothing found! Try again"
self.stopSpinner(nil)
return