Skip to content

Instantly share code, notes, and snippets.

@hechien
hechien / webpacker_rails.md
Created August 23, 2020 02:40 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
@hechien
hechien / 20150731014159_create_no_id_models.rb
Created August 18, 2020 09:01 — forked from bunyan/20150731014159_create_no_id_models.rb
Rails 4.2: composite_primary_keys 8.1.0 and activerecord-sqlserver-adapter 4.2.4 generating wrong SQL on some queries
class CreateNoIdModels < ActiveRecord::Migration
def change
create_table :no_id_models, id: false do |t|
t.integer :pk1
t.integer :pk2
end
end
end
@hechien
hechien / rails_webpacker_bootstrap_expose_jquery.md
Created April 30, 2019 14:26 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
set daemon 20
set logfile syslog facility log_daemon
set mailserver smtp.gmail.com port 587
username "ERROR-EMAIL-ADDRESS" password "PASSWORD"
using tlsv1
with timeout 30 seconds
set alert ERROR-EMAIL-ADDRESS
set httpd port 2812 and
@hechien
hechien / Capistrano 3.md
Last active August 29, 2015 14:26 — forked from stevenyap/Capistrano 3.md
Capistrano 3 Setup

This guide explains the way to setup a production server using Capistrano.

Setup Capistrano on LOCAL

  • Capistrano is a development gem which assist the developer to run commands on the production server (something like a Heroku toolbelt)
  • Hence, it is installed and configured on developer's computer
# Gemfile

# Use Capistrano for deployment
###
# helper_name:inspect_helper
# author: Whien_Liou
# time: 2014/07/23
#
# usage
# 請在增加 config/initializers/inspect_helper.rb
# 加入下列幾行代碼
# 在 controller 使用
#

專案名稱: Rails新手村網站

主旨:收集 Rails 有用 Link

基本功能

@hechien
hechien / Gemfile
Created December 29, 2013 13:52 — forked from ronny/Gemfile
source :rubygems
# Turbolinks and jQuery.turbolinks without Rails dependencies
gem 'turbolinks', :git => 'git://github.com/ronny/turbolinks.git', :branch => 'lite'
gem 'jquery-turbolinks', :git => 'git://github.com/ronny/jquery.turbolinks.git', :branch => 'lite'
@hechien
hechien / gist:8168407
Created December 29, 2013 07:47 — forked from xdite/gist:8168404
class Link < ActiveRecord::Base
scope :recent, order("id DESC")
belongs_to :post
belongs_to :user
belongs_to :group

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter