If your computer has OSX 10.11 El Capitan, and try to create middleman project then write bundle to install gems. But you can get

1
2
3
4
5
6
Installing eventmachine 1.0.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
In file included from binder.cpp:20:
./project.h:116:10 fatal error: 'openssl/ssl.h' file not found
include <openssl/ssl.h>
1 error generated

like above error. You have to solve problem with openssl . For fix it ;

1
brew link openssl --force

then you can run bundle now. For detail about this problem please look at this link

I hope helped to you .

Sometimes while you are adding bootstrap to your rails app, you can getting some problem on javascript side. In this article I try to explain how we can fix active class to navbar . For fixing, you can write in helper active_class method like below

1
2
3
4
5
module ApplicationHelper
  def active_class(link_path)
    current_page?(link_path) ? 'active' : ""
  end
end
  • rake db:migrate for an existing model

Firstly I created new rails app, after that created several models, or you make some changes on your model manually(wrong way), while you are running rake db:migrate getting error for an existing model in your app. For fix that issue you can write,

1
rake db:schema:load

or

1
2
3
4
5
rake db:drop
rake db:create
rake db:migrate
rake db:schema:dump
rake db:text:prepare

App engine ve PHP

Uzun zamandır ingilizce olarak yazdığım yazılara ufak bir ara verip, türkçe yazılar paylaşmaya çalışacağım. Tabi amaç dile yatırım yapmak, neyse lafı daha fazla uzatmadan biz konumuza dönelim. Bu yazımda, App engine ile PhpStorm üzerinde nasıl çalışır, nasıl proje oluşturulur ve nasıl deploy edilir işlemlerinden bahsetmeye çalışacağım.

Google App Engine

Öncelikle herhangi bir google hesabınızla Google App engine sisteme giriş yapmanız, hesabınız yoksada basit bir google hesabı oluşturmanız gerekmekte, siz hesabı oluşturduktan sonra google size ücretsiz 25 repoluk bir sistem oluşturuyor. Giriş yaptığınız sistemden öncelikle bir proje oluşturuyorsunuz. Sistemde proje oluştururken dikkat etmeniz gereken nokta Application Identifier kısmı zira burda aslında sayfanızın url kısmını belirlemiş oluyorsunuz (proje_id.appspot.com). Tabi belirledikten sonra daha önce böyle bir adres kullanılmışmı diye kontrol etmeniz gerekmektedir, yoksa projeyi oluşturamıyorsunuz.

Ardından localinizde PhpStorm’u çalıştırıp, Create New Project kısmından yeni bir proje oluşturup,

1
2
3
Project name: blog-leylakapi
Location: /Workspace/PhpstormProjects/blog-leylakapi
Project type: App engine Project

kısımlarını girdikten sonra, Phpstorm sizden

1
2
3
Application ID: blog-leylakapi
SDK directory: /home/leylakapi/google_appengine
Python executable: /usr/bin/python

How to fix N+1 query in Rails ?

I try to explain fix N+1 on example. Let’s start, firstly, in your rails application, you created association between user and user_profile models like below :

1
2
3
class User < ActiveRecord::Base
   has_one :profile, class_name: 'UserProfile'
end

and

1
2
3
class UserProfile < ActiveRecord::Base
  belongs_to :user
end

Use getExtra and putExtra

You want to get some information like name, surname, email when user login on Android, and show on second activity these information , we can use getExtra and putExtra . There are a lot of method for getting information from first to second activity, I try to explain getting with getExtra and putExtra on getting user name and surname to show second activity, let ’s start,

  • Firstly I created two label(TextView) for definition to name and surname and EditText for enter name and surname to users on activity_main.xml,

  • Then we created new class under src folder and under the package name SecondActivity.java, and under the /res/layout/ folder created secondactivity.xml .

  • For definite and connect between main and second activity open AndroidManifest.xml and create new activity for second .

1
2
3
4
5
6
7
8
9
<activity
    android:name=".SecondActivity"
    android:label="Second Activity"
    >
    <intent-filter >
        <action android:name="com.example.package_path.SecondActivity"/>
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Method for go previous activity

If you make connection between first and second activity, this means, you can go to from first activity to second activity but you can not return to previous page, for return to first page, we can use very common method, onBackPressed().

Where you want to use button for return from second to first, open your secondactivity.xml

1
2
3
4
5
<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="ReturnHome"
    android:text="Return Previous Page" />

Fix date/time in menu bar

If you are update or upgrade your pc, you can getting error about menu bar for date – time missing . For fixing this bug, you should write below commands step by step ,

  • Re-install indicator-datetime run ,
1
$ sudo apt-get install indicator-datetime

Uzun zamandır düşündüğüm bloguma türkçe destek eklemekti. Bunun nedeni ise birçok yabancı konunun (yazılım anlamında) türkçe desteğinin olmamasıdır. Umarım faydalı olur.

Teşekkür ederim.

I want to sticker notes for my pc, when I search about it, I found sticky notes for Ubuntu 13.10 . This notes provide to reminder of something like a agenda, when you wrote some notes inside, you see always the notes. If you want to add sticker notes you can use below command.

1
$ sudo add-apt-repository ppa:umang/indicator-stickynotes