Skip to content

Instantly share code, notes, and snippets.

View lasershow's full-sized avatar

Akihiro Shimizu lasershow

View GitHub Profile
@lasershow
lasershow / file0.txt
Last active January 27, 2016 01:46
【Ruby・Rails】三項演算子(条件演算子)を使ってif文をスリムに書こう! ref: http://qiita.com/lasershow/items/160c854e4256ba596ec5
def add_button_name
if controller.action_name == 'show'
"コメントを投稿する"
else
"コメントを更新する"
end
end
@lasershow
lasershow / file0.js
Created January 26, 2016 16:17
jquery.tile.jsをrails + coffeeで使用する方法 ref: http://qiita.com/lasershow/items/20393fa26cabee974672
(function($) {
$.fn.tile = function(columns) {
var tiles, $tile, max, c, h, remove, s = document.body.style, a = ["height"],
last = this.length - 1;
if(!columns) columns = this.length;
remove = s.removeProperty ? s.removeProperty : s.removeAttribute;
return this.each(function() {
remove.apply(this.style, a);
}).each(function(i) {
c = i % columns;
@lasershow
lasershow / file0.txt
Created January 29, 2016 14:14
あれっ?降順ってASC?DESC?そんな時は、reverse_orderを使ってみましょう! ref: http://qiita.com/lasershow/items/5bcefcbd6ae86a5ff202
pry(main)> Comment.all
=>
[#<
id: 1,
content: "あ">,
#<
id: 2,
content: "い">,
#<
id: 3,
@lasershow
lasershow / file0.txt
Last active February 17, 2016 06:32
【初心者】railsのvalidatesのpresenceでエラーメッセージが重複するのを防ぐ方法 ref: http://qiita.com/lasershow/items/0229855720aaf2be5fc8
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: {with: VALID_EMAIL_REGEX}
require 'mechanize'
require 'spreadsheet'
# http://qiita.com/shizuma/items/d04facaa732f606f00ff
agent = Mechanize.new
page = agent.get('https://www.tripadvisor.jp/Restaurants-g298158-Chiba_Chiba_Prefecture_Kanto.html')
anker_tags = page.search('.shortSellDetails h3 a')
restaurants_url = []
@lasershow
lasershow / blog.py
Created January 24, 2017 01:40
Python基礎 〜関数まで 超簡易ブログ機能
def create(blogs):
print('1:ブログを作成する')
blog = {}
print(blog)
blog["title"] = input()
blog["content"] = input()
print(blog)
blogs.append(blog)
blogs = []
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lasershow
lasershow / classify_junk_mail.ipynb
Last active September 4, 2017 08:29
迷惑メール 回答例
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
The MIT License (MIT)
Copyright (c) [2015] [chuck]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.