Skip to content

Instantly share code, notes, and snippets.

View makiftutuncu's full-sized avatar
💭
🤘🏻

Mehmet Akif Tütüncü makiftutuncu

💭
🤘🏻
View GitHub Profile

Keybase proof

I hereby claim:

  • I am makiftutuncu on github.
  • I am makiftutuncu (https://keybase.io/makiftutuncu) on keybase.
  • I have a public key whose fingerprint is E83C 323C 34DA DD70 97FB AB7A 3F26 DC07 5227 C356

To claim this, I am signing this object:

<!DOCTYPE html><html><body><h2>Privacy Policy</h2><p>Mehmet Akif Tütüncü built the Text Instead? app as an open source app. This SERVICE is provided by Mehmet Akif Tütüncü at no cost and is intended for use as is.</p><p>This page is used to inform website visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.</p><p>If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect are used for providing and improving the Service.I will not use or share your information with anyone except as described in this Privacy Policy.</p> <p>The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Text Instead?, unless otherwise defined in this Privacy Policy.</p><p><strong>Information Collection and Use</strong></p><p>For a better experience, while using our Service, I may require you to provide
@makiftutuncu
makiftutuncu / Model.scala
Created October 10, 2016 14:06
Model base and it's corresponding database access singleton for Play Framework 2.4+ using Errors
import javax.inject.Singleton
import com.mehmetakiftutuncu.errors.{Errors, Maybe}
trait Model {
val id: String
}
trait ModelSingleton[M <: Model] {
def get(id: String): Maybe[Option[M]]
@makiftutuncu
makiftutuncu / DistanceOfPointToLine.java
Created September 5, 2016 19:11
Calculates the distance of a location point to the line constructed by other 2 location points and checks whether or not the location point is close enough to the line to be on it
/* If the distance between location point and line is less than this, point is considered to be on the line */
public static final double POINT_DISTANCE_TO_LINE_THRESHOLD = 0.01;
/* Calculates the distance of a location point to the line constructed by other 2 location points */
public double distanceOfPointToTheLine(Location location, Location point1, Location point2) {
double x0 = location.getLatitude();
double y0 = location.getLongitude();
double x1 = point1.getLatitude();
double y1 = point1.getLongitude();
@makiftutuncu
makiftutuncu / Timer.scala
Last active August 24, 2016 07:01
A simple, straightforward timer implementation backed by Java 8 time APIs
import java.time.{Duration, Instant}
import java.util.UUID
import java.util.concurrent.atomic.AtomicReference
import java.util.function.UnaryOperator
object Timer {
private val map: AtomicReference[Map[String, Instant]] = new AtomicReference[Map[String, Instant]](Map.empty[String, Instant])
def start(key: String): Instant = {
val now: Instant = Instant.now
@makiftutuncu
makiftutuncu / GoingCrazyWithTypesAndFutures.scala
Created August 22, 2016 12:00
A Play controller to collect all districts of all cities of all countries of MuezzinAPI
def test: Action[AnyContent] = {
def countriesToCities(countries: List[Country]): Future[Maybe[Map[Country, List[City]]]] = {
val idToCountryMap: Map[Int, Country] = countries.map {
country: Country =>
country.id -> country
}.toMap
val futureMaybeCitiesList: List[Future[Maybe[List[City]]]] = countries.map {
country: Country =>
Thread.sleep(20)
@makiftutuncu
makiftutuncu / GetQuupNotifications.scala
Last active June 29, 2016 08:38
A draft for parsing notifications from new quup
sealed trait NotificationType {
val regex: Regex
}
object NotificationTypes {
case object EntryLike extends NotificationType {override val regex: Regex = """.+gönderini.+beğendi.*""".r}
case object CommentLike extends NotificationType {override val regex: Regex = """.+yorumunu.+beğendi.*""".r}
case object Comment extends NotificationType {override val regex: Regex = """.+yorum.+yaptı.*""".r}
case object Mention extends NotificationType {override val regex: Regex = """.+senden.+bahsetti.*""".r}
case object Message extends NotificationType {override val regex: Regex = """.+sana.+gönderdi.*""".r}
@makiftutuncu
makiftutuncu / PlayRoutesParser.scala
Created January 15, 2016 08:59
A small script to parse Play's routes file and genenrate Json string output
import scala.io._
case class Route(httpMethod: String, url: String, endpoint: Endpoint) {
def toJson = s"""{"httpMethod":"$httpMethod","url":"$url","endpoint":$endpoint}"""
override def toString = toJson
}
case class Endpoint(controllerPackage: String, controller: String, method: String, parameters: List[String]) {
def toJson = s"""{"controllerPackage":"$controllerPackage","controller":"$controller","method":"$method","parameters":${parameters.map(p => "\"" + p + "\"").mkString("[",",","]")}}"""
@makiftutuncu
makiftutuncu / helloworld.scala
Created January 27, 2014 12:12
Hello world!
println("Hello world!")
@makiftutuncu
makiftutuncu / ScalaDonguIfadeleri4.scala
Created December 15, 2015 21:13
Scala'da Döngü İfadeleri Yazımdaki Örnek 4
// Java
String[] isimler = new String[] {"Ali", "Veli", "Ahmet", "Hüseyin", "Akif"};
String[] secilenIsimler = new String[isimler.length];
int i = 0;
for (String isim : isimler) {
if (isim.startsWith("A") && isim.length > 3) {
System.out.println("Seçilen isim: " + isim);
secilenİsimler[i] = isim;
i++;