This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccurateInterval { | |
intervalId = null | |
constructor(fn, timer) { | |
this.fn = fn | |
this.timer = timer | |
} | |
start = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of a schema for a Poll document | |
const PollSchema = new mongoose.Schema({ | |
createdBy: { | |
type: mongoose.Schema.Types.ObjectId, | |
ref: 'User' | |
}, | |
createdTime: { | |
type: String, | |
required: true | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread, Lock | |
from random import randint | |
from time import sleep | |
class AsyncLetter(Thread): | |
def __init__(self, letter): | |
super().__init__() | |
self.timer = randint(1,5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_POST['submit'])) | |
{ | |
//This page should not be accessed directly. Need to submit the form. | |
echo "error; you need to submit the form!"; | |
} | |
$name = $_POST['name']; | |
$visitor_email = $_POST['email']; | |
$message = $_POST['message']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc(expr): | |
operators = ['+', '-', '*', '/'] | |
stack = list() | |
for item in expr.split(' '): | |
if item in operators: | |
right, left = [str(i) for i in (stack.pop(), stack.pop())] | |
stack.append(eval(left + item + right)) | |
else: | |
stack.append(eval(item + '+ 0')) |
NewerOlder