This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tetromino for Idiots | |
# By Al Sweigart [email protected] | |
# http://inventwithpython.com/pygame | |
# Released under a "Simplified BSD" license | |
import random, time, pygame, sys | |
from pygame.locals import * | |
偵數 = 25 | |
視窗寬度 = 640 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def main(): | |
print(__doc__) | |
排假(1, True) | |
排假(2, True) | |
排假(3) | |
排假(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
列出巴斯卡三角形() | |
畫出二項分佈() | |
畫出巴松分佈() | |
def 列出巴斯卡三角形(): | |
Z=[[bCoef(n,k) for k in range(n+1)] for n in range(20)] | |
for z in Z: print(z) |
NewerOlder