Skip to content

Instantly share code, notes, and snippets.

View xirukitepe's full-sized avatar
🙈
See No Evil

Shi xirukitepe

🙈
See No Evil
View GitHub Profile
@xirukitepe
xirukitepe / xiruki.conf
Created September 7, 2013 04:02
Apache configuration file for MAC OSX
<Directory "/Users/xiruki/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Ensemblist::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
@xirukitepe
xirukitepe / zsh.md
Last active August 29, 2015 14:20 — forked from tsabat/zsh.md
@xirukitepe
xirukitepe / capybara cheat sheet
Created April 20, 2016 02:27 — 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')
@xirukitepe
xirukitepe / friendly_urls.markdown
Created June 2, 2016 00:19 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

curl -XGET http://localhost:9200/store_development_products/_search -d '
{
"aggs": {
"category_ids": {
"terms": {
"field": "root_category_ids",
"size": 1000
},
"aggs" : {
"by_product_type": {
@xirukitepe
xirukitepe / for_lcl_query
Created August 13, 2020 01:43
SQL Query for LCL hire rate analysis
EXPLAIN for: SELECT `jobs`.* FROM `jobs` INNER JOIN `bids` ON `bids`.`job_id` = `jobs`.`id` INNER JOIN `suburbs` ON `suburbs`.`id` = `jobs`.`suburb_id` WHERE (jobs.status NOT IN ('drafted','rejected') AND (jobs.status = 'stopped' OR bidding_closes_on < DATE(CURRENT_TIMESTAMP + INTERVAL 10 HOUR))) AND (DATE(jobs.created_at) >= '2020-06-09') AND (suburbs.region IN ('Sydney','Melbourne','Brisbane')) GROUP BY bids.job_id HAVING (count(bids.job_id) >= 1) ORDER BY jobs.id desc