Skip to content

Instantly share code, notes, and snippets.

View achimmihca's full-sized avatar

Andreas achimmihca

View GitHub Profile
@koraktor
koraktor / RepositoryImpl.java
Created August 18, 2017 10:43
Combining specifications and projections in Spring Data JPA
public class RepositoryImpl<T, ID extends Serializable>
extends SimpleJpaRepository<T, ID extends Serializable> {
ProjectionFactory projectionFactory;
public <P> List<P> findProjected(Specification<?> spec, Sort sort, Class<P> projectionClass) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> tupleQuery = criteriaBuilder.createTupleQuery();
Root<?> root = tupleQuery.from(getDomainClass());
@justincoh
justincoh / handshake_country_language_locale_codes.json
Last active June 23, 2023 20:45
A more robust listing of country codes, language codes, date formats, etc
[
{
"ISO 3166 Country Code": "sqi",
"ISO639-2 Country Code": "AL",
"Country": "Albania",
"ISO639-2 Lang": "sq",
"Locale": "sq-AL",
"Language": "Albanian",
"Date Format": "yyyy-MM-dd",
},
@openroomxyz
openroomxyz / LoadTexture2dFromFile.cs
Created April 6, 2020 11:26
Unity : How to load Texture2d from file (PNG) on disk?
private static Texture2D LoadPNG(string filePath)
{
Texture2D tex = null;
byte[] fileData;
if (System.IO.File.Exists(filePath))
{
fileData = System.IO.File.ReadAllBytes(filePath);
tex = new Texture2D(2, 2);