This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onOptionsItemSelected(final MenuItem item) | |
{ | |
final int itemId = item.getItemId(); | |
switch (itemId) | |
{ | |
case android.R.id.home: | |
// Action bar home button: go back | |
finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
module EnumUtil = | |
/// Return all values for an enumeration type | |
let EnumValues (enumType : Type) : seq<int> = | |
let values = Enum.GetValues enumType | |
let getValue (i : int) : int = downcast values.GetValue i | |
let lb = values.GetLowerBound 0 | |
let ub = values.GetUpperBound 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Bootstrap Template</title> | |
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app> | |
<head> | |
<meta charset="utf-8"> | |
<title>AngularJS Template</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-sanitize.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-animate.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-cookies.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app="formatterApp"> | |
<head> | |
<meta charset="utf-8"> | |
<title>JSON Reformatter</title> | |
<!-- | |
Copyright (c) 2014 Kristopher Johnson | |
Permission is hereby granted, free of charge, to any person obtaining |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: Due to bugs in the Angular/Karma generators, the Karma runner may not work correctly when following the | |
// steps given in yeoman_angular.sh. If that's the case, compare the contents of your test/karma.conf.js with | |
// this version, and edit yours as needed. | |
// Karma configuration | |
// http://karma-runner.github.io/0.12/config/configuration-file.html | |
// Generated on 2014-06-05 using | |
// generator-karma 0.8.1 | |
module.exports = function(config) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "A !|| B" returns unwrapped value of A if it is not nil, or B if it is | |
operator infix !|| { associativity left } | |
func !|| <T>(lhs: T?, rhs: T) -> T { | |
if let unwrappedValue = lhs { | |
return unwrappedValue; | |
} else { | |
return rhs; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wrap closure that will be evaluated only the first time force()/value is called. | |
// Subsequent calls will return the already-calculated value. | |
class Lazy<T> { | |
init(_ closure: () -> T) { | |
self.force = { [unowned self] in | |
let v = closure() | |
self.force = { return v } | |
return v | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit: https://twitter.com/eridius/status/474990322506670080 | |
func curry<A, B, C>(f: (A, B) -> C) -> A -> B -> C { | |
return { a in { b in f(a, b) } } | |
} | |
func curry<A, B, C, D>(f: (A, B, C) -> D) -> A -> B -> C -> D { | |
return { a in { b in { c in f(a, b, c) } } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (c) 2014 Kristopher Johnson | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: |