Skip to content

Instantly share code, notes, and snippets.

View bouchtaoui-dev's full-sized avatar

Nordin-010 bouchtaoui-dev

  • Netherlands, Rotterdam
View GitHub Profile
<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>
@bouchtaoui-dev
bouchtaoui-dev / question.js
Last active January 4, 2024 11:54
Example Telegraf
const {
session,
Scenes: { Stage, WizardScene },
Markup,
} = require("telegraf");
const questionWizard = new WizardScene(
"create-question",
async (ctx) => {
await ctx.reply(`What's the subject?`);
@bouchtaoui-dev
bouchtaoui-dev / userSchema.js
Created May 18, 2020 08:29 — forked from jzellis/userSchema.js
Boilerplate for simple Mongoose user schema
/*
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
@bouchtaoui-dev
bouchtaoui-dev / nsnotification.m
Last active September 30, 2019 12:56
NSNotification example
- (void) subscribeNotificationWithName: (NSString*) name {
[ [NSNotificationCenter defaultCenter ] addObserver: self
selector: @selector(didReceiveNotification:)
name: name
object: nil ];
}
- (void) didReceiveNotification: (NSNotification *) notification {
NSLog(@"didReceiveNotification");
@bouchtaoui-dev
bouchtaoui-dev / ifelse.swift
Last active April 9, 2019 09:24
How to improve this snippet of Swift code. I have like more than 10 checkboxes
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
// variables declaration
var str = "Hello, playground"
var x = Int(10)
// class definition
class ParentClass {
func writeText(_ text: String?) -> Void {
print("\(text ?? "empty text")")
}
}
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
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()!
}
// 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 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