Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / mongo-docker.bash
Last active July 16, 2023 18:18
Running mongodb inside a docker container (with mongodb authentication)
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
@sourcerebels
sourcerebels / test.java
Created April 29, 2012 16:45
Android > Testing > Robolectric > Assert some button starts activity
@Test
public void shouldStartSomeActivityWhenSomeButtonPressed() {
someButton.performClick();
assertActivityStarted(SomeActivity.class)
}
private void assertActivityStarted(Class<? extends Activity> clazz) {
ShadowActivity shadowActivity = shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
@sourcerebels
sourcerebels / layout.xml
Created April 27, 2012 11:40
Android > Form > Don't show keyboard (don't focus first editable widget
<LinearLayout
style="@style/OfficeDetail"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<!-- Widgets formulario (EditText, ...) -->
</LinearLayout>