CSS ellipsis text

2018 07 05 No Comments

CSS3 gave us perfect property: text-overflow.
We have ability to cut off words.

In LESS there are many mixins I know. But I wanted to share my little mixin 😀

Use like this:


See the Pen RJmQXG by ozer (@ozer) on CodePen.

Also SASS version

@mixin ellipsis($line) {
	display: -webkit-box;
	-webkit-line-clamp: $line;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
@include ellipsis(2);

Ubuntu touchpad problem

2018 06 16 No Comments

When I install Kubuntu to my computer, unfortunately touchpad was not working. Tried a few ways and this way worked for me. (Xiaomi notebook pro)

sudo apt remove xserver-xorg-input-synaptics xserver-xorg-input-evdev
sudo apt install xserver-xorg-input-libinput

After then sudo vim /etc/X11/xorg.conf.d/30-touchpad.conf
Type these inside vim editor:

Section "InputClass"
    Identifier "touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"

And press ESC, then :wq


WordPress üyelere özel içerik için kısa kod

2018 06 07 No Comments

Bazen üyelik sistemi ile çalışan wordpress sitelerinde, site sahipleri sadece üye girişi yapan kullanıcılara özel içerik göstermek isteyebilir. Bunu için kısa kod kullanmak en mantıklısıdır.

Yazı içerisinde “ozel” kısa kodunu kullanarak bazı içerikleri gizleyebilirsiniz.

[ozel] indirme linkleri vs burada [/ozel] 

Kısa kodu aktif etmek için temanızın functions.php dosyasını açın ve


den sonra ekleyin:

function uye_ozel_shortcode($atts, $content = null) {

   if(is_user_logged_in()) {
     return $content;
   } else {
     return '<a class="giris-yap" href="'.wp_login_url( get_permalink() ).'">Bu içeriği görmek için giriş yapmalısınız..</a>';

add_shortcode('ozel', 'uye_ozel_shortcode');

Else bloğundan sonra içeriği düzenlemek size kalmış.

CSRF token with Selmer, Ring

2018 05 29 No Comments

Firstly install Selmer and Ring. Here are my project.clj

(defproject test "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :min-lein-version "2.0.0"
  :resource-paths ["public" "resources" "templates"]
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [compojure "1.5.1"]
                 [ring/ring-defaults "0.2.1"]
                 [mysql/mysql-connector-java "5.1.32"]
                 [yesql "0.5.3"]
                 [selmer "1.11.7"]
                 [org.clojure/tools.namespace "0.2.11"]
                 [proto-repl "0.3.1"]
                 [proto-repl-charts "0.3.1"]

  :plugins [[lein-ring "0.12.4"]]
  :ring {:handler test.handler/app}
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.0"]]}})

After that, create crsf-token as tag to use in selmer template engine.

Using Kemal CSRF handler with Crinja

2018 05 19 No Comments

I assume that you are using kemal, kemal-session and kemal-csrf. Require them and use add_handler to handle requests.

Default input name is authenticity_token so I used it.

require "kemal"
require "kemal-session"
require "kemal-csrf"

add_handler CSRF.new(
  allowed_methods: ["GET", "HEAD", "OPTIONS", "TRACE"],
  error: ->myerrorhandler(HTTP::Server::Context)

def myerrorhandler(env)
  if env.request.headers["Content-Type"]? == "application/json"
    {"error" => "csrf error"}.to_json
    "No token!"


Create a function to use it in templates

Crystal seo friendly url

2018 05 19 No Comments

Maybe someone needs it.

Markdown render in template side with Crinja – Crystal

2018 05 18 No Comments

In crystal ecr templates, we can use render markdown like this: <%= Markdown.to_html("# text") %>

But with crinja we cant do it as I see.

So I created template function.

require "markdown"

c = Crinja.new
c.loader = Crinja::Loader::FileSystemLoader.new("src/views/")

c.functions << Crinja.function({:str => ""}, :Markdown) do

To use it:

{{ Markdown("# title")  | safe}}


Crystal code reloading with nodemon

2018 05 14 No Comments

I saw this solution in this link.

First install nodemon globally:
npm i -g nodemon

After install, run your main cr file:
nodemon --exec "crystal run" src/{YOUR_MAIN_FILE}.cr

In my computer (macbook early 2015 8/128), it works faster than sentry.

Ps: Nodemon doesn’t works with ecr templates, sentry works.

Godot Engine key-value based database

2018 04 22 No Comments

Here are you simple database for Godot Engine. I got inspired from this answer at godotengine qa.

func SetValue(key, value):
	var data = {key: value}
	var file = File.new()
	if file.open("user://shared_pref.sav", File.WRITE) != 0:
	    print("Error opening file")
	# Save the dictionary as JSON (or whatever you want, JSON is convenient here because it's built-in)

func GetValue(key):
	var file = File.new()
	if not file.file_exists("user://shared_pref.sav"):
	    print("No file saved!")
	# Open existing file
	if file.open("user://shared_pref.sav", File.READ) != 0:
	    print("Error opening file")
	# Get the data
	var data = {}
	data = parse_json(file.get_line())
	if data.has(key):
		return data[key]
		print(key, " [key] not assigned in saved_data")
		return 0

Save above file named Database.gd … To use it import like this:

onready var Database = preload("res://Database.gd").new()

Here you are ready to save values to database:

Database.SetValue("SomeValue", "test")
var foo = Database.GetValue("SomeValue")


Godot Engine Android testing & publishing

2018 04 21 No Comments

I am writing these informations as a note. If I forgot the steps, I can look at this page..

Firstly Editor > Manage Export Templates. Download and install, that’s it.

Secondly in Editor > Editor Settings set these values:
– adb (download android studio and set path)
– jarsigner executable (download from version 8 and set jarsigner path)
– debug keystore

Last step is to set window.

Go Project > Project Settings > Display > Window
– Scroll to Strect section
– Set mode 2d(2d because I am working on 2d game)
– Aspect=expand.

So you can test now on your phone and see result.

To run game on your phone, enable usb debugging in your phone and connect usb cable. There will be Android icon next to Play Scene button.

More Godot Engine posts will be came..
<3 Godot Engine Happy coding.