Skip to content

Instantly share code, notes, and snippets.

View SeptiyanAndika's full-sized avatar
🏠
Working from home

Septiyan Andika SeptiyanAndika

🏠
Working from home
View GitHub Profile
//http://stackoverflow.com/questions/4605527/converting-pixels-to-dp
//The above method results accurate method compared to below methods
//http://stackoverflow.com/questions/8309354/formula-px-to-dp-dp-to-px-android
//http://stackoverflow.com/questions/13751080/converting-pixels-to-dpi-for-mdpi-and-hdpi-screens
public static float convertPixelsToDp(float px){
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float dp = px / (metrics.densityDpi / 160f);
return Math.round(dp);
@SeptiyanAndika
SeptiyanAndika / gist:570e323a7792f589ebe3
Last active August 29, 2015 14:07
crawler nodejs using request, cheerio, and async
// from a https://github.com/chriso/node.io
var request = require('request')
, cheerio = require('cheerio')
, async = require('async')
, format = require('util').format;
var reddits = [ 'programming', 'javascript', 'node' ]
, concurrency = 2;
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
@SeptiyanAndika
SeptiyanAndika / server.js
Last active August 29, 2015 14:07 — forked from jrolfs/server.js
var express = require('express'),
routingProxy = require('http-proxy').RoutingProxy(),
app = express.createServer();
var apiVersion = 1.0,
apiHost = my.host.com,
apiPort = 8080;
function apiProxy(pattern, host, port) {
return function(req, res, next) {
# the IP(s) on which your node server is running. I chose port 3000.
upstream server {
server 127.0.0.1:3000;
}
# the nginx server instance
server {
listen 80;
@SeptiyanAndika
SeptiyanAndika / AppDelegate.swift
Last active March 26, 2018 04:23
Custom Exception to getting filename and method name from NSSetUncaughtExceptionHandler
//
// AppDelegate.swift
// Custom CatchException
//
// Created by Septiyan Andika on 4/25/16.
// Copyright © 2016 Septiyan Andika . All rights reserved.
//
import UIKit
#import <UIKit/UIKit.h>
@interface IntrinsicTableView : UITableView
@end
@SeptiyanAndika
SeptiyanAndika / A-HopperBus-CodeSample-Readme.md
Created May 30, 2016 15:15 — forked from TosinAF/A-HopperBus-CodeSample-Readme.md
Example use of the Model-View-ViewModel Pattern in iOS (Swift) as explained in http://www.objc.io/issue-13/mvvm.html. Full Source Code can be found at https://github.com/TosinAF/HopperBus-iOS

I decided to build an iOS app for my University's bus service that runs through the various campuses.

xy

It was an interesting challenge as I had nothing but the printed timetables (http://www.nottingham.ac.uk/about/documents/903-times.pdf) to use as the data.

Thus I had to come with a suitable data structure that would complement the design & user experience i had in mind for the app.

I also decided to take the challenge of writing the app in swift. This project has helped me get to up speed with swift really quickly.

server {
listen 80;
server_name res.server-name.me;
gzip on;
gzip_proxied any;
location / {
proxy_pass http://res.cloudinary.com/account-name/;
}
}
@SeptiyanAndika
SeptiyanAndika / CustomItemClickListener.java
Created September 8, 2016 04:44 — forked from riyazMuhammad/CustomItemClickListener.java
Easy Implementation of RecyclerView custom onItemClickListener
public interface CustomItemClickListener {
public void onItemClick(View v, int position);
}