Skip to content

Instantly share code, notes, and snippets.

View westonal's full-sized avatar

Alan Evans westonal

View GitHub Profile
@westonal
westonal / SaltShaker.java
Last active August 29, 2015 14:14
Salt shaker - Salt generator using secure random
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.security.SecureRandom;
public final class SaltShaker {
public static void main(String[] args) {
final byte[] data = new byte[20];
@westonal
westonal / useful.gradle
Last active August 29, 2015 14:14
gradle android signing and other useful configs
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.package.app"
minSdkVersion 16
targetSdkVersion 19
@westonal
westonal / ReverseStringTests.cs
Last active August 29, 2015 14:19
Reverse string...
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;
using System.Collections.Generic;
namespace ReverseString
{
[TestClass]
public class ReverseStringTests
@westonal
westonal / ExampleSpockSpec.groovy
Last active August 29, 2015 14:22
Groovy Spock Specification Tests
import spock.lang.*
@Unroll
class ExampleSpockSpec extends Specification {
def "max of #a and #b is #c"() {
expect:
Math.max(a, b) == c
where:
@westonal
westonal / cordic_tests.c
Last active August 29, 2015 14:22
CORDIC
/*
============================================================================
Name : SinCosProject.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
@westonal
westonal / gist:78bf91deab8e2f0dbd30
Created June 15, 2015 16:08
Sin cos using series
/*
============================================================================
Name : SinCosProject.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
@westonal
westonal / AssertImmutableTests.cs
Last active August 29, 2015 14:23
C# Test for immutable
using System;
using System.Linq;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ImmutableTests
{
[TestClass]
public class AssertImmutableTests
{
@westonal
westonal / Examples
Created June 26, 2015 09:29
Specs from fields
public readonly object Spec = "Public spec field"
.Assert(() => Assert.Pass("It works!"));
private object Spec2 = "Private spec field"
.Assert(() => Assert.Pass("It works!"));
private object Spec3 = new[]
{
"Collection spec field"
.Assert(() => Assert.Pass("It works!")),
// add this to the general build.gradle, not in the subproject's build.gradle
// improved version of Xavier's tip http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.
// usage example default, preDex will be enabled: gradle clean build
// usage example disabling preDex: gradle clean build -PpreDexEnable=false
// preDexEnable parameter's value can be set as property of Continuous Integration build config
// this is the main difference from Xavier's workaround where he doing only hasProperty check
project.ext {
if (project.hasProperty('preDexEnable')) {
@westonal
westonal / AddPropertyToJsonOnSerialize.cs
Created July 6, 2015 10:59
Add a property to Json on serialize
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NUnit.Framework;
namespace AddToJsonPoco
{
[TestFixture]
public class AddPropertyToJsonOnSerialize