Skip to content

Instantly share code, notes, and snippets.

import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@csakis
csakis / feathersjs-swagger.js
Created October 1, 2018 19:35 — forked from bravo-kernel/feathersjs-swagger.js
Working example of feathers-swagger with the swagger definition in a service (not in app.js)
// -----------------------------------------------------
// 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);
@csakis
csakis / LICENCE SUBLIME TEXT
Created July 28, 2018 20:08
Sublime Text 3 Serial key build is 3176
## 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 -----
@csakis
csakis / splash-spider.py
Created June 6, 2018 16:22 — forked from stummjr/splash-spider.py
Scrapy + Splash example
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):
@csakis
csakis / response.js
Last active January 17, 2018 00:44
request.response.details
[{
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',
@csakis
csakis / onPreResponse.js
Last active January 16, 2018 23:48
onPreresponse interception of the response
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', {
@csakis
csakis / route.js
Created January 16, 2018 23:12
POST route with Joi validation
server.route({
method: 'POST',
path: '/login',
config: {
validate: {
options: {
abortEarly: false
},
payload: {
username: Joi.string().email().required(),
@csakis
csakis / login.hbs
Created January 16, 2018 18:43
Simple bootstrap4 login form
<form action='/login' method="POST">
<div class="form">
<div class="col">
<label class="" for="username">User Name</label>
<input type="text" class="form-control" id="username" name="username" aria-describedby="emailHelp" placeholder="Enter email">
<small class="invalid-feedback">The user name field is required</small>
<small class="invalid-feedback">The user name needs to be a valid email address</small>
</div>
<div class="col" style="margin-top:10px;">
<label for="password">Password</label>
@csakis
csakis / index.js
Created January 16, 2018 18:40
Basic hapi application with handlebars templating and Inert for static content
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: {
@csakis
csakis / ajax.php
Last active December 23, 2015 13:59 — forked from optikalefx/ajax.php
<?php
require_once("grid.php");
$grid = new Grid("users", array(
"delete"=>true
));
?>