Skip to content

Instantly share code, notes, and snippets.

View chadwilken's full-sized avatar

Chad Wilken chadwilken

View GitHub Profile
@chadwilken
chadwilken / project.rb
Created July 20, 2017 18:42
The Project JSON Partial
json = {
id: project.id,
name: project.name,
street_address_1: project.street_address_1,
street_address_2: project.street_address_2,
city: project.city,
state: project.state,
postal_code: project.postal_code,
country: project.country,
company_id: project.company_id,
can_view_users_photos = current_user.has_permission?(Permission::VIEW_USERS_PHOTOS)
@projects.map do |project|
Rails.cache.fetch(['v1', "can-view-all-photo-#{can_view_users_photos}", 'recent', project]) do
render partial: 'v1/locations/recent/project', locals: { project: project, can_view_users: can_view_users_photos }
end
end
@chadwilken
chadwilken / example-request.json
Created August 23, 2017 17:10
An example request body for creating a project
{
"project": {
"name": "The Office",
"address": {
"street_address_1": "3793 West Trickery Rd",
"city": "Lincoln",
"state": "NE",
"postal_code": "68512",
"country": "US"
},
{
"parser": "babel-eslint",
"extends": "airbnb",
"globals": {
"alert": true,
"document": true,
"FormData": true,
"window": true
},
"plugins": [
import { Controller } from 'stimulus';
export default class extends Controller {
static targets = ['message']
connect() {
this.timeout = setTimeout(this.closeFlash, 2500);
}
disconnect() {
module ReactHelper
def react_component(name, props: {}, html_class: nil)
content_tag(
'div',
nil,
class: html_class,
data: { controller: 'react', 'react-component' => name, 'react-props' => react_props(props) }
)
end
@chadwilken
chadwilken / CreateProject.cs
Last active April 19, 2018 19:49
CompanyCam .NET Examples
// Set secret key for your application globally
CompanyCamConfiguration.SetSecretKey("YourSecretKey");
var requestOptions = new CompanyCamRequestOptions
{
ApiKey = "CompanyApiKey",
UserEmailAddress = "UserPerformingAction"
};
var projectService = new ProjectService(requestOptions);
var project = projectService.Create(new Project
// project will be https://docs.companycam.com/#the-project-object
const project = await fetch ('https://api.companycam.com/v2/projects', {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer {access_token},
'X-CompanyCam-User': '{user_email}',
'X-CompanyCam-Secret': '{application_secret}'
},
@chadwilken
chadwilken / collection.md
Last active July 9, 2018 15:20
Photos To Web Payload

Photo Collection

Attribute Type Description
version int The version of the photo collection, will increase as modifications are made
collectionUUID string A unique identifier for the collection, it will remain the same with subsequent versions
title string The title of the collection
subtitle string The subtitle of the collection
description string The long description explaining the project
categories Array A list of categories the user applied to the collection
@chadwilken
chadwilken / puma.service
Created August 23, 2018 20:38
Puma Systemd service
[Unit]
Description=Puma HTTP Server for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
After=network.target
Requires=puma.socket
[Service]
Type=simple
User=<%= fetch(:deploy_user) %>
Environment=RAILS_ENV=<%= fetch(:rails_env) %>