Skip to content

Instantly share code, notes, and snippets.

View christherama's full-sized avatar

Chris Ramacciotti christherama

View GitHub Profile
@christherama
christherama / ArrayList.java
Last active November 2, 2016 15:53
Add an element to the ArrayList
public class ArrayList<E> {
transient Object[] elementData;
private static final int DEFAULT_CAPACITY = 10; // (4)
private static final Object[] EMPTY_ELEMENTDATA = {};
private int size;
public boolean add(E e) {
ensureCapacityInternal(size + 1); // (1)
elementData[size++] = e; // (6)
return true;
@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 / 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(),
)
)
@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