Skip to content

Instantly share code, notes, and snippets.

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@Axxiss
Axxiss / AsyncTester.java
Last active June 2, 2016 18:17
Testing AsyncHttpClient with Robolectric
public class AsyncTester {
protected static final int HTTP_OK = 200;
protected ApiCallback mCallback;
private ProtocolVersion mHttpVersion;
protected AsyncHttpClient mHttpClient = new AsyncHttpClient();
@Axxiss
Axxiss / hibernate-maven.xml
Last active December 22, 2015 14:29
Adding Hibernate to a Maven project.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
class FeatureContext extends MinkContext
implements KernelAwareInterface
{
private $kernel;
private $parameters;
/**
* Initializes context with parameters from behat.yml.
*
* @param array $parameters
@Axxiss
Axxiss / behat.yml
Last active December 15, 2015 05:49
default:
paths:
features: src/Acme/MyBundle/Features
bootstrap: %behat.paths.features%/bootstrap
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Given I have a calculator
When I add 2 and 2
Then the result should be 4
Given I have a calculator
When I add 2 and -2
Then the result should be 0
Given I have a calculator
When I add -2 and -2
public void testSuma() {
assertEqualas(4, Calculadora.suma(2, 2));
assertEqualas(0, Calculadora.suma(2, -2));
assertEqualas(-4, Calculadora.suma(-2, -2));
}
@Axxiss
Axxiss / MyActivity.java
Created March 9, 2013 23:15
Injection on Activity
@Inject TelephonyManager mTelephonyManager
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((FinderApplication) getApplication()).getGraph().inject(this);
}
@Axxiss
Axxiss / ServiceModule.java
Last active December 14, 2015 17:59
Module for system services injection
@Module(
entryPoints = {
MyApplication.class,
}
)
public class ServiceModule {
private Context mContext;
public ServiceModule(Context context) {
@Axxiss
Axxiss / MyApplication.java
Last active December 14, 2015 17:59
Daggers integration
public class MyApplication extends Application {
private ObjectGraph mObjectGraph;
@Override
public final void onCreate() {
super.onCreate();
mObjectGraph = ObjectGraph.create(new ServiceModule(this));
}