Skip to content

Instantly share code, notes, and snippets.

$(document).ready(function() {
$('#add-team-submit').on('click', function(e) {
e.preventDefault()
FormHelper.submit('#team-add-modal form', '{{ csrf_token() }}')
})
})
"""
Django settings for weiloapi project.
Generated by 'django-admin startproject' using Django 2.2.12.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
<?php
echo "Hello World";
class CommentController extends BaseController
{
/**
* @var CommentService
*/
private $commentService;
public function __construct(CommentService $commentService)
{
parent::__construct();
$verifyToken = generateToken();
while(User::where('verify_token', '=', $verifyToken)->exists()) {
$verifyToken = generateToken();
}
func register(_ req: Request) throws -> Future<UserResponse> {
return try req.content.decode(CreateUserRequest.self).flatMap { user -> Future<User> in
guard user.password == user.verifyPassword else {
throw Abort(.badRequest, reason: "Password and verification must match.")
}
let hash = try BCrypt.hash(user.password)
return User(id: nil, name: user.name, email: user.email, password: hash, acceptedTos: user.acceptedTos, acceptedAds: user.acceptedAds)
func encode(apiKey: String) throws -> String {
guard let apiKeyData = "api:\(apiKey)".data(using: .utf8) else {
throw Error.encodingProblem
}
let authKey = apiKeyData.base64EncodedData()
guard let authKeyEncoded = String.init(data: authKey, encoding: .utf8) else {
throw Error.encodingProblem
}
return authKeyEncoded
func email(_ req: Request) throws -> Future<Response> {
let message = Mailgun.Message(
from: "mg@sandbox339393939393.mailgun.org",
to: "myemail@myprovider.com",
subject: "Newsletter",
text: "This is a newsletter",
html: "<h1>This is a newsletter</h1>"
)
import FluentMySQL
import Vapor
/// Called before your application initializes.
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
// Register providers first
try services.register(FluentMySQLProvider())
// Register routes to the router
let router = EngineRouter.default()
if ($request->has('xing')) {
if ($job->hasMedia('xing')) {
$image = $job->getFirstMediaUrl('xing');
} else {
$image = $job->employer->hasMedia('avatar') ? $job->employer->getFirstMediaUrl('avatar') : asset('/images/opengraph.jpg');
}
} else if ($request->has('linkedin')) {
if ($job->hasMedia('linkedin')) {
$image = $job->getFirstMediaUrl('linkedin');
} else {