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
/** | |
* @desc this snippet will allow multiple arguments to a search query in Google Chrome | |
* examples include https://www.reddit.com/r/%s/search?q=%s | |
* @author Chris McCormack mccormack.christopher@gmail.com | |
* @required Google Chrome. Replace all values in brackets ([]) with valid entries. | |
* To add to Chrome, go to Settings > Search [Manage search engines...] > Other search engines. | |
* At the bottom of this section, there are three required fields: | |
* [Add a new search engine] [Keyword] [URL with %s in place of query] | |
* - Add a new search engine: Descriptive name of your search | |
* - Keyword: used to trigger search. |
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