Skip to content

Instantly share code, notes, and snippets.

View arnabc's full-sized avatar

Arnab Chakraborty arnabc

View GitHub Profile
// Provided by Square under the Apache License
public final enum BusProvider {
INSTANCE;
public static final Bus BUS;
private BusProvider() {
BUS = new Bus();
}
}
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
package com.squareup.example;
public abstract BaseActivity extends SherlockActivity {
private final ScopedBus scopedBus = new ScopedBus();
protected ScopedBus getBus() {
return scopedBus;
}
@Override public void onPause() {
@arnabc
arnabc / some_php_link_parsing_not_for_production.php
Created June 7, 2013 13:00
A simple PHP code which parses the Youtube links from a text(paragraph) and then finds the video id from the URL.
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
nbproc 1
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
### Nginx upstart script
### source: http://serverfault.com/a/391737/70451
### /etc/init/nginx.conf
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/opt/nginx/sbin/nginx
public class MyContentProvider extends ContentProvider {
private final ThreadLocal<Boolean> mApplyingBatch;
private final ThreadLocal<Set<Uri>> mChangedUris;
private boolean applyingBatch() {
return mApplyingBatch.get() != null && mApplyingBatch.get();
}
private Uri insert(final Uri uri, final ContentValues values, final SQLiteDatabase db) {
// do the uri matching and insert
/*
* Copyright 2012 CodeSlap - Cristian Castiblanco
*
* 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
@arnabc
arnabc / cap_notify.rb
Created November 10, 2012 11:27 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@arnabc
arnabc / cap_notify.rb
Created November 10, 2012 11:26 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.