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
import asyncio | |
loop = asyncio.get_event_loop() | |
async def hello(): | |
await asyncio.sleep(3) | |
print('Hello!') | |
if __name__ == '__main__': | |
loop.run_until_complete(hello()) | |
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
// ----------------------------------------------------- | |
// projects.service.js | |
// ----------------------------------------------------- | |
// Initializes the `projects` service on path `/projects` | |
const createService = require('feathers-sequelize'); | |
const createModel = require('../../models/projects.model'); | |
const hooks = require('./projects.hooks'); | |
module.exports = function (app) { | |
const Model = createModel(app); |
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
## Sublime Text 3 Serial key build is 3176 | |
> * Added these lines into /etc/hosts | |
127.0.0.1 www.sublimetext.com | |
127.0.0.1 license.sublimehq.com | |
> * Used the license key | |
----- BEGIN LICENSE ----- |
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
import scrapy | |
# this example needs the scrapyjs package: pip install scrapyjs | |
# it also needs a splash instance running in your env or on Scrapy Cloud (https://github.com/scrapinghub/splash) | |
class SplashSpider(scrapy.Spider): | |
name = 'splash-spider' | |
download_delay = 3 | |
def start_requests(self): |
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
[{ | |
message: '"username" is not allowed to be empty', | |
path: ['username'], | |
type: 'any.empty', | |
context: { | |
key: 'username', | |
label: 'username' | |
} | |
},{ | |
message: '"username" must be a valid email', |
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
server.ext('onPreResponse', function (request, h) { | |
const response = request.response; | |
// if there's no Boom error, don't bother checking further down | |
if (!response.isBoom) { | |
return h.continue; | |
} | |
//let's handle login POST error | |
if (request.route.path == '/login' && request.route.method == 'post') { | |
//business logic comes here to extract the errors from response.details | |
return h.view('login', { |
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
server.route({ | |
method: 'POST', | |
path: '/login', | |
config: { | |
validate: { | |
options: { | |
abortEarly: false | |
}, | |
payload: { | |
username: Joi.string().email().required(), |
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 Path = require('path'); | |
const Hapi = require('hapi'); | |
const Inert = require('inert'); | |
const Vision = require('vision'); | |
const Handlebars = require('handlebars'); | |
const server = Hapi.server({ | |
port: 3000, | |
routes: { | |
files: { |
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 | |
require_once("grid.php"); | |
$grid = new Grid("users", array( | |
"delete"=>true | |
)); | |
?> |
NewerOlder