Skip to content

Instantly share code, notes, and snippets.

@seoyoochan
seoyoochan / rails http status codes
Created February 9, 2016 08:50 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@seoyoochan
seoyoochan / install_packages.md
Last active May 2, 2016 05:21
Install Essential Atom Packages and Themes

apm install advanced-open-file atom-beautify atom-pair autoclose-html autocomplete-html-entities autocomplete-ruby autoprefixer dash emmet environment linter linter-eslint linter-jscs merge-conflicts react redux-snippets go-plus file-icons

@seoyoochan
seoyoochan / vim-movment.txt
Created May 1, 2016 02:20
Vim: Movement Commands
// http://vim.wikia.com/wiki/Moving_around
e
Move to the end of a word.
w
Move forward to the beginning of a word.
3w
Move forward three words.
W
Move forward a WORD (any non-whitespace characters).
@seoyoochan
seoyoochan / ES6-TDZ-explain.txt
Created April 30, 2016 19:44
ES6 TDZ(Temporary Dead Zone)
The w in the w + 1 default value expression looks for w in the formal parameters' scope,
but does not find it, so the outer scope's w is used.
Next, The x in the x + 1 default value expression finds x in the formal parameters' scope,
and luckily x has already been initialized, so the assignment to y works fine.
However, the z in z + 1 finds z as a not-yet-initialized-at-that-moment parameter variable,
so it never tries to find the z from the outer scope.
As we mentioned in the "let Declarations" section earlier in this chapter,
ES6 has a TDZ, which prevents a variable from being accessed in its uninitialized state.
@seoyoochan
seoyoochan / git_rename.sh
Created March 25, 2016 12:21
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@seoyoochan
seoyoochan / README.md
Created March 19, 2016 09:20 — forked from mik01aj/README.md
How to use Tether with React

Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.

But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body).

That's why I created 2 helpers to use Tether with React.

The first one, TetheredElement is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.

The second one, TetherTarget is a React component and it uses TetheredElement to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:

@seoyoochan
seoyoochan / I18nRuntimePlugin.js
Created March 17, 2016 22:36 — forked from valscion/I18nRuntimePlugin.js
Venuu I18n Webpack integration
var ConstDependency = require('webpack/lib/dependencies/ConstDependency');
var NullFactory = require('webpack/lib/NullFactory');
var _ = require('lodash');
function I18nRuntimePlugin(options) {
options = options || {};
this.functionNames = options.functionNames || ['I18n.t', 'I18n.translate'];
this.translationsPlaceholder = options.translationsPlaceholder || 'I18N_RUNTIME_TRANSLATIONS';
this.fullTranslations = options.fullTranslations || {};
}
@seoyoochan
seoyoochan / README.md
Created March 17, 2016 22:31 — forked from jhilden/README.md
Setup for using i18n-js together with react-rails i18n-js for server side prerendering

When using react-rails for an internationalized app it makes a lot of sense to use i18n-js for translations, so that you can reuse the the strings from your rails app's .yml files (and all the tooling & services that exist around that).

When you use the prerender feature of react-rails you face 2 problems:

  • The first is that translation.js & i18n.js from i18n-js need to be loaded inside the server-side JS prerendering processes, which is achieved by loading them inside the components.js.
  • The second problem is the server processes need to be aware of the current locale of each HTTP request. This is done by adding a custom renderer and using the before_render hook to configure i18n-js accordingly for each render call.
@seoyoochan
seoyoochan / largest
Last active February 13, 2016 00:21
Return the largest int from an array of numerical strings
#! /usr/bin/env ruby
# Author: Yoochan Seo
# Email: supergnee@gmail.com
# If you want this program executable,
# `chmod 755 largest`
=begin
./largest 99, 997, 101, 2, 33 # execute this program and pass your value
@seoyoochan
seoyoochan / rspec_model_testing_template.rb
Created February 6, 2016 05:38 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: