Skip to content

Instantly share code, notes, and snippets.

View run26kimo's full-sized avatar
👋
Hello ~

RichKe run26kimo

👋
Hello ~
  • Taipei, Taiwan
View GitHub Profile
@run26kimo
run26kimo / Gemfile
Created May 11, 2018 08:03
Ruby AWS cloudwatch put log event example
gem 'aws-sdk-cloudwatchlogs'
@run26kimo
run26kimo / rspec_model_testing_template.rb
Created June 19, 2017 04:24 — 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:
@run26kimo
run26kimo / .rubocop.yml
Created February 9, 2017 02:29
rubocop setting
AllCops:
TargetRubyVersion: 2.2
Exclude:
- db/schema.rb
# Relaxed.Ruby.Style
Style/Alias:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylealias
@run26kimo
run26kimo / index.html
Created November 14, 2016 06:44 — forked from anonymous/index.html
Capture FB Reactions count and show them on webpage
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My FB Reactions Page</title>
<style>
html {
box-sizing: border-box;
width: 100%;
@run26kimo
run26kimo / parse_instagram_hashtag_image.rb
Created October 6, 2016 04:33
Parse instagram hashtag image
hashtag = 'car'
url = "https://www.instagram.com/explore/tags/#{hashtag}/"
page = HTTParty.get(url)
body = Nokogiri::HTML.parse(page.body, nil, 'utf-8').text
reg = /display_src\": \"(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})\"}/
images = body.scan(reg).map{|s| s[0] }
@run26kimo
run26kimo / docker-compose.yml
Last active September 20, 2016 12:39
Mac use install elastic search by docker, use docker-compose version 2
version: '2'
services:
elasticsearch:
image: elasticsearch:2.1.2
ports:
- "9201:9200"
- "9301:9300"
volumes:
- "$PWD/esdata/plugins:/usr/share/elasticsearch/plugins"
- "$PWD/esdata:/usr/share/elasticsearch/data"
@run26kimo
run26kimo / rgb_to_lab.js
Created September 6, 2016 16:37 — forked from kfitfk/rgb_to_lab.js
Convert RGB color to CIE LAB color
function rgbToXyz(r, g, b) {
r /= 255
g /= 255
b /= 255
if (r > 0.04045) r = Math.pow(((r + 0.055) / 1.055), 2.4)
else r = r / 12.92
if (g > 0.04045) g = Math.pow(((g + 0.055) / 1.055), 2.4)
else g = g / 12.92
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@run26kimo
run26kimo / Gemfile
Last active March 15, 2016 03:07 — forked from zealot128/crawler.rb
Web Crawler Helper class based upon Poltergeist (PhantomJS).Using Capybara as framework for building webcrawlers is surprisingly convenient
gem 'capybara'
gem 'poltergeist'
<script type="text/javascript" src="http://run26kimo.github.io/we-are-g0v/FileSaver.js"></script>
<script type="text/javascript" src="http://run26kimo.github.io/we-are-g0v/filer.min.js"></script>
<script type="text/javascript">
function download(){
blob = Util.dataURLToBlob(getBase64());
saveAs(blob,'cover.png')
}
</script>