View is_zip.js
function isZip(path, callback) {
fs.open(path, 'r', (error, fd) => {
if (error)
return callback(error)
fs.read(fd, Buffer.alloc(4), 0, 4, 0, (error, bytesRead, buffer) => {
if (error)
return callback(error)
callback(null, buffer.readUInt32LE(0) === 0x04034b50)
View validation-sample.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.errors {
color: red;
}
</style>
View store-main.js
import { ipcMain, BrowserWindow } from 'electron'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
count: 0
}
View future_and_promise.js
class F extends Promise {
onComplete(callback) {
this.then(callback, callback);
}
}
class P {
constructor() {
this.future = new F((resolve, reject) => {
this.trySuccess = resolve;
View error_matcher.rb
module Rescuer
class << self
attr_accessor :error_class
def error_matcher
error_class = self.error_class
Module.new do
define_singleton_method :=== do |e|
error_class === e
View gacha.rb
ITEMS_BASIC = [
[:R, 82],
[:SR, 15],
[:SSR, 3],
]
ITEMS_SPECIAL = [
[:SR, 97],
[:SSR, 3],
]
View errors_with_symbol.rb
require 'active_model'
class ActiveModel::Errors
module WithSymbol
attr_accessor :symbol_value
end
def add_with_symbol(attribute, message = :invalid, options = {})
add_without_symbol(attribute, message, options).tap do |messages|
View lovelive_quiz.rb
#!/usr/bin/env ruby
require "json"
require "open-uri"
class LoveLiveQuiz
API_URL = 'https://lovelive-quiz-api.herokuapp.com/quiz'
def initialize
fetch
View active_model_each_error_to_be_formattable.rb
require 'active_model'
class ActiveModel::Errors
module HiddenEntity
attr_accessor :_entity
end
def generate_message_with_format(attribute, type = :invalid, options = {})
message = generate_message_without_format attribute, type, options
View mix.coffee
Array::forEachAsync = (each, context) ->
copy = @slice()
index = -1
do next = ->
return if copy.length == 0
process.nextTick ->
item = copy.shift()
index += 1