Skip to content

Instantly share code, notes, and snippets.

View sdanna's full-sized avatar

Steven D'Anna sdanna

View GitHub Profile
@sdanna
sdanna / AddEntryActivity.java
Created October 21, 2015 01:54
Wire up DatePicker
private void setDateFields(){
entryDate.setOnClickListener(this);
Calendar calendar = Calendar.getInstance();
datePickerDialog = new DatePickerDialog(mThis, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
entryDate.setText(dateFormatter.format(newDate.getTime()));
@sdanna
sdanna / AddEntryActivity.java
Created October 21, 2015 01:51
Date Picker Declarations
private DatePickerDialog datePickerDialog;
private EditText entryDate;
private SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
@sdanna
sdanna / activity_add_entry.xml
Created October 21, 2015 01:43
Material Design Date Entry
<android.support.design.widget.TextInputLayout
android:id="@+id/add_entry_date_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/add_entry_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
package com.stevendanna.navigation;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
@sdanna
sdanna / ClassFixture.cs
Created July 28, 2015 03:52
Generic XUnit ClassFixture
public class DatabaseFixture<T> : IDisposable
{
public DatabaseFixture<T>()
{
// Do something interesting with the Generic parameter like initialize
// a database dynamically based on generic type.
Db = new SqlConnection("MyConnectionString");
// ... initialize data in the test database ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using StructureMap;
namespace ConsoleApplication1
@sdanna
sdanna / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sdanna
sdanna / EmailConfig.cs
Last active August 29, 2015 14:08
web.config - Send email to directory
public class EmailConfig
{
public static void Configure()
{
#if(DEBUG)
// Allows for a good F5 from Visual Studio experience.
const string emailDropFolder = "C:\\Email-Drop\\";
if (!Directory.Exists(emailDropFolder)) Directory.CreateDirectory(emailDropFolder);
#endif
}