Skip to content

Instantly share code, notes, and snippets.

View cyanglee's full-sized avatar

Kenneth Lee cyanglee

View GitHub Profile
@cyanglee
cyanglee / issue.md
Created January 6, 2020 03:18
Rails with Postgres 12 issue
  • Ran into an weird pg related issue:
.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pg-1.1.4/lib/pg.rb:56: [BUG] Segmentation fault at 0x0000000000000110
— Control frame information ———————————————————————
c:0071 p:—— s:0406 e:000405 CFUNC  :initialize
c:0070 p:—— s:0403 e:000402 CFUNC  :new
c:0069 p:0016 s:0398 e:000397 METHOD /Users/xxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pg-1.1.4/lib/pg.rb:56
c:0068 p:0107 s:0393 e:000392 METHOD /Users/xxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgres
@cyanglee
cyanglee / .rubocop.yml
Created May 11, 2019 10:27
Rubocup settings
AllCops:
TargetRubyVersion: 2.5
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
- 'railties/test/fixtures/tmp/**/*'
> bill = { name = "Gates", age = 57 }
{ name = "Gates", age = 57 } : { age : number, name : String }
> { bill | test = "123" }
-- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm
`bill` is being used in an unexpected way.
4| { bill | test = "123" }
^^^^
Based on its definition, `bill` has this type:
@cyanglee
cyanglee / 寶寶.js
Created April 29, 2016 10:34 — forked from DingWeizhe/寶寶.js
新增line的功能
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express'),
bodyParser = require('body-parser'),
request = require('request'),
crypto = require('crypto'),
FBToken = '',
port = 443,
options = {
@cyanglee
cyanglee / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function render_result(queryText) {
// Test if the broswer supports geolocation
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
// Get geolocation from the browser's location
latitude = position.coords.latitude;
longitude = position.coords.longitude;
@cyanglee
cyanglee / ruby_chef_install.sh
Last active December 20, 2015 02:09 — forked from codemis/ruby_chef_install.sh
ruby 2.0 on Ubuntu 12.10 x64
#!/usr/bin/env bash
sudo apt-get -y update
sudo apt-get -y install build-essential libyaml-dev zlib1g-dev openssl libssl-dev libreadline6-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xvzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
sudo ./configure --prefix=/usr/local
sudo make
sudo make install
@cyanglee
cyanglee / gist:5660276
Created May 28, 2013 03:02
lograge logs
11:00:31,840 INFO [wordsentry] (http-/0.0.0.0:8080-1) method=GET path=/admin/app_configs format=html controller=app_configs action=index status=200 duration=338.00 view=282.00
11:00:40,459 INFO [wordsentry] (http-/0.0.0.0:8080-2) method=GET path=/admin/users format=html controller=users action=index status=200 duration=579.00 view=491.00
11:00:54,061 INFO [wordsentry] (http-/0.0.0.0:8080-2) method=GET path=/admin/orgs format=html controller=orgs action=index status=200 duration=174.00 view=141.00
11:00:59,046 INFO [wordsentry] (http-/0.0.0.0:8080-1) method=GET path=/admin/reports format=html controller=reports action=index status=200 duration=301.00 view=299.00
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-TW:
errors:
messages:
expired: "已經過期,請重新申請一個"
not_found: "找不到"
already_confirmed: "已經驗證,請直接登入"
not_locked: "被鎖定了"
not_saved:
@cyanglee
cyanglee / gist:5617141
Created May 21, 2013 02:25
There are different ways to create recursive hash in ruby. I found two tricks from here: http://metaskills.net/2012/03/12/store-configurable-a-lesson-in-recursion-in-ruby/
# ruby recursive hash examples
# http://metaskills.net/2012/03/12/store-configurable-a-lesson-in-recursion-in-ruby/
# trick 1
class RecursiveHash < Hash
Recursive = lambda { |h,k| h[k] = h.class.new }
def initialize
super(&Recursive)
end
end