Skip to content

Instantly share code, notes, and snippets.

Book book = new Book
{
Title = "Hit Refresh"
};
Book anotherBook = new Book
{
book.Title //CS1922: Collection initializer requires its type 'type' to implement System.Collections.IEnumerable.
};
@kmb385
kmb385 / Program.cs
Created January 13, 2022 15:19
C# Binary Search
int[] nums = { 33, 44, 55, 66, 77, 88, 99, 100 };
int index = BinarySearch(nums, 99);
Console.WriteLine(index);
int BinarySearch(int[] nums, int target)
{
int low = 0, high = nums.Length - 1;
@kmb385
kmb385 / Program.cs
Created January 13, 2022 07:48
C# QuickSort
int[] nums = { 23, 300, 2400, 2300, 100, 1, 10, 20, 15 };
QuickSort(nums, 0, nums.Length - 1);
Console.WriteLine(String.Join(",", nums));
void QuickSort(int[] nums, int low, int high)
{
if(low < high)
@kmb385
kmb385 / Program.cs
Last active January 13, 2022 07:41
C# Merge Sort
int[] nums = { 2323, 23, 200, 323, 20, 15 };
MergeSort(nums);
Console.WriteLine(String.Join(",", nums));
void MergeSort(int[] nums)
{
if(nums.Length < 2)
{
return;
@kmb385
kmb385 / Filter Offensive Tests
Created August 13, 2021 21:42
Filter offensive
package review;
import java.util.ArrayList;
import java.util.List;
public class Assessment {
public static void main(String[] args) {
List<Video> videos = new ArrayList<Video>(List.of(new Video("A", false), new Video("B", true), new Video("C", false)));
package review;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
public class Assessment {
public static int PATIENT_ID = 0;
public static int SSN_COLUMN = 0;
spring.datasource.driveClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/batch_repo
spring.datasource.username=batch_user
spring.datasource.password=password
spring.datasource.platform=mysql
spring.datasource.initialization-mode=always
spring.batch.initialize-schema=always
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE `batch_repo`.`BATCH_JOB_EXECUTION`,
`batch_repo`.`BATCH_JOB_EXECUTION_CONTEXT`,
`batch_repo`.`BATCH_JOB_EXECUTION_PARAMS`,
`batch_repo`.`BATCH_JOB_EXECUTION_SEQ`,
`batch_repo`.`BATCH_JOB_INSTANCE`,
`batch_repo`.`BATCH_JOB_SEQ`,
`batch_repo`.`BATCH_STEP_EXECUTION`,
`batch_repo`.`BATCH_STEP_EXECUTION_CONTEXT`,
`batch_repo`.`BATCH_STEP_EXECUTION_SEQ`;
package com.linkedin.batch;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.job.builder.FlowBuilder;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oreilly.mongo</groupId>
<artifactId>mongo-spring-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>4.2.1.RELEASE</spring.version>
<spring-data.version>Gosling-RELEASE</spring-data.version>
</properties>