Skip to content

Instantly share code, notes, and snippets.


Chris Ramacciotti christherama

View GitHub Profile
christherama / build.gradle
Created Dec 19, 2016
Gradle build file including the passing of command line args to application's main method
View build.gradle
group 'com.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
repositories {
christherama /
Last active Nov 2, 2016
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 /
Last active Nov 2, 2016
An empty ArrayList is created
public class ArrayList<E> {
transient Object[] elementData; // (1)
private static final Object[] EMPTY_ELEMENTDATA = {}; // (3)
public ArrayList() {
this.elementData = EMPTY_ELEMENTDATA; // (2)
christherama / listobject.c
Created Oct 27, 2016
CPython List Implementation
View listobject.c
/* List object implementation */
#include "Python.h"
#include <stddef.h>
#include <sys/types.h> /* For size_t */
christherama /
Last active Oct 26, 2016
OpenJDK 8 ArrayList
package java.util;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
public class ArrayList<E> extends AbstractList<E>
implements List<E>, RandomAccess, Cloneable,
private static final long serialVersionUID = 8683452581122892189L;
christherama /
Last active May 17, 2021
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 / httpget.vb
Created May 13, 2015
Visual Basic function to fetch a response from a web server
View httpget.vb
''' <summary>
''' Fetches the response from a website or server, with the provided URL
''' </summary>
Public Shared Function HttpGet(ByVal url As String) As String
' Create the HTTP request
Dim req As HttpWebRequest = HttpWebRequest.Create(url)
' Open a connection (stream) using the request
Dim stream As Stream = req.GetResponse.GetResponseStream()
christherama / displayobject.vb
Created May 8, 2015
Procedures for displaying an object in a well-formatted manner. This is helpful for debugging in the console.
View displayobject.vb
''' <summary>
''' Displays an object's properties in a well-formatted manner.
''' </summary>
''' <param name="obj">Object to display</param>
''' <param name="numTabs">Number of tabs to prefix the object's properties with</param>
Public Shared Sub DisplayObject(ByVal obj As Object, Optional ByVal numTabs As Integer = -1)
' Define non-special types
Dim types As String() = {"String", "Boolean", "DateTime", "Integer", "Double", "Long"}
' Get the properties of this object
christherama / deserialize.vb
Last active Aug 29, 2015
Deserializing JSON Data in Visual Basic
View deserialize.vb
''' <summary>
''' Deserializes a JSON string to an object of the specified type
''' </summary>
''' <typeparam name="T">Class of object this JSON data will be mapped to</typeparam>
''' <param name="jsonString">String containing the JSON to be deserialized</param>
''' <returns>Mapped object (of type T) representing the JSON data</returns>
Public Shared Function DeserializeJson(Of T)(ByVal jsonString As String) As T
Dim serializer As New DataContractJsonSerializer(GetType(T))
Dim memStream As New MemoryStream(Encoding.UTF8.GetBytes(jsonString))
Dim obj As T = DirectCast(serializer.ReadObject(memStream), T)
christherama / response.json
Last active Aug 29, 2015
ForecastIO Response Sample
View response.json
"summary":"Mostly Cloudy",