Skip to content

Instantly share code, notes, and snippets.

View SeyZ's full-sized avatar

Sandro Munda SeyZ

View GitHub Profile
@SeyZ
SeyZ / gist:4ac7702fa0b37ba0083c8441b87c19d0
Last active March 28, 2019 13:45
Forest Admin Toolbelt example
#!/bin/bash
FOREST_EMAIL=sandro@munda.me FOREST_PASSWORD=lumberjack forest login
envsecret=$(forest environments:create -p 82 -n TestFeatureX -u http://my.application.com:4294 | awk '$1 ~ /^ *FOREST_ENV_SECRET/ {print $2}')
forest schema:apply --secret $envsecret
envid=$(forest environments:list -p 82 | awk '$2 ~ "TestFeatureX" {print $1; exit}')
forest environments:copy-layout 2200 $envid -p 82 --force
@SeyZ
SeyZ / command line
Last active August 30, 2018 09:02
doc-lumber-deploy-to-heroku-dump-database
# Export my data from my local database
pg_dump -h localhost -p 5446 -U forest forest_live_demo_rails --no-owner --no-acl -f database.sql
# Import my data to the Heroku database
heroku pg:psql DATABASE_URL --app lumber-deploy-to-production < database.sql
@SeyZ
SeyZ / git push heroku master
Created August 30, 2018 08:50
doc-lumber-deploy-to-heroku
seyz:LumberDeployToProdExample/ (master) $ git push heroku master
Counting objects: 25, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (25/25), 21.56 KiB | 5.39 MiB/s, done.
Total 25 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
@SeyZ
SeyZ / 1-forest-products.js
Last active July 7, 2018 08:48
doc-lumber-how-to-import-data
/* /forest/products.js */
const Liana = require('forest-express-sequelize');
const models = require('../models');
Liana.collection('products', {
actions: [{
name: 'Import data',
endpoint: '/forest/products/actions/import-data',
type: 'global',
fields: [{
@SeyZ
SeyZ / forest-companies.js
Created June 12, 2018 14:48
doc-lumber-restrict-search-on-specific-fields
/* /forest/companies.js */
const Liana = require('forest-express-sequelize');
Liana.collection('companies', {
searchFields: ['name', 'industry'],
});
@SeyZ
SeyZ / config-initializers-forest_liana.rb
Created March 27, 2018 10:38
doc-lumber-integrations-stripe
# /config/initializers/forest_liana.rb
ForestLiana.env_secret = Rails.application.secrets.forest_env_secret
ForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret
ForestLiana.integrations = {
stripe: {
api_key: ENV['STRIPE_SECRET_KEY'],
mapping: 'Customer.stripe_id'
}
}
@SeyZ
SeyZ / 1 format
Created March 27, 2018 10:33
doc-lumber-smart-chart-time-based
// The value MUST be formatted like this.
{
value: [{
label: <string> ,
values: { value: <number> }
}, {
label: <string> ,
values: { value: <number> }
}, …]
}
@SeyZ
SeyZ / 1 format
Created March 27, 2018 10:24
doc-lumber-smart-chart-repartition
// The value MUST be formatted like this.
{
value: [{
key: <string> ,
value: <number>
}, {
key: <string> ,
value: <number>
}, …]
}
@SeyZ
SeyZ / 1 format
Created March 27, 2018 10:14
doc-lumber-smart-chart-value
// The value MUST be formatted like this.
{
value: <number>
}
@SeyZ
SeyZ / lib-forest_liana-collections-product.rb
Created March 27, 2018 09:55
doc-rails-smart-segment
# /lib/forest_liana/collections/product.rb
class Forest::Product
include ForestLiana::Collection
collection :Product
segment 'Bestsellers' do
products = ActiveRecord::Base.connection.execute("""
SELECT products.id, COUNT(orders.*)
FROM products