Skip to content

Instantly share code, notes, and snippets.

View XeeD's full-sized avatar

Lukáš Voda XeeD

View GitHub Profile

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@XeeD
XeeD / .gitconfig
Last active February 9, 2018 14:19
[color]
ui = auto
[core]
editor = vim
autocrlf = false
whitespace = space-before-tab,cr-at-eol
excludesfile = ~/.gitignore_global
trustctime = false
mergeoptions = --no-edit
[alias]
[1] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> create(:line_item)
(0.1ms) SAVEPOINT active_record_1
SQL (0.5ms) INSERT INTO "spree_users" ("authentication_token", "created_at", "email", "login", "updated_at") VALUES (?, ?, ?, ?, ?) [["authentication_token", "xxxx14028747076021xxxxxxxxxxxxx"], ["created_at", "2014-06-15 23:25:07.770910"], ["email", "[email protected]"], ["login", "[email protected]"], ["updated_at", "2014-06-15 23:25:07.770910"]]
(0.1ms) RELEASE SAVEPOINT active_record_1
Spree::Country Load (0.2ms) SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."numcode" = 840 LIMIT 1
(0.1ms) SAVEPOINT active_record_1
SQL (1.0ms) INSERT INTO "spree_countries" ("iso", "iso3", "iso_name", "name", "numcode", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["iso", "US"], ["iso3", "USA"], ["iso_name", "UNITED STATES"], ["name", "United States of America"], ["numcode", 840], ["updated_at", "2014-06-15 23:25:07.843809"]]
(0.1ms) RELEASE SAVE
@Genkilabs
Genkilabs / any_controller.rb
Last active August 31, 2020 14:45
Rails 4 Ransacker to build subquery for searching across multiple fields in multiple polymorphic classes.
#This is how it might be used. Create your instance which could be polymorphic or just a class.
#Search using the predicate 'in' because the subquery find_term will return an ID of every record that matches.
@profile_instance = either a PetProfile or an OwnerProfile
@profile_instance.search( { :find_term_in => "has fleas", :other_ransack_term_eq => "foobar" } ).results()
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
@pbojinov
pbojinov / README.md
Last active January 31, 2025 05:04
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@kesor
kesor / an upstart unicorn.conf
Last active February 9, 2022 09:20
Unicorn that receives USR2 signal on upstart's "stop unicorn", but also allows upstart to respawn it when for some reason it crashed on its own.
# unicorn
description "unicorn ruby app server"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
env WORKDIR=/data
env PIDFILE=/data/tmp/pids/unicorn.pid
env CFGFILE=/data/config/unicorn.rb
@cheeaun
cheeaun / js-error-logging-services.md
Last active October 24, 2024 17:13
JavaScript error logging services