Skip to content

Instantly share code, notes, and snippets.

View cristian-frumusanu's full-sized avatar

Cristian Frumusanu cristian-frumusanu

View GitHub Profile
{
"bracketSpacing": true,
"semi": true,
"trailingComma": "es5",
"printWidth": 80,
"tab-width": 4,
"endOfLine": "lf",
"singleQuote": true,
"overrides": [
{
@cristian-frumusanu
cristian-frumusanu / vscode-vue-dot-ts-file.json
Last active August 21, 2020 07:36
VS Code Snippets: Vue.js + TypeScript
{
"Vue.js Component": {
"prefix": "vue-component",
"body": [
"import { Vue, Component } from 'vue-property-decorator';",
"",
"@Component",
"export default class $1 extends Vue {",
"",
"}"
@cristian-frumusanu
cristian-frumusanu / fw.scss
Created April 24, 2020 10:03
SCSS - generate font weight helper classes
$fw: (300, 400, 500, 700);
@each $w in $fw {
.fw-#{$w} { font-weight: $w !important; }
}
@cristian-frumusanu
cristian-frumusanu / fs.scss
Last active April 24, 2020 10:04
SCSS - generate font size helper classes
// REM
@for $i from 10 through 25 {
.fs-#{$i} {
font-size: #{$i/16}rem !important;
}
}
// PX
@for $i from 10 through 25 {
.fs-#{$i} {
@cristian-frumusanu
cristian-frumusanu / rgb2hex.js
Created September 20, 2019 08:02
RGB to HEX
const _rgb2hex = ( orig ) => {
let rgb = orig.replace(/\s/g, '').match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),
alpha = (rgb && rgb[4] || "").trim(),
hex = rgb ?
(rgb[1] | 1 << 8).toString(16).slice(1) +
(rgb[2] | 1 << 8).toString(16).slice(1) +
(rgb[3] | 1 << 8).toString(16).slice(1) : orig;
if ( alpha !== '' && alpha < 1 ) {
hex += ' ' + alpha;
@cristian-frumusanu
cristian-frumusanu / uuidv4.js
Last active September 20, 2019 08:03
Generate uuid in JavaScript
const _uuidv4 = () => {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues( new Uint8Array( 1 ) )[ 0 ] & 15 >> c / 4 ).toString( 16 )
)
};
export _uuidv4;
@cristian-frumusanu
cristian-frumusanu / clone-object.ts
Last active September 20, 2019 08:00
Cloning an JavaScript object (using TypeScript) see - https://stackoverflow.com/a/4591639 - for disadvantages
const _cloneObject = <T>( object: T ): T => {
return JSON.parse( JSON.stringify( object ) );
}
export _cloneObject;