Skip to content

Instantly share code, notes, and snippets.

Roger Wang roger35972134

Block or report user

Report or block roger35972134

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Currency_controller.rb
class CurrencyController < ApplicationController
require 'line/bot'
def client
@client ||= Line::Bot::Client.new { |config|
config.channel_secret = ENV["LINE_CHANNEL_SECRET"] # Your Channel secret
config.channel_token = ENV["LINE_CHANNEL_TOKEN"] # Your Channel token
}
end
View Currency.rb
class Currency < ActiveRecord::Base
require 'open-uri'
def self.get_currency
begin
books = Nokogiri::HTML(open("https://www.coingecko.com/en"))
name = []
abbreviation = []
rate = []
exchange = []
View Leetcode_3_3:Accepted.rb
def length_of_longest_substring(s)
max = 0
start_index = -1
char_to_index_map = {}
s.chars.each_with_index do |c, i|
if current_index = char_to_index_map[c] and current_index > start_index # if current_index != nil
start_index = current_index
end
View Leetcode_3_2:time_limit.rb
# @param {String} s
# @return {Integer}
def length_of_longest_substring(s)
max = 0
for i in 0..s.length-1
check = Array.new(256, false)
for j in i..s.length-1
index = s[j].ord
if check[index] == false
@roger35972134
roger35972134 / Leetcode_3:time_limit.rb
Created Oct 11, 2017
Leetcode 3. Longest Substring Without Repeating Characters, but it failed by Submission Result: Time Limit Exceeded
View Leetcode_3:time_limit.rb
# @param {String} s
# @return {Integer}
# ----------time limit-------------
def length_of_longest_substring(s)
longest_length = 0
for i in 0..s.length-1
check = []
for j in i..s.length-1
unless check.include? s[j]
check.push s[j]
@roger35972134
roger35972134 / udn_news_crawler.rb
Last active Sep 27, 2017
crawler preparation for NEWS analysis
View udn_news_crawler.rb
require 'nokogiri'
require 'open-uri'
# Let's try to fetch and parse HTML document
books = Nokogiri::HTML(open('https://udn.com/rank/pv/2/0/1'))
news = []
i = 0
View pygame_new_version
# Tetromino for Idiots
# By Al Sweigart al@inventwithpython.com
# http://inventwithpython.com/pygame
# Released under a "Simplified BSD" license
import random, time, pygame, sys
from pygame.locals import *
偵數 = 25
視窗寬度 = 640
View python_hw4
from matplotlib import pyplot
from collections import namedtuple
from pprint import pprint as pp
from math import floor
#由於有點摸不著頭緒,所以參考了一下同學的程式碼,我下次會更多自己的想法
Stem = namedtuple('Stem', 'data, leafdigits')
data0 = Stem((4285,564,1278,205,3920,
2066,604,209,602,1379,
2584,14,349,3770,99,
View python_hw3
import itertools
def main():
print(__doc__)
排假(1, True)
排假(2, True)
排假(3)
排假(4)
@roger35972134
roger35972134 / python_hw2
Created May 11, 2015
第二次python作業
View python_hw2
def main():
列出巴斯卡三角形()
畫出二項分佈()
畫出巴松分佈()
def 列出巴斯卡三角形():
Z=[[bCoef(n,k) for k in range(n+1)] for n in range(20)]
for z in Z: print(z)
You can’t perform that action at this time.