Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@m0smith
m0smith / Student.java
Created January 27, 2024 22:59
Default Constructor example 3
class Student {
String name;
int age;
// A parameterized constructor
Student(String newName, int newAge) {
name = newName;
age = newAge;
}
}
@m0smith
m0smith / Book.java
Created January 27, 2024 22:57
Example 2 for Default Constructor
class Book {
String title;
// A no-argument constructor
Book() {
title = "Unknown";
}
}
public class Main {
@m0smith
m0smith / Bike.java
Created January 27, 2024 22:52
First example of a default constructor
class Bike {
int speed;
// Notice, no constructor is defined here
}
public class Main {
public static void main(String[] args) {
Bike myBike = new Bike();
System.out.println("Speed: " + myBike.speed); // Outputs: Speed: 0
@m0smith
m0smith / deployment.yml
Last active August 21, 2023 17:22
YAML fragment to add apply an existing OpenShift secret to a deployment when using the openshift maven plugin: oc:resource oc:apply
# Put this file in src/main/jkube
spec:
template:
spec:
containers:
- envFrom:
- secretRef:
name: my-secret
@m0smith
m0smith / json2csvwithheaders.sh
Created August 1, 2023 20:22
Converting JSON to CSV with headers
cat data.json | jq -r '["Name", "Email"], (.[] | [.name, .email]) | @csv'
@m0smith
m0smith / data.json
Created August 1, 2023 20:16
Example JSON data in a file
[
{
"name": "John Doe",
"age": 32,
"email": "john.doe@example.com"
},
{
"name": "Jane Smith",
"age": 28,
"email": "jane.smith@example.com"
# For macOS (using Homebrew)
brew install jq
# For Ubuntu/Debian Linux
sudo apt-get install jq
Foo:
Type: AWS::Serverless::Function
Properties:
Policies:
- AthenaQueryPolicy:
WorkGroupName:
primary
cd ~/annals/storm/
mkdir Storm202{0,1}
cat Storm\ 2020\ Transactions.csv | parallel --header : --pipe -N500000 'cat >Storm2020/Storm2020_{#}.csv'
cat Storm\ 2021\ Transactions.csv | parallel --header : --pipe -N500000 'cat >Storm2021/Storm2021_{#}.csv'
zip -r storm.zip Storm202[01]
cd ~/annals/storm/
mkdir Storm202{0,1}
cat Storm\ 2020\ Transactions.csv | parallel --header : --pipe -N500000 'cat >Storm2020/Storm2020_{#}.csv'
cat Storm\ 2021\ Transactions.csv | parallel --header : --pipe -N500000 'cat >Storm2021/Storm2021_{#}.csv'
zip -r storm.zip Storm202[01]