Skip to content

Instantly share code, notes, and snippets.

View Ntr0's full-sized avatar
💭
🤘

Christian Schulze-Wiehenbrauk Ntr0

💭
🤘
View GitHub Profile
-- The main select just gets _all_ records which have a relation to taxonomies via taxable_taxonomies
select d.id, d.name, tt.taxable_type, tt.taxonomy_id from domains as d left outer join taxable_taxonomies as tt on tt.taxable_id = d.id and tt.taxable_type = 'Domain' left outer join taxonomies as t on t.id = tt.taxonomy_id and t.type = 'Location';
id | name | taxable_type | taxonomy_id
----+--------------------+--------------+-------------
2 | four.example.com | Domain | 1
1 | three.example.com | Domain | 1
11 | one.example.com | Domain | 13
11 | one.example.com | Domain | 12
12 | two.example.com | Domain | 14
# test/controllers/api/v2/domains_controller_test.rb
# http://projects.theforeman.org/issues/19707
test "should get domains for searched location only" do
hg = FactoryGirl.create(:hostgroup, :id => domains(:yourdomain).id, :location_ids => [taxonomies(:location2).id])
taxonomies(:location2).domain_ids = [domains(:unuseddomain).id]
get :index, {:search => "location_id=#{taxonomies(:location2).id}" }
assert_response :success
assert_equal taxonomies(:location2).domains.length, assigns(:domains).length
assert_equal assigns(:domains), taxonomies(:location2).domains
end
@Ntr0
Ntr0 / linux_bridge.py
Created December 8, 2017 17:15 — forked from upa/LICENSE
Ansible Module for Linux Bridge and VLAN
#!/usr/bin/env python
#-*- coding: utf-8 -*-
DOCUMENTATION = '''
---
module: linux_bridge
short_description: Manage Linux bridges
requirements: [ brctl ]
description:
- Manage Linux bridges
@Ntr0
Ntr0 / keybase.md
Created November 7, 2018 18:33
keybase auth

Keybase proof

I hereby claim:

  • I am ntr0 on github.
  • I am ntr0 (https://keybase.io/ntr0) on keybase.
  • I have a public key ASDBinYTQCl73M4GJfB9xmZyj4i3LhQayd6oRiIWh_h_dQo

To claim this, I am signing this object: