Skip to content

Instantly share code, notes, and snippets.

View foucist's full-sized avatar

James Robey foucist

View GitHub Profile
class PhotosController < ApplicationController
respond_to :json
def index
respond_with load_photos
end
def show
respond_with load_photo
end
scope :either, ->(a, b){where(where(profile: a, block: b).where(profile: b, block: a).where_values.instance_exec { self[0].and(self[1]).or(self[2].and(self[3]))})}
# or
def self.either(a,b)
pb = Arel::Table.new(:profile_blocks)
pb[:profile_id].eq(a).and(pb[:block_id].eq(b)).or(pb[:profile_id].eq(b).and(pb[:block_id].eq(a)))
end
class Message < Base
belongs_to :attachable, polymorphic: true, foreign_type: :attachable_class
end
class Photo < Base
has_many :messages, as: :attachable, foreign_type: :attachable_class
end
class Message::Collection::Count
MENU_TYPES = %w{message gift flirt access_granted request_access}
def initialize(profile)
@profile = profile
end
def self.unread_counts_for(profile)
new(profile).unread_message_counts
end
class Price
def pricer(quantity, item)
end
case
when setpoint
SetPrice
when bulkpoint
BulkPrice
end
@foucist
foucist / RiotControl.js
Created November 18, 2016 13:56 — forked from assertnotnull/RiotControl.js
Autonomous riot.js paging
var RiotControl = {
_stores: [],
addStore: function(store) {
this._stores.push(store);
}
};
['on','one','off','trigger'].forEach(function(api){
RiotControl[api] = function() {
var args = [].slice.call(arguments);
@foucist
foucist / css-grid.md
Created April 7, 2018 12:33 — forked from osban/css-grid.md
css grid summary

Grid

  1. define grid container element (parent) -> display: grid
  2. set its column and row sizes -> grid-template-columns and grid-template-rows
  3. place grid items (children) into the grid -> grid-column and grid-row
  • children are only the direct descendants of the parent element
  • Note: column, float, clear, and vertical-align have no effect on a grid container.

Terminology

@foucist
foucist / index.html
Last active September 20, 2018 07:20
preliminary clone of angular.io with tailwind css
<!doctype html>
<html lang="en">
<head>
<title>Tailwind Starter Template</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<div class="container bg-blue-dark">
<div class="bg-blue flex items-center py-1">
@foucist
foucist / urlsafari
Created October 16, 2018 13:46 — forked from kshiteesh/urlsafari
This AppleScript saves all the tabs open in all Safari windows to a Markdown file.
(*
Export All Safari Tabs in All Open Windows to a Markdown File
July 13, 2015
// SCRIPT PAGE
http://hegde.me/urlsafari
// ORIGINAL SCRIPT ON WHICH THIS SCRIPT IS BUILT
http://veritrope.com/code/export-all-safari-tabs-to-a-text-file
@foucist
foucist / keybase.md
Created September 12, 2019 02:31
kb

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: