Skip to content

Instantly share code, notes, and snippets.

View 3den's full-sized avatar

Marcelo Eden 3den

View GitHub Profile
#What’s the issue with the controller code below? How would you fix/improve it?
class CommentsController < ApplicationController
...
def users_comments
posts = Post.all
comments = posts.map(&:comments).flatten
@user_comments = comments.select do |comment|
comment.author.username == params[:username]
@3den
3den / client_node_Handler.js
Created April 20, 2017 18:44
React On Rails Node Server
/* eslint-disable no-console */
module.exports = class Handler {
constructor() {
this.queue = [];
this.initialized = false;
}
initialize() {
if (this.initialized) {
@3den
3den / database.yaml
Last active April 14, 2017 19:10
Docs DB
# database tables schema
tables:
# "Guide" rows will be created with data from swagger, we can have rake task that loads data from swagger after deploy
# we shoulda have a uniq validation of [slug, vertion] so we can select/display diferent version for a guide.
# need to figure out how to index the guides nested in a way that makes it possible to find guides based on resources and endpoints
guides: we search in this level...
description: 'bla bla bla...' #swagger.info.description #
title: 'Salesforce' #swagger.info.title
slug: 'sobject' #id of the swagger config
version: '1.0.0' # swagger.info.version # 1.0.0
@3den
3den / resources.js
Last active April 4, 2017 04:26 — forked from rsukale/swagger-parsing-format.js
resources.js
navigation: [
{title: 'Account', href: '/guides/account'},
...
],
resources: {
'account': {
title: 'Account', // x-sfdc-ia-resource
slug: 'account', // parameterized version of x-sfdc-ia-resource
endpoints: [
$static-font-path: "salesforce-lightning-design-system/assets/fonts/webfonts/";
// This is needed to fix loadind fonts
// https://github.com/salesforce-ux/design-system/issues/71
@mixin set-slds-font($name, $file, $weight: 400, $style: normal) {
@font-face {
font-family: $name;
font-weight: $weight;
font-style: $style;
src: font-files(
# this command syncs docker-machine running on virtualbox with your current working directory
# replace "/app/user" with the path where your app will be mounted on the docker container
# $(pwd) this will return your local folder and sync it with the equivalen folder on virtualbox
# make sure to stop your docker-machine before running this command
VBoxManage sharedfolder add DFC --automount --name /app/user --hostpath $(pwd)
@3den
3den / mini-framework.js
Last active April 2, 2016 10:05 — forked from anonymous/index.html
basic Rx "state$"
// **** Framework *******
function createAction(reducer) {
const subject$ = new Rx.Subject();
return {
dispatch (payload) {
subject$.onNext(payload);
},
stream$: subject$.map((payload) => {
import {setEntries, next, vote, INITIAL_STATE} from './core';
// This is a polymorphic aprorach that conforms to all SOLID principles
// This reduce is much simpler and will raise an error if the action does not exist
export default function reducer(state = INITIAL_STATE, action) {
return action.handler(state, action.payload);
}
// This is the defensive version of the reducer above, if there is an error returns the current state
export default function maybeReducer(state = INITIAL_STATE, action) {
@3den
3den / SassMeister-input.scss
Created December 11, 2014 18:05
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
$list: (
(a: ".div-1", b: (a: 100px)),
(a: ".div-2", b: (a: 200px)),
(a: ".div-3", b: (a: 300px)),
);
@3den
3den / gist:8409977
Created January 13, 2014 23:15
hanoi
class Tower
def initialize(name, rings)
@name = name
@rings = rings
end
def to_s
@name
end