Skip to content

Instantly share code, notes, and snippets.

View djodjoni's full-sized avatar

Kalin Maldzhanski djodjoni

View GitHub Profile
{
"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 ->
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] =~ ^# {
@djodjoni
djodjoni / introrx.md
Last active August 29, 2015 14:19 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

#!/usr/bin/env bash
TCPDUMP_PID=""
SOCAT_PID=""
OUTPUT_FILE=""
PORT=12345
TMPDIR="."
TCPDUMP_PATH="/data/local/tmp/xbin/tcpdump"
NETCAT_PATH="/data/local/tmp/nc"
HOST_INTERFACE="en0"