クエリビルダは、SELECT文で「悲観的ロック」を行うための機能をいくつか持っています。SELECT文を実行する間「共有ロック」をかけたい場合は、sharedLockメソッドをクエリに指定して下さい。共有ロックはトランザクションがコミットされるまで、SELECTしている行が更新されることを防ぎます。
DB::table('users')
->where('votes', '>', 100)
->sharedLock()
->get();
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// © sooch | |
// | |
// TradingViewのMACDストラテジーに期間指定パラメータを追加したPineScriptです. | |
// | |
//@version=4 | |
strategy("MACD Strategy", overlay=true) | |
// Input parameters |
import pandas as pd | |
import numpy as np | |
from pandas import DataFrame, Series | |
def sma(ohlc: DataFrame, period=9) -> Series: | |
return Series( | |
ohlc['close'].rolling(period).mean(), | |
name=f'SMA {period}', | |
) |
extension String { | |
func asHtmlAttributedString() -> NSAttributedString? { | |
guard let htmlData = self.data(using: String.Encoding.utf8, allowLossyConversion: true) else { return nil } | |
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [ | |
.documentType: NSAttributedString.DocumentType.html, | |
.characterEncoding: String.Encoding.utf8.rawValue | |
] | |
return try? NSAttributedString(data: htmlData, options: options, documentAttributes: nil) | |
} |
/** | |
* 範囲内の値をランダムで返す | |
* | |
* @param float $min 最小値 | |
* @param float $max 最大値 | |
* @return float | |
*/ | |
function random_float($min, $max, $mul = 1000000): float | |
{ | |
return random_int($min * $mul, $max * $mul) / $mul; |
#-*- coding: utf-8 -*- | |
class NutritionFacts(object): | |
def __init__(self, builder): | |
self.serving_size = builder.serving_size | |
self.servings = builder.servings | |
self.calories = builder.calories | |
self.fat = builder.fat | |
self.sodium = builder.sodium |