Skip to content

Instantly share code, notes, and snippets.

View ersin-ertan's full-sized avatar
🔥
GCP/Firebase + Android Professional

Ersin Ertan ersin-ertan

🔥
GCP/Firebase + Android Professional
View GitHub Profile
@ersin-ertan
ersin-ertan / pythonDictionaryUsage.py
Created February 21, 2016 21:26
practise using a dictionary with different typed keys, string, int and a tuple. Doing conversions to strings and ints, note that you can not alter the size of the items in the dictionary while in the for loop. Popping value from a secondary list.
d = { "a":3, 1:'b'}
dd ={}
dd[1] = 'b'
dd['a'] = 2
dd[(1,2)] = 0 # using a tuple as a key
print d
print dd
listOfKeysToPop = []
@ersin-ertan
ersin-ertan / CrushComplementTemplate.java
Created October 18, 2015 03:08
Programmer romance...
public class Complement<T> extends PersonalityBased implements Rapportable{
private Person crush;
Complement(Person crush){this.crush = crush;}
// test
{new Complement<Genuine>(new Person("Jane Doe")).exciting();} // use builder for multi attribute complements
@Override public String funny(){
return crush.name + "";
public class SC{
static class N{
@Retained N1 n1;
@Retained N2 n2;
}
static class O{
@Retained O1 o1;
@Retained O2 o2;
}
@ersin-ertan
ersin-ertan / FragArgsAlphaOrder.java
Last active August 29, 2015 14:26
Fragment args mix and match constructor due to alphabetic ordering
public class Frag00 extends Fragment{
@Arg
String required;
@Arg
boolean isTablet;
}
@FragmentArgsInherited
public class Frag02 extends Frag00{
@Arg
String a;
@ersin-ertan
ersin-ertan / GA-ConversionTerminology
Created July 20, 2015 19:03
Google analytics conversion terminology cheat sheet
Conversion terminology cheat sheet
Ad clicks per conversion: The total number of ad clicks on conversion paths divided by the number of conversions.
Ad impressions per conversion: The total number of ad impressions on conversion paths divided by the number of conversions.
Assisted conversions: The number of conversions that were assisted by a particular campaign, ad group, or keyword. Assisted conversions don't include last click conversions.
Attribution: Assigning value to the different interactions on a customer’s conversion path.
@ersin-ertan
ersin-ertan / gist:3830f699e15da631945a
Created June 17, 2015 11:19
Remove tracked files that are now gitignored
http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore?rq=1
Try the following, else goto link.
git update-index --assume-unchanged <file>
@ersin-ertan
ersin-ertan / GradleTaskForGeneratingJarAndJavadoc.java
Created April 18, 2015 18:14
gradle task for generating the jar file and the javadoc with annotation processors
// jar task modification
task androidJar(type: Jar){
dependsOn assemble
group 'Build'
description 'blah blah'
from zipTree(
'build/intermediates/bundles/release/classes.jar')
from zipTree(
'../annotations-processor/build/libs/processor.jar')
from zipTree(
@ersin-ertan
ersin-ertan / AndroidLibraryGradleTaskForBintray.java
Created April 18, 2015 17:59
Bintray requires sourcesJar and javadoc jar, here is how to generate them from your library using gradle
// for sources
task androidSourcesJar(type: Jar){
from android.sourceSets.main.java.srcDirs
}
// for javadoc.jar
android.libraryVariants.all { variant ->
task("javadoc${variant.name.capitalize()}", type: Javadoc){
description "Generates Javadoc for $variant.name."
group 'Docs'
public static void testMontyHall(){
Random random = new Random(1);
float percentOfWinsForStay = 0;
float percentOfWinsForSwitch = 0;
float numberOfPlays = 100;
for(int aPlay = 0; aPlay < numberOfPlays; aPlay++){
int guess = random.nextInt(3);
@ersin-ertan
ersin-ertan / PatternGenericStategyRecursiveGeneric.java
Created March 18, 2015 05:23
Requiring the type of TaxStrategy to be passed in with the income, allowing for each TaxPayer to implement their own TaxStrategy, using getThis() abstract method to retrieve the class specific compiled type
public class StrategyRecursiveGenerics {
public void clientProvideStrategy(){
long amount = 10000000L;
Person person = new Person(amount, new DefaultTaxStrategy<Person>());
Person person1 = new Person(amount, new DodgingTaxStrategy<Person>());
Trust nonProfit = new Trust(amount, new TrustTaxStrategy(), true);
Trust forProfit = new Trust(amount, new TrustTaxStrategy(), false);
assert person.computeTax() == 4000000;