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
<nav class="border-gray-200 dark:bg-gray-900"> | |
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4"> | |
<a href="#" class="flex items-center space-x-3 rtl:space-x-reverse"> | |
<img src="images/robomask.png" class="h-8" alt="Flowbite Logo"/> | |
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">App name</span> | |
</a> | |
<button data-collapse-toggle="navbar-default" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false"> | |
<span class="sr-only">Open main menu</span> | |
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
const { | |
session, | |
Scenes: { Stage, WizardScene }, | |
Markup, | |
} = require("telegraf"); | |
const questionWizard = new WizardScene( | |
"create-question", | |
async (ctx) => { | |
await ctx.reply(`What's the subject?`); |
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
/* | |
I find myself recreating user models for Mongoose every time I start a new project, so I thought I'd create a generic schema for a user model that can be added to or modified as need be. | |
This is loosely based on the Meteor user model (using a "profile" sub-object for the user's personal information). It also includes an optional geolocation point for the user, and Mongoose timestamps, as well as a pre("save") function to bcrypt the user password and a comparePassword() function. | |
Just save this file wherever you store your models and do something like const Users = include('./models/userSchema.js') and you can just use it as a standard Mongoose user model. | |
The username/email address definitions were copied from this tutorial: https://thinkster.io/tutorials/node-json-api/creating-the-user-model |
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
- (void) subscribeNotificationWithName: (NSString*) name { | |
[ [NSNotificationCenter defaultCenter ] addObserver: self | |
selector: @selector(didReceiveNotification:) | |
name: name | |
object: nil ]; | |
} | |
- (void) didReceiveNotification: (NSNotification *) notification { | |
NSLog(@"didReceiveNotification"); |
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
var socialData: SocialData? = storage.data("social") | |
... | |
... | |
// checkLiveAudio = NSButton (CheckBox button) | |
... | |
if let data = socialData { | |
if data.isAudioEnabled() { | |
checkLiveAudio.state = NSControl.StateValue.on | |
} else { | |
checkLiveAudio.state = NSControl.StateValue.off |
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
// variables declaration | |
var str = "Hello, playground" | |
var x = Int(10) | |
// class definition | |
class ParentClass { | |
func writeText(_ text: String?) -> Void { | |
print("\(text ?? "empty text")") | |
} | |
} |
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
var express = require('express') | |
var router = express.Router() | |
// middleware that is specific to this router | |
// this will be called for every request (get, put, update and delete) | |
router.use(function timeLog (req, res, next) { | |
console.log('Time: ', Date.now()) | |
next() // pass control to the nex router int he chain | |
}) | |
// define the home page route |
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
var cb0 = function (req, res, next) { | |
console.log('CB0') | |
next() // don't forget to call next()! | |
} | |
var cb1 = function (req, res, next) { | |
console.log('CB1') | |
next() // don't forget to call next()! | |
} |
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
// route handler with 2 handlers | |
route.get('/example/b', function (req, res, next) { // handler 1 | |
console.log('the response will be sent by the next function ...') | |
next() // don't forget to call next() for passing control to the nex callback | |
}, function (req, res) { // handler 2 | |
res.send('Hello from B!') | |
}) |
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
/** | |
* This function returns a promise to fetch a user by id | |
*/ | |
function getUserWithId(id) { | |
return new Promise((resolve, reject) => { | |
// Look for a user with id in the database | |
User.find({_id: id}, (user, err) => { | |
if(err) return reject(err); | |
// on success |
NewerOlder