This file contains 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 Storage { | |
static getItem(key) { | |
if (key.match(/^([a-z0-9]+)\[['"]?(.*?)['"]?\]$/i)) { // array format e.g., groupName["foo"] | |
const [_, groupKey, itemKey] = key.match(/^([a-z0-9]+)\[['"]?(.*?)['"]?\]$/i); | |
const storageData = sessionStorage.getItem(groupKey); | |
const storageObj = JSON.parse(storageData); | |
return storageObj?.[itemKey]; | |
} else if (key.match(/^([a-z0-9]+)\.([a-z0-9]+)/i)) { // key format groupName.foo | |
const [groupKey, itemKey] = key.split('.'); |
This file contains 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
# | |
# This is modified version of https://github.com/gimite/web-socket-ruby/blob/master/lib/web_socket.rb | |
# | |
# Lincense: New BSD Lincense | |
# | |
require "base64" | |
require "socket" | |
require "uri" | |
require "digest/md5" |
This file contains 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 { Pipe, PipeTransform } from '@angular/core'; | |
import * as CryptoJS from 'crypto-js'; | |
const key = 'TUc0emRqRXpkdw=='; | |
@Pipe({name: 'encrypted'}) | |
export class EncryptPipe implements PipeTransform { | |
transform(value: string) { | |
if (value) { | |
return CryptoJS.AES.encrypt(value, key).toString(); |
This file contains 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 crypto from 'crypto'; | |
import * as zlib from 'zlib'; | |
const assert = require('assert'); | |
const encrypt = (val, password='p@55w07d') => { | |
const key = password.repeat(16).substring(0, 32); | |
const iv = key.substring(0, 16).split('').reverse().join(''); | |
let cipher = crypto.createCipheriv('aes-256-cbc', key, iv); | |
let encrypted = cipher.update(val, 'utf8', 'base64'); | |
return (encrypted + cipher.final('base64')).replace(/[=]+/,''); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 pako from 'pako'; | |
// Usage: | |
// console.log(compress('hello'), decompress(compress('hello'))); | |
export function compress(str) { | |
var unit8arr = pako.deflate(str); | |
return base64EncArr(unit8arr); | |
} |
This file contains 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 { Directive, ElementRef, AfterViewInit } from '@angular/core'; | |
@Directive({ | |
selector: '[trapFocus]' | |
}) | |
export class TrapFocusDirective implements AfterViewInit { | |
constructor(private el: ElementRef) {} | |
ngAfterViewInit() { | |
this.trapFocus(this.el.nativeElement); |
This file contains 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 { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock'; | |
// usage example: | |
// <resize-handle bottom left></resize-handle> | |
// <resize-handle bottom left single></resize-handle> | |
export class ResizeHandle extends HTMLElement { | |
static css = ` | |
resize-handle { position: absolute; } | |
resize-handle:after { content: ' '; display: block; width: 12px; height: 12px; opacity: .5; } |
This file contains 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
[ req ] | |
default_bits = 2048 | |
default_keyfile = server-key.pem | |
distinguished_name = subject | |
req_extensions = req_ext | |
x509_extensions = x509_ext | |
string_mask = utf8only | |
# The Subject DN can be formed using X501 or RFC 4514 (see RFC 4519 for a description). | |
# Its sort of a mashup. For example, RFC 4514 does not provide emailAddress. |
NewerOlder