Skip to content

Instantly share code, notes, and snippets.

View isuke's full-sized avatar
🎵
Listening to music, and coding

FUJIYAMA Isuke isuke

🎵
Listening to music, and coding
View GitHub Profile
require 'thread'
THREAD_NUM = 4
list = ['*',
'_*',
'__*',
'___*',
'____*',
'_____*',
(1..50).map { ('a'..'z').to_a[rand(26)] }.join
<template lang="pug">
ul.pagination
li.item: a.link.first(@click.prevent="$emit('first-page')") First
li.item: a.link.prev(@click.prevent="$emit('prev-page')") Prev
li.item(v-for="i in pageTotal")
a.link.num(
@click.prevent="$emit('set-current-page', i)",
:class="i == currentPage ? '-current' : ''"
) {{i}}
li.item: a.link.next(@click.prevent="$emit('next-page')") Next
@isuke
isuke / database_rewinder.rb
Last active January 2, 2018 09:02
The best of database_cleaner setting
RSpec.configure do |config|
# Use transactions by default
config.before :each do
DatabaseRewinder.strategy = :transaction
end
# Switch to truncation for javascript tests, but *only clean used tables*
config.before :each, js: true do
DatabaseRewinder.strategy = :truncation, {pre_count: true}
end
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
# ver: 0.9.6
# rubocop: v1.38.0
inherit_from:
- .rubocop_rails.yml
- .rubocop_rspec.yml
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 3.1
def make_string(length, type = :alphabet, random: false)
char_set = nil
case type
when :alphabet
char_set = ('a'..'z').to_a
when :zenkaku
char_set = ('あ'..'ん').to_a
when :hankaku
char_set = ('ア'..'ン').to_a
end
namespace :notes do
desc "Enumerate all annotations"
task 'all' do
ENV['SOURCE_ANNOTATION_DIRECTORIES'] ||= 'spec'
SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO|HACK", tag: true
end
end
box: ruby:2.3.0
services:
- postgres
build:
steps:
- script:
name: install Nodejs
code: |
sudo apt-get update -y
sudo apt-get install nodejs npm -y
javascript:
flash = #{raw flash.to_json};
coffee:
$ ->
$.each flash, (index, message) ->
toastr[message[0]]('', message[1])