Skip to content

Instantly share code, notes, and snippets.

View christherama's full-sized avatar

Chris Ramacciotti christherama

View GitHub Profile
@christherama
christherama / build.gradle
Created December 19, 2016 00:34
Gradle build file including the passing of command line args to application's main method
group 'com.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
repositories {
mavenCentral()
@christherama
christherama / Gif.java
Last active May 17, 2021 07:55
These files demonstrate how to implement a custom Spring validator for a Gif entity that includes as a mapped property a Category entity.
/*
Notice the @Transient annotation on the MultipartFile field.
This means that the field value will NOT be persisted to the database.
*/
package com.teamtreehouse.giflib.model;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.*;
@christherama
christherama / workflow.yaml
Last active March 13, 2023 11:19
Using create-postgres-image
on: [pull_request]
jobs:
create-postgres-image:
permissions:
contents: read
packages: write
uses: christherama/create-postgres-image/.github/workflows/workflow.yaml@v0.0.1
with:
docker-registry: ghcr.io
@christherama
christherama / query.py
Last active July 20, 2023 15:11
Django query with aggregation
status_counts_by_month = (
Task.objects.filter(plan_id=plan_id, metric_type=metric_type, group_by_date__year=effective_year)
.annotate(
completed_on_time=Case(
When(completed_date__isnull=True, then=0),
When(completed_date__lte=F("due_date"), then=1),
default=0,
output_field=IntegerField(),
)
)