Skip to content

Instantly share code, notes, and snippets.

View leylaKapi's full-sized avatar
💭
I may be slow to respond.

Leyla Kapi Kurtul leylaKapi

💭
I may be slow to respond.
  • Hamburg / Germany
View GitHub Profile
@leylaKapi
leylaKapi / index.html.erb
Created October 2, 2017 14:10
Select-tag add link
<%= select_tag 'team_id', options_from_collection_for_select(@teams, "id", "name") %>
<script>
$(function(){
$('#team_id').bind('change', function () {
var url = "/Teamleader/" + $(this).val()
if (url) {
window.location.replace(url);
}
return false;
@leylaKapi
leylaKapi / spining.js
Created October 2, 2017 14:06
Spining loader ajax
function spining_calculator(target_div) {
if (target_div == ''){
var indicator = '<table id="indicator" style="width:100%;height:100%;" class="ajax_loading indicator_small"><tr><th style="text-align:center"><img src="/images/indicator-small.gif" /></th></tr></table>';
$('body').prepend(indicator);
} else {
var width = $(target_div).width();
var height = $(target_div).height();
var indicator = '<table id="indicator" style="width:'+width+'px; height:'+height+'px;" class="ajax_loading indicator_small"><tr><th style="text-align:center"><img src="/images/indicator-small.gif" /></th></tr></table>';
$(target_div).prepend(indicator);
}
@leylaKapi
leylaKapi / dev.rake
Last active October 2, 2017 14:04
Import datas with Rake in Rails
# For running this rake run "rails data:datas or rails data:seed"
def open_spreadsheet_data
Roo::Spreadsheet.open("#{Rails.root.to_s}/lib/data/datas.xlsx")
end
namespace :data do
task setup: [:environment] do
raise 'Nah, You are at production' if Rails.env.production?
@leylaKapi
leylaKapi / app.coffee
Created July 11, 2017 12:51
Add ancestry gem and nested categories list with js
$('.tree li').show()
$('.tree li').on 'click', (e) ->
children = $(this).find('> ul > li')
if children.is(':visible')
children.hide 'fast'
else
children.show 'fast'
e.stopPropagation()
return
return
@leylaKapi
leylaKapi / devise.tr.yml
Created April 24, 2017 14:38 — forked from cihad/devise.tr.yml
Turkish translations for Devise
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
tr:
devise:
confirmations:
confirmed: "Eposta adresiniz başırılı bir şekilde onaylandı."
send_instructions: "Bir kaç dakika içerisinde eposta adresinizi nasıl onaylayacağınız hakkında bir eposta alacaksınız."
send_paranoid_instructions: "Eğer eposta adresinizi veritabanımızda kayıtlı ise bir kaç dakika içerisinde eposta adresinizi nasıl onaylayacağınız hakkında bir eposta alacaksınız."
failure:
already_authenticated: "Zaten giriş yaptınız."
@leylaKapi
leylaKapi / trigger.rb
Created February 27, 2017 11:15
trigger
after_save :update_subtotal
def calc_subtotal
order_items.includes(:model).collect {|oi| oi.valid? ? (oi.unit_price.to_f) : 0}.sum
end
def update_subtotal
self.update_column(:subtotal, calc_subtotal)
end
@leylaKapi
leylaKapi / link.haml
Created February 27, 2017 11:15
Giving path to link_to with id
@leylaKapi
leylaKapi / dumb.sh
Created February 27, 2017 11:13
pg_dumb
psql asdf_development < /Users/johndoe/Desktop/db_dump.sql
@leylaKapi
leylaKapi / controller.rb
Created February 27, 2017 11:12
Filter according to categories
@models = Model.joins(:categories).where('categories.id = ?', @categories_id).order("created_at DESC").paginate(page: params[:page])
@leylaKapi
leylaKapi / info.md
Created February 27, 2017 11:11
Wordpress setup on Mac