{ "url": "https://api.github.com/gists/a06926360de8edf108be8591368ce1fb", "forks_url": "https://api.github.com/gists/a06926360de8edf108be8591368ce1fb/forks", "commits_url": "https://api.github.com/gists/a06926360de8edf108be8591368ce1fb/commits", "id": "a06926360de8edf108be8591368ce1fb", "node_id": "G_kwDNRzjaACBhMDY5MjYzNjBkZThlZGYxMDhiZTg1OTEzNjhjZTFmYg", "git_pull_url": "https://gist.github.com/a06926360de8edf108be8591368ce1fb.git", "git_push_url": "https://gist.github.com/a06926360de8edf108be8591368ce1fb.git", "html_url": "https://gist.github.com/dkam/a06926360de8edf108be8591368ce1fb", "files": { "ipv6_in_sqlite.rb": { "filename": "ipv6_in_sqlite.rb", "type": "application/x-ruby", "language": "Ruby", "raw_url": "https://gist.githubusercontent.com/dkam/a06926360de8edf108be8591368ce1fb/raw/13e47fb5d3c981a407997fc954b163fe50a37b45/ipv6_in_sqlite.rb", "size": 373, "truncated": false, "content": "class IpAddress < ApplicationRecord\n def ipv6\n (ipv6_high << 64) | ipv6_low\n end\n\n def ipv6=(addr)\n self.ipv6_high = addr >> 64\n self.ipv6_low = addr & 0xFFFFFFFFFFFFFFFF\n end\n\n def self.ipv6_range(start_ip, end_ip)\n where(ipv6_high: start_ip >> 64..end_ip >> 64)\n .where(ipv6_low: start_ip & 0xFFFFFFFFFFFFFFFF..end_ip & 0xFFFFFFFFFFFFFFFF)\n end\nend", "encoding": "utf-8" } }, "public": false, "created_at": "2025-01-25T00:07:09Z", "updated_at": "2025-01-25T00:07:09Z", "description": "Store IPv6 address in SQLite, via Active Record", "comments": 0, "user": null, "comments_enabled": true, "comments_url": "https://api.github.com/gists/a06926360de8edf108be8591368ce1fb/comments", "owner": { "login": "dkam", "id": 18232, "node_id": "MDQ6VXNlcjE4MjMy", "avatar_url": "https://avatars.githubusercontent.com/u/18232?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dkam", "html_url": "https://github.com/dkam", "followers_url": "https://api.github.com/users/dkam/followers", "following_url": "https://api.github.com/users/dkam/following{/other_user}", "gists_url": "https://api.github.com/users/dkam/gists{/gist_id}", "starred_url": "https://api.github.com/users/dkam/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dkam/subscriptions", "organizations_url": "https://api.github.com/users/dkam/orgs", "repos_url": "https://api.github.com/users/dkam/repos", "events_url": "https://api.github.com/users/dkam/events{/privacy}", "received_events_url": "https://api.github.com/users/dkam/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "forks": [ ], "history": [ { "user": { "login": "dkam", "id": 18232, "node_id": "MDQ6VXNlcjE4MjMy", "avatar_url": "https://avatars.githubusercontent.com/u/18232?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dkam", "html_url": "https://github.com/dkam", "followers_url": "https://api.github.com/users/dkam/followers", "following_url": "https://api.github.com/users/dkam/following{/other_user}", "gists_url": "https://api.github.com/users/dkam/gists{/gist_id}", "starred_url": "https://api.github.com/users/dkam/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dkam/subscriptions", "organizations_url": "https://api.github.com/users/dkam/orgs", "repos_url": "https://api.github.com/users/dkam/repos", "events_url": "https://api.github.com/users/dkam/events{/privacy}", "received_events_url": "https://api.github.com/users/dkam/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "version": "7f52a7373edd4cbf186162dc71444792eece75b3", "committed_at": "2025-01-25T00:07:09Z", "change_status": { "total": 15, "additions": 15, "deletions": 0 }, "url": "https://api.github.com/gists/a06926360de8edf108be8591368ce1fb/7f52a7373edd4cbf186162dc71444792eece75b3" } ], "truncated": false }