This file contains hidden or 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
| @Service | |
| public class BatchServiceImpl { | |
| @Scheduled(cron = "your-cron-expression-here (example: */5 * * * * MON-FRI would execute on weekdays)") | |
| public void sendReport() { | |
| // ... | |
| } | |
| } |
This file contains hidden or 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 { Inject } from 'decorators'; | |
| import * as directives from './module'; | |
| function factoryize(directive) { | |
| return directive.$inject | |
| ? Inject(...directive.$inject)((...dependencies) => new directive(...dependencies)) | |
| : () => new directive(); | |
| } | |
| const directivesModule = angular.module('app.directives', []); |
This file contains hidden or 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 { Inject, Directive } from 'decorators'; | |
| @Inject('$scope', '$compile') | |
| @Directive('myDirective') | |
| class MyDirective { | |
| constructor($scope, $compile) { | |
| // ... | |
| } | |
| } |
This file contains hidden or 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 { Inject } from 'decorators'; | |
| function factoryize(directive) { | |
| return directive.$inject | |
| ? Inject(...directive.$inject)((...dependencies) => new directive(...dependencies)) | |
| : () => new directive(); | |
| } |
This file contains hidden or 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
| function Service(name) { | |
| return target => { | |
| target.__service = { name }; | |
| return target; | |
| } | |
| } | |
| function Controller(name, stateOpts) { | |
| return target => { | |
| target.__controller = { name, stateOpts }; // stateOpts get passed to $stateProvider during registration. |
This file contains hidden or 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 * as services from './module'; | |
| const serviceModule = angular.module('app.services', []); | |
| // Automatically register each service. | |
| Object.keys(services).forEach(key => { | |
| if(!services[key].__service) { | |
| console.warn(`Service ${key} is missing the @Service decorator.`); | |
| return; | |
| } |
This file contains hidden or 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 path = require('path'); | |
| var webpackConfig = require('./webpack.config'); | |
| var webpack = require('webpack'); | |
| var webpackDevMiddleware = require('webpack-dev-middleware'); | |
| var webpackHotMiddleware = require('webpack-hot-middleware'); | |
| var proxyMiddleware = require('http-proxy-middleware'); | |
| var devConfig = webpackConfig.devServer; | |
| var app = express(); |
This file contains hidden or 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 com.google.gson.Gson; | |
| import java.util.Date; | |
| import lombok.Data; | |
| import com.google.common.collect.Maps; | |
| import java.util.Map; | |
| /** | |
| * The message class. | |
| * This class should be present on both the client as well as the receiving app. | |
| * You can serialize this class to send it over the network. JSON is a good choice. |
This file contains hidden or 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
| authenticate_message(message) { | |
| secret_key = get_secret_key(message.public_key) | |
| my_signature = sprintf("payload=%s&public_key=%s×tamp=%s&type=%s", | |
| url_encode(message.payload), | |
| url_encode(message.public_key), | |
| url_encode(message.timestamp), | |
| url_encode(message.type)) | |
| return hmac_sha256(my_signature, secret_key) == message.signature | |
| } |
This file contains hidden or 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
| create_signature(payload, type, timestamp, public_key, secret_key) { | |
| signature = sprintf("payload=%s&public_key=%s×tamp=%s&type=%s", | |
| url_encode(payload), | |
| url_encode(public_key), | |
| url_encode(timestamp), | |
| url_encode(type)) | |
| return hmac_sha256(signature, secret_key) | |
| } |