Skip to content

Instantly share code, notes, and snippets.

View 0guzhan's full-sized avatar

Oguzhan Acargil 0guzhan

  • Amsterdam
View GitHub Profile
@0guzhan
0guzhan / gist:e50b7b43471ec7f82617e9f6a0f788cb
Created June 9, 2018 22:13
git init add origin set upstream pull push
git init .
git remote add origin [email protected]:0guzhan/review.git
git remote -v
git branch --set-upstream-to=origin/master master
git remote set-url origin [email protected]: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);
@0guzhan
0guzhan / mysql_docker.sh
Created February 17, 2017 20:15
I short listed how to run mysql docker container and some docker management commands on linux.
# running mysql docker container with port forwarding and setup root password
# while forwarding port right side is container port and left side is host port e.g. -p 80:5000
sudo docker run --name demo-mysql-server2 -e MYSQL_ROOT_PASSWORD=password -d -p=3306:3306 mysql/mysql-server:5.7
# docker-proxy process allocates port 3306 to forward traffic to container
sudo netstat -tulpn | grep 3306
sudo docker port demo-mysql-server2
# starting container
@0guzhan
0guzhan / Edge.java
Created December 30, 2016 11:07
Directed Graph Implementation in Java
/*
* Copyright 2016 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 / PostOrderDFS.java
Created December 29, 2016 12:34
Simulating output of recursive depth-first-search traversal on graph with using iterative (non-recursive) approach.
Stack<Vertex<T>> frontiers = new Stack<>();
root.markFrontier();
frontiers.push(root);
FRONTIERS:
while (!frontiers.isEmpty()) {
Vertex<T> current = frontiers.pop();
List<Vertex<T>> successors = current.getSuccessors();
for (Vertex<T> successor : successors) {
if (successor.isUndiscovered()) {
@0guzhan
0guzhan / CalculateOverallRatesFromUserRates.java
Created December 28, 2016 08:24
Calculate user preferences of each fruits in fiven sample. Then, filter fruits which have certain rate level or more and sort them according to rate levels in reverse of natural order.
/*
* Copyright 2016 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 / FindMostVisitedDateInterval.java
Created December 28, 2016 07:23
Algorithm takes checkin-checkout records to find the most visited date interval and how many visitors in this interval visited.
/*
* Copyright 2016 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