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
// Bad | |
public static final int MARITAL_SINGLE = 1; | |
public static final int MARITAL_MARRIED = 2; | |
public static final int MARITAL_DISVORCED = 3; | |
public static final int MARITAL_WIDOW = 4; | |
public static final String MARITAL_SINGLE_NAME = "Single"; | |
public static final String MARITAL_MARRIED_NAME = "Married"; | |
public static final String MARITAL_DISVORCED_NAME = "Disvorced"; | |
public static final String MARITAL_WIDOW_NAME = "Widow[er]"; |
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
// Bad | |
public List<Employee> getEmployeesByManager(Employee manager){ | |
String sql = "SELECT e FROM Employee e WHERE e.manager = :manager"; | |
Query query = entityManager.createQuery(sql); | |
query.setParameter(...); | |
return query.getResultList(); // Warning "unchecked" | |
} | |
// Good | |
TypedQuery<Employee> query = entityManager.createQuery(sql, Employee.class); |
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
// Bad | |
public Employee getSingleEmployee(params...){ | |
String sql = ...; | |
TypedQuery<Employee> query = entityManager.createQuery(sql, Employee.class); | |
query.setParameter(...); | |
List<Employee> list = query.getResultList(); // can load more than one result | |
if (list == null || list.isEmpty()) { | |
return null; |
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
// Bad | |
if (foo !== undefined && foo != null && foo != '') { | |
// do something... | |
} | |
// Good | |
if (foo) { | |
// do something... | |
} | |
// will evaluate to true if value is not: |
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
// Bad | |
if (data.selected == true){ | |
// do staff | |
} | |
if (data.selected != true){ | |
// do staff | |
} | |
// Good | |
if ( data ) { |
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
/** | |
* @file A sample file demo about JSDoc | |
* @author dungdm93 | |
* @since 2016-05-26 | |
*/ | |
/** | |
* Person entity class | |
* @class | |
*/ |
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
ALTER TABLE revinfo | |
AUTO_INCREMENT = 3; | |
INSERT INTO revinfo | |
(REV, REVTSTMP) | |
VALUES (2, 146613965300); | |
UPDATE revinfo | |
SET REV = REV + 1 | |
WHERE REVTSTMP > 1466139651507 |
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> | |
<head lang="en"> | |
<meta charset="utf-8"> | |
<title>Egghead Videos</title> | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.css"> | |
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script> | |
<script type="text/javascript" src="main.js"></script> | |
</head> | |
<body ng-app="app" scope="{{$id}}"> |
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
var app = angular.module("app", ["ngRoute"]); | |
app.config(function ($routeProvider) { | |
$routeProvider | |
.when('/', { | |
templateUrl: "app.html", | |
controller: "ViewCtrl", | |
resolve: { | |
first: function () { | |
return "Hello world"; |
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
$("input").on("invalid", function(e) { | |
if (this.validity.valueMissing){ | |
this.setCustomValidity("valueMissing"); | |
} | |
if (this.validity.tooShort){ | |
this.setCustomValidity("tooShort"); | |
} | |
// .... more custom message here. | |
}); | |
$("input").on("input", function(e) { |
OlderNewer