Skip to content

Instantly share code, notes, and snippets.

@Dylan0203
Dylan0203 / base_controller.rb
Created August 23, 2017 03:28 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@Dylan0203
Dylan0203 / coffeescript.coffee
Created July 20, 2017 05:09
Prevent Enter to submit form
$(document).ready ->
$('form').on 'keypress', (e) ->
if e.keyCode == 13
return false
@Dylan0203
Dylan0203 / text.md
Created June 28, 2017 06:50
Bundle or compile problems
gem install eventmachine -v '1.0.8' -- --with-cppflags=-I/usr/local/opt/openssl/include
@Dylan0203
Dylan0203 / readme.md
Last active June 1, 2017 12:46
升級openssl ubuntu 14.04
@Dylan0203
Dylan0203 / fuckup.md
Last active May 18, 2017 08:46
亂搞 local ssl

要用rails 5 的 puma 跑ssl 首先會碰到一個問題

新版的 mac os 好像用了openssl然後之前用homebrew裝的openssl就不能用了,

keg-only 就是不幫你連起來,你也不要連,會壞掉

裝了之後在termal打的指令都是用系統內建版本在執行

但是你可以用brew的版本compile一些需要build local的gem

found solution on the link below

SlatherOrg/slather#227

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/dylan/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri
/Users/dylan/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20170419-54813-jzpam3.rb extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
@Dylan0203
Dylan0203 / library_not_found_for_lssl.md
Last active April 20, 2017 07:41
gem install mysql2

while fixing termainal-notifier, I excute gem clean --force and now need to bundle on every project

Then I ran into a problem while install mysql2

 ~/Projects  gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.
@Dylan0203
Dylan0203 / text.txt
Created April 19, 2017 11:35
VS code crash report
Process: Electron [42482]
Path: /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Identifier: com.microsoft.VSCode
Version: 1.11.2 (1.11.2)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Electron [42482]
User ID: 501
Date/Time: 2017-04-19 19:34:20.179 +0800
@Dylan0203
Dylan0203 / what-i-did.md
Created April 19, 2017 08:26
Error Double initialize Json while Guard
16:06:51 - INFO - LiveReload is waiting for a browser to connect.
16:06:51 - INFO - Guard::RSpec is running
16:06:51 - INFO - Guard is now watching at '/Users/dylan/Projects/TargetGlobal'
[1] guard(main)>
16:06:57 - INFO - Run all
16:06:57 - INFO - Running all specs
/Users/dylan/.rbenv/versions/2.3.3/lib/ruby/2.3.0/json/version.rb:4: warning: already initialized constant JSON::VERSION
/Users/dylan/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-2.0.2/lib/json/version.rb:4: warning: previous definition of VERSION was here
/Users/dylan/.rbenv/versions/2.3.3/lib/ruby/2.3.0/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
@Dylan0203
Dylan0203 / what-i-did.md
Created April 19, 2017 08:24
Error Terminal-notifier in Guard

gem uninstall terminal-notifier

brew uninstall terminal-notifier

brew install terminal-notifier