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
<ul> | |
<li>item 1 | |
<ul> | |
<li>sub-item 1</li> | |
<li>sub-item 2</li> | |
<li>sub-item 3</li> | |
</ul> | |
</li> | |
<li>item 2 | |
<ol> |
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 rhombus(n) { | |
return n < 0 || n % 2 == 0 ? null : | |
[ | |
(n - (n % 2)) / 2, | |
max => Array(max+1).fill(1).map((i, j) => ' '.repeat(max-j) + '*'.repeat(j*2+1)), | |
half => half.concat(half.slice(0, -1).reverse(), '').join('\n') | |
] | |
.reduce((curr, fn) => fn(curr)); | |
} | |
} |
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
let str = 'My Secure String'; | |
let enc = str.split('').map(char => '0x'+char.codePointAt(0).toString(16)).join(' '); | |
let dec = enc.split(' ').map(code => String.fromCodePoint(parseInt(code))).join('') | |
console.log(`Encoded: '${enc}'`); | |
console.log(`'${str}' === '${dec}'`, str === dec); |
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
class Encoder { | |
public static encode(str: string, pass: string): string { | |
let res = ''; | |
let j = 0, jlen = pass.length; | |
str = pass + str; | |
for (let i = 0, ilen = str.length; i < ilen; i++) { | |
let charCode = str.charCodeAt(i), | |
passCode = pass.charCodeAt(j), | |
sumCode = charCode + passCode; |
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
declare type Dependency = any; | |
declare type DependencyKey = string|number|{new(...args: any[])}; | |
/** | |
* Dependency injection container | |
* | |
* Example: | |
* | |
* // There is a class | |
* class Auth { ... } |
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
class Security { | |
static encrypt(text, password) { | |
password = String(password); | |
return String(text) | |
.split('') | |
.map((char, index) => String.fromCharCode(char.charCodeAt(0) + password.charCodeAt(index % password.length))) | |
.join(''); | |
} |
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
'use strict'; | |
class Collection<T> extends Array<T> { | |
// noinspection JSAnnotator | |
public constructor(...args: T[]) { | |
let array = super(...args); | |
Object.setPrototypeOf(array, this.constructor.prototype); | |
return array; | |
} |
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
/** | |
* @param {string} str testable string | |
* | |
* @return {boolean} | |
*/ | |
function verify(str) { | |
if (typeof str !== 'string') return false; | |
var pairs = { | |
'(' : ')', |
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
{ | |
"require": { | |
"swiftmailer/swiftmailer": "@stable" | |
} | |
} |
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
<?php | |
return [ | |
'components' => [ | |
... | |
'mailer' => [ | |
'class' => 'yii\swiftmailer\Mailer', | |
'viewPath' => '@common/mail', | |
// send all mails to a file by default. You have to set |