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 / 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 / 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 / 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 / your_model.rb
Created October 31, 2017 07:04
Rails pg jsonb column search method
# heading jsonb cloumn, and title a field inside jsonb search in jsonb
# heading: { title: "ABC" }
# For detail look at http://edgeguides.rubyonrails.org/active_record_postgresql.html#json-and-jsonb
def self.search(search)
q = "%#{search.downcase}%"
where("lower(heading ->> 'title') LIKE ?", q)
end
@leylaKapi
leylaKapi / bash.sh
Last active November 24, 2017 09:16
Using FactoryGirl in Rails Console
$ RAILS_ENV=test rails c
[1] pry(main)> FactoryGirl.find_definitions
# then we can use each test row code in rails console
@leylaKapi
leylaKapi / db.rake
Created December 27, 2017 11:38 — forked from bonkydog/db.rake
Fix 'ERROR: must be owner of extension plpgsql' complaints from Postgresql when dumping and reloading structure.sql
# Put this in your Rails app's lib/tasks directory
namespace :db do
desc "Fix 'ERROR: must be owner of extension plpgsql' complaints from Postgresql"
task :fix_psql_dump do |task|
filename = ENV['DB_STRUCTURE'] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "structure.sql")
sql = File.read(filename)
sql.sub!(/(CREATE EXTENSION IF NOT EXISTS plpgsql)/, '-- \1')
sql.sub!(/(COMMENT ON EXTENSION plpgsql)/, '-- \1')
File.open(filename, 'w') do |f|
f.write(sql)
@leylaKapi
leylaKapi / capybara cheat sheet
Created March 1, 2018 11:38 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@leylaKapi
leylaKapi / gist:cc0bd1e616a7cdf9e7aa8194fc87b18a
Created March 3, 2018 20:54 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@leylaKapi
leylaKapi / rspec_model_testing_template.rb
Created March 14, 2018 10:12 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@leylaKapi
leylaKapi / video-example.rb
Created May 2, 2018 08:35 — forked from arirusso/video-example.rb
ruby-processing: video processing example
#!/usr/bin/env ruby
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) with the video library
# use "rp5 unpack library" at a command line to install the video library, among others
# tested with Ruby 1.9.2
# video file: http://bit.ly/H5yBjK
class VideoTest < Processing::App