Skip to content

Instantly share code, notes, and snippets.

View 1hakr's full-sized avatar
🇦🇺
working on new microstartup

Hari 1hakr

🇦🇺
working on new microstartup
View GitHub Profile
@1hakr
1hakr / parseIgnoreCacheHeaders
Last active August 29, 2015 14:13
parseIgnoreCacheHeaders
public static Cache.Entry parseIgnoreCacheHeaders(NetworkResponse response) {
long now = System.currentTimeMillis();
Map<String, String> headers = response.headers;
long serverDate = 0;
String serverEtag = null;
String headerValue;
headerValue = headers.get("Date");
if (headerValue != null) {
@1hakr
1hakr / LocationHelper
Created March 2, 2015 10:08
Location Helper which helps you get current location from network
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import java.io.DataInputStream;

Keybase proof

I hereby claim:

  • I am 1hakr on github.
  • I am 1hakr (https://keybase.io/1hakr) on keybase.
  • I have a public key ASD6reZN-xvnHJwouZXFDVWeVRsVumZXPVaBpeygIu7Kzwo

To claim this, I am signing this object:

@1hakr
1hakr / index.js
Last active June 5, 2018 07:55
Cloud function for sending notification to android, ios and amazon
function sendAlertNotification(userId, instanceId, notificationKey) {
// Notification details.
const payload = {
notification: {
title: `Price Alert`,
body: 'Body',
sound: 'default',
icon: 'ic_alerts',
android_channel_id: "alerts_channel",
@1hakr
1hakr / index.js
Created July 6, 2018 06:04
Cloud functions for referral rewards and notifications
exports.referralUpdate = functions.database.ref('/rewards/{uid}/referredBy').onCreate((data, context) => {
const snapshot = data;
const uid = context.params.uid;
const referredByUid = snapshot.val().uid;
const referredByClientIdKey = snapshot.val().clientIdKey;
return admin.database().ref(`/users/${referredByUid}/clients`).once('value').then(dataSnapshot => {
var validReferral = true;
var value = dataSnapshot.val();
if (value) {
dataSnapshot.forEach(function(snapshot) {
@1hakr
1hakr / NetworkHelper.swift
Created July 6, 2018 06:47
Network Helper for iOS with custom caching and bootstrapping suppory
//
// NetworkHelper.swift
// acrypto
//
// Created by HaKr on 21/10/17.
// Copyright © 2017 DWorkS. All rights reserved.
//
import Foundation
import Alamofire
@1hakr
1hakr / example.com
Last active January 31, 2024 01:16
Supercharge your NGIX config
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com;
location /api/ {
# Rate Limiting
limit_req zone=reqlimit burst=20; # Max burst of request