Skip to content

Instantly share code, notes, and snippets.

View untalfranfernandez's full-sized avatar

Fran Fernández untalfranfernandez

  • iOS developer
  • Granada
View GitHub Profile
@untalfranfernandez
untalfranfernandez / Equatable.swift
Last active July 26, 2020 18:22
Swift: Subclases and Equatable protocol
class Superclass : Equatable {
let foo: Int
init(foo: Int) { self.foo = foo }
func equal(to: Superclass) -> Bool {
return foo == to.foo
}
}
@untalfranfernandez
untalfranfernandez / .gitignore
Created November 2, 2016 15:58
Basic .gitignore for iOS
###############
# OS X Finder #
###############
.DS_Store
####################
## Build generated #
####################
build/
@untalfranfernandez
untalfranfernandez / dex-methods.sh
Created April 3, 2014 19:38
Bash script to find out how many methods your .apk file will contain. (Original idea from @rochoa)
#! /bin/bash
if [ $# -ne 1 ]; then
echo
echo " Usage: dex-methods.sh [dex file to explore] "
echo
echo
else
NUMBER=`cat $@ | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'`
echo "The number of methods found is: " $NUMBER
fi
@untalfranfernandez
untalfranfernandez / gist:8669472
Last active January 4, 2016 19:49
Testing OutOfMemoryError with StringBuilder.
@Test
public void shouldGetOutOfMemoryErrorUsingStringBufferButNotUsingStringWritter(){
int stringBuilderCapacity = 1024;
StringBuilder stringBuilder = new StringBuilder(stringBuilderCapacity);
String randomString = new BigInteger(stringBuilderCapacity++, new SecureRandom()).toString(32);
try {
while (true) {
stringBuilder.append(randomString);
stringBuilderCapacity *= 2;
}
@untalfranfernandez
untalfranfernandez / MenuKey
Created September 24, 2013 12:21
How to know if your Android device has physical menu key.
public boolean hasPhysicalMenyKey(Context context) {
if (VERSION.SDK_INT <= VERSION_CODES.GINGERBREAD_MR1) {
return true;
} else if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB && VERSION.SDK_INT <= VERSION_CODES.HONEYCOMB_MR2) {
return false;
} else {
return ViewConfiguration.get(context).hasPermanentMenuKey();
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="config_app_name">AVélib</string>
<string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string>
<string name="config_com.google.android.maps.v2.api_key">XXX</string>
</resources>
@untalfranfernandez
untalfranfernandez / pom.xml
Created March 24, 2013 17:09
Android application module pom. Copy, paste and replace with the right values.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>[YOUR GROUP ID GOES HERE]</groupId>
<artifactId>[YOUR ARTIFACT ID GOES HERE]</artifactId>
<version>[YOUR ARTIFACT VERSION GOES HERE]</version>
// Copyright 2012 Square, Inc.
package com.squareup.test;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.internal.ActionBarSherlockCompat;
@untalfranfernandez
untalfranfernandez / Usage.java
Created November 12, 2012 23:57 — forked from abombss/Usage.java
A roboguice provider for creating a User-Agent string on android
public class MyModule extends AbstractModule {
@Override
void configure() {
bind(String.class).annotatedWith(UserAgent.class).to(UserAgentProvider.class);
}
}
public class MyComponent {
String userAgent;