Real unit test (isolation, no children render)
Calls:
- constructor
- render
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.TimeZone; | |
/** | |
* | |
* Java program to display a date in different timezone in Java. Internally Java | |
* stores date as millisecond passed since 01-01-1970 00:00 GMT, which can be |
public class GetDayFromDate { | |
public static void main(String[] args) { | |
Date now = new Date(); | |
SimpleDateFormat simpleDateformat = new SimpleDateFormat("E"); // the day of the week abbreviated | |
System.out.println(simpleDateformat.format(now)); | |
simpleDateformat = new SimpleDateFormat("EEEE"); // the day of the week spelled out completely |
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation | |
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration | |
@SpringBootApplication | |
public class FooApplication { | |
public static void main(String[] args) { | |
// Bootstrap the application | |
SpringApplication.run(FooApplication.class, args); | |
} | |
} |
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Title</title> | |
<link href="stylesheets/main.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<header> | |
<hgroup> |
import axios from 'axios'; | |
import Config from './app.config'; | |
const instance = axios.create({ | |
baseURL: Config.apiPath, | |
}); | |
/** | |
* Catch the AunAuthorized Request | |
*/ |
var fs = require('fs') | |
fs.readFile(someFile, 'utf8', function (err,data) { | |
if (err) { | |
return console.log(err); | |
} | |
var result = data.replace(/string to be replaced/g, 'replacement'); | |
fs.writeFile(someFile, result, 'utf8', function (err) { | |
if (err) return console.log(err); | |
}); |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition: