Skip to content

Instantly share code, notes, and snippets.

@0guzhan
0guzhan / google_checkstyle_suppressions.xml
Created August 18, 2023 00:49
How to fully disable javadoc checking with checkstyle maven plugin?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<!-- Suppressions for Javadoc rules -->
<suppress checks="InvalidJavadocPosition" files="."/>
<suppress checks="JavadocTagContinuationIndentation" files="."/>
<suppress checks="SummaryJavadoc" files="."/>
<suppress checks="JavadocParagraph" files="."/>
@0guzhan
0guzhan / spring-el.java
Created April 14, 2020 07:07
spring expression language example
@Autowired
private Employee firstEmployee;
/*
name
#this.toString()
roles.?[level>7].![id]
roles.?[id>0].toString()
roles.![roleName]
roles.![{role_name:roleName,id:id}].toString()

void is not a type in java.

because void keyword in java tells the behaviour of java execution stack which is a completely empty stack at the end of void method execution (not returning a type). this yields a distinction between expressions and statements in java language. in contrary to java, in scala everything is expression thus always returns (or evaluates to) sth.

scala types

AnyVal: all primitive types + void (unit) AnyRef: all java ref (object) types + all scala ref types Any: AnyVal + AnyRef

@0guzhan
0guzhan / read_csv.py
Created November 19, 2018 22:20
read csv
import csv
def read_csv(path, num_lines = 10):
with open(path,"r") as f:
reader = csv.reader(f)
next(reader, None)
i = 0
for row in reader:
print(row)
i=i+1
@0guzhan
0guzhan / Test.java
Created June 13, 2018 00:27
Weighted Round Robin implementation
/*
* Copyright 2018 oguzhan acargil
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@0guzhan
0guzhan / gist:e50b7b43471ec7f82617e9f6a0f788cb
Created June 9, 2018 22:13
git init add origin set upstream pull push
git init .
git remote add origin git@bitbucket.org:0guzhan/review.git
git remote -v
git branch --set-upstream-to=origin/master master
git remote set-url origin git@bitbucket.org:0guzhan/review.git
@0guzhan
0guzhan / AuthenticateFilter.java
Created November 19, 2017 21:42
AuthenticateFilter for Dropwizard Restful Endpoint which simply checks authentication with filter HTTP Request
import org.apache.commons.lang3.StringUtils;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
@0guzhan
0guzhan / Bash File Testing
Created September 30, 2017 13:38
Bash File Testing
Bash File Testing
-b filename - Block special file
-c filename - Special character file
-d directoryname - Check for directory Existence
-e filename - Check for file existence, regardless of type (node, directory, socket, etc.)
-f filename - Check for regular file existence not a directory
-G filename - Check if file exists and is owned by effective group ID
-G filename set-group-id - True if file exists and is set-group-id
-k filename - Sticky bit
@0guzhan
0guzhan / create_schema.pl
Last active June 9, 2018 19:06
Mysql Database Schema SQL Generator e.g. [./create_schema.pl database_name username password]
#!/usr/bin/perl
use strict;
use warnings;
use feature qw/say/;
my $sql_create_database = <<'SQL_CREATE_DATABASE';
CREATE DATABASE IF NOT EXISTS database_name
DEFAULT CHARACTER SET = utf8mb4
DEFAULT COLLATE utf8mb4_unicode_ci;
@0guzhan
0guzhan / IntersectionOfCircles.java
Created April 20, 2017 11:32
Area of Intersection of Circles; given by coordinates and diameters
/**
* calculates area of intersections of circles
*
* @param x1,y1,r1 first circle
* @param x2,y2,r2 second circle
*/
public double solution(int x1, int y1, int r1, int x2, int y2, int r2) {
double sR1 = power(r1, 2);
double sR2 = power(r2, 2);
double d = distance(x1, y1, x2, y2);