Skip to content

Instantly share code, notes, and snippets.

View djodjoni's full-sized avatar

Kalin Maldzhanski djodjoni

View GitHub Profile
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.
*/
{
"main": "food",
"sub": "bread"
}
@djodjoni
djodjoni / rmFrags.java
Created April 27, 2014 14:44
Remove multiple fragments from the same container without knowledge of their tags
//--> REMOVE fragments if any in containerId
//FragmentTransaction.replace does not replace all the fragments in the container but only one thus we need to remove them all one by one
Fragment currFrag = getFragmentManager().findFragmentById(containerId);
while(currFrag!=null) {
try {
getFragmentManager().beginTransaction().remove(currFrag).commit();
// fragment will not be removed instantly so we need to wait for the next one, otherwise too many commits buildup in the heap causing OutOfMemory
android.app.Fragment nextFrag = getFragmentManager().findFragmentById(containerId);
while (nextFrag != null && nextFrag==currFrag) {
package com.yourco.yourapp;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
configurations {
apt
}
dependencies {
compile 'com.squareup.dagger:dagger:1.1.0'
apt 'com.squareup.dagger:dagger-compiler:1.1.0'
}
android.applicationVariants.all { variant ->
@djodjoni
djodjoni / cca2-to-cca3
Created June 23, 2014 16:16
json Map helper to/from cca2-cca3 country codes
{"AF":"AFG","AX":"ALA","AL":"ALB","DZ":"DZA","AS":"ASM","AD":"AND","AO":"AGO","AI":"AIA","AQ":"ATA","AG":"ATG","AR":"ARG","AM":"ARM","AW":"ABW","SH":"SHN","AU":"AUS","AT":"AUT","AZ":"AZE","BS":"BHS","BH":"BHR","BD":"BGD","BB":"BRB","BY":"BLR","BE":"BEL","BZ":"BLZ","BJ":"BEN","BM":"BMU","BT":"BTN","BO":"BOL","BQ":"BES","BA":"BIH","BW":"BWA","BV":"BVT","BR":"BRA","IO":"IOT","VG":"VGB","BN":"BRN","BG":"BGR","BF":"BFA","BI":"BDI","KH":"KHM","CM":"CMR","CA":"CAN","CV":"CPV","KY":"CYM","CF":"CAF","TD":"TCD","CL":"CHL","CN":"CHN","CX":"CXR","CC":"CCK","CO":"COL","KM":"COM","CG":"COG","CD":"COD","CK":"COK","CR":"CRI","HR":"HRV","CU":"CUB","CW":"CUW","CY":"CYP","CZ":"CZE","DK":"DNK","DJ":"DJI","DM":"DMA","DO":"DOM","EC":"ECU","EG":"EGY","SV":"SLV","GQ":"GNQ","ER":"ERI","EE":"EST","ET":"ETH","FK":"FLK","FO":"FRO","FJ":"FJI","FI":"FIN","FR":"FRA","GF":"GUF","PF":"PYF","TF":"ATF","GA":"GAB","GM":"GMB","GE":"GEO","DE":"DEU","GH":"GHA","GI":"GIB","GR":"GRC","GL":"GRL","GD":"GRD","GP":"GLP","GU":"GUM","GT":"GTM","GG":"GGY",
import urllib2
import json
import re
class SoccerwayTeamMatches:
def __init__(self, teamId):
self.teamId = str(teamId)
self.data = {'all': [], 'home': [], 'away': []}
@djodjoni
djodjoni / reverse.es
Last active August 29, 2015 14:05 — forked from mathieue/reverse.es
<VirtualHost *:80>
ServerName es.yourhost.com
<Proxy balancer://main>
BalancerMember http://127.0.0.1:9200 max=1 retry=5
<Limit GET >
order deny,allow
deny from all
allow from 127.0.0.1
SearchResponse searchResponse = client.prepareSearch()
.setQuery(matchAllQuery())
.setSize(35)
.setScroll(TimeValue.timeValueMinutes(2))
.addSort("field", SortOrder.ASC)
.execute().actionGet();
assertThat(searchResponse.hits().getTotalHits(), equalTo(100l));
assertThat(searchResponse.hits().hits().length, equalTo(35));
@djodjoni
djodjoni / gist:38f949a1fd863d427bd8
Created November 12, 2014 13:22
logstash conf FOR iis
input {
file {
type => iis
path => /Users/sic/works/logs/*.log
}
}
filter {
#ignore log comments
if [message] =~ ^# {