Skip to content

Instantly share code, notes, and snippets.

View stfalconaleks's full-sized avatar

stfalconaleks

View GitHub Profile
public function eat($food)
{
switch ($food) {
case 'carrot':
$this->getCalories(50);
break;
case 'cabbage':
$this->getCalories(100);
break;
default:
$piecesOfCarrot = $carrot / 4;
foreach ($piecesOfCarrot as $pieceOfCarrot) {
$rabbit->eat($pieceOfCarrot);
}
// Cut the carrot into 4 pieces
$piecesOfCarrot = $carrot / 4;
// Let the rabbit eat all pieces of carrot one by one
foreach ($piecesOfCarrot as $pieceOfCarrot) {
$rabbit->eat($pieceOfCarrot); // Rabbit eats the piece of carrot
}
class MovieSpec extends ObjectBehavior
{
function it_should_have_john_smith_in_the_cast_with_a_lead_role()
{
$this->getCast()->shouldHaveKeyWithValue('leadRole', 'John Smith');
}
}
$conditions = new Condition();
$untilCondition = (new Condition\Until())->findVegetables('carrot', 'cabbage');
$turnBackCondition = (new Condition\TurnBack())->ifMeet('wolf', 'hunter');
$conditions->add($untilCondition)->add($turnBackCondition);
$rabbit->run(Direction::FORWARD, $conditions);
import Vapor
let drop = Droplet()
drop.get("hello") { request in
if let name = request.data["name"]?.string {
return try drop.view.make("hello", ["name": name])
}
return try drop.view.make("hello", ["name": "no name"])
class func fontExplanation(questionTitle: String,
question: String,
wrongTitle: String?,
wrongAnswer: String?,
correctTitle: String,
correctAnswer: String,
explanationTitle: String,
explanation: String,
isCorrect: Bool) -> String {
let pathToCss = Bundle.main.path(forResource: "styles", ofType: "css")
cell.webView.loadHTMLString(HtmlHelper.fontExplanation(questionTitle: questionTitle,
question: question,
wrongTitle: item!.is_correct! == false ? "YOUR ANSWER —
WRONG" : "",
wrongAnswer: item!.is_correct! == false ? wrongText : nil,
correctTitle: item!.is_correct! == false ? "CORRECT
ANSWER" : "YOUR ANSWER - CORRECT",
correctAnswer: correctText,
fileprivate var alertVC: UIAlertController = {
let vc = UIAlertController(title: "Warning", message: "No internet connection",
preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
vc.addAction(action)
return vc
}()
//internet connection
UHBConnectivityManager.shared().registerCallBack({ [weak self] (status:
ConnectivityManagerConnectionStatus) in
if status == ConnectivityManagerConnectionStatusConnected {
print("Internet connected")
SocketManager.sharedInstance.reconnect()
self?.alertVC.dismiss(animated: true, completion: nil)
} else {