Skip to content

Instantly share code, notes, and snippets.

View hassanabidpk's full-sized avatar
🎯
Focusing

Hassan Abid hassanabidpk

🎯
Focusing
  • Singapore
View GitHub Profile
/* Create new object at /user-runs/$userid/$runid and at
* /runs/$runid simultaneously
*/
String key = mDatabase.child("runs").push().getKey();
MyRun run = new MyRun(userId, mCity, mDate, mHost, mTitle, mWeather, mWebsite, mLat,
mLng, mLocation, mMapUrl, mTemperature, "strava", activity, photo_url);
Map<String, Object> postValues = run.toMap();
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/runs/" + key, postValues);
public class PastEventFragment extends Fragment {
private static final String TAG = PastEventFragment.class.getSimpleName();
public static final String MARATHON_EVENT_DATABASE = "event";
private DatabaseReference mDatabase;
private List<Event> mEventList;
private Query mEventsQuery;
private Context mContext;
@hassanabidpk
hassanabidpk / Event.java
Created June 11, 2017 14:16
For firebase medium blog
@IgnoreExtraProperties
public class Event {
public String application_period;
public String city;
public String date;
public String email;
public String host;
public String latitude;
public String location;
{
"event" : {
".read": true,
".write": true,
"2017": {
".indexOn": ["run_id", "date"]
}
}
}
{
"event": {
"2017": [{
"title": "Seoul International Marathon",
"host": "Donga Ilbo",
"email": "kumf3040@naver.com",
"date": "2017/03/19 08:00",
"phone": "02-2652-3040",
"race": {
"0": "10km",
import UIKit
import Alamofire
class NewRestaurantViewController: UIViewController {
static let REST_UPLOAD_API_URL = "YOUR_POST_REQUEST_URL"
override func viewDidLoad() {
super.viewDidLoad()
// If you have any autorization headers
@hassanabidpk
hassanabidpk / views.py
Last active April 6, 2017 06:40
views.py for Medium blog post
from .serializers import RestaurantSerializer
from rest_framework import status, permissions
from rest_framework import mixins, generics
class RestaurantList(mixins.ListModelMixin,
mixins.CreateModelMixin,
generics.GenericAPIView):
"""
List all restaurant, or create a restaurant
"""
@hassanabidpk
hassanabidpk / serializers.py
Created April 6, 2017 06:21
Serializer for Medium blog post
from rest_framework import serializers
from .models import Restaurant
class RestaurantSerializer(serializers.ModelSerializer):
class Meta:
model = Restaurant
fields = ('id', 'name', 'description', 'image')
@hassanabidpk
hassanabidpk / models.py
Created April 6, 2017 05:47
For Medium blog post
from django.db import models
class Restaurant(models.Model):
name = models.CharField(max_length=200)
description = models.TextField(blank=True)
image = models.ImageField(upload_to="restaurants/images/", null=True, blank=True)
def __str__(self):
return "{}".format(self.name)
platform :ios, '9.0'
target 'TestPodsVersion' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'ObjectMapper', '~> 2.2'
pod 'RxSwift', '~> 3.0'
pod 'Moya/RxSwift'
pod 'Moya-ObjectMapper/RxSwift'