Skip to content

Instantly share code, notes, and snippets.

View vparaskevas's full-sized avatar

Vasileios Paraskevas vparaskevas

View GitHub Profile
@tranduongms1
tranduongms1 / quill-figure-with-caption.js
Last active December 12, 2023 14:04
Quill figure with caption, base on BlockEmbed
import Quill from 'quill';
const Module = Quill.import('core/module');
const BlockEmbed = Quill.import('blots/block/embed');
class ImageBlot extends BlockEmbed {
static blotName = 'image';
static tagName = ['figure', 'image'];
static create(value) {
@sanjeevbishnoi
sanjeevbishnoi / app.js
Created October 29, 2018 05:59
Electron JS main App.js file
import path from 'path'
import url from 'url'
import { app, crashReporter, BrowserWindow, Menu, globalShortcut } from 'electron'
const isDevelopment = (process.env.NODE_ENV === 'development')
let mainWindow = null
let forceQuit = false
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
import React from "react";
import { Location } from "@reach/router";
let scrollPositions = {};
class ManageScrollImpl extends React.Component {
componentDidMount() {
try {
// session storage will throw for a few reasons
// - user settings
@gaearon
gaearon / minification.md
Last active June 8, 2024 08:15
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@hagemann
hagemann / database.js
Last active December 9, 2022 10:24
Promisified MySQL middleware for Node.js
const util = require('util')
const mysql = require('mysql')
const pool = mysql.createPool({
connectionLimit: 10,
host: 'localhost',
user: 'root',
password: 'password',
database: 'my_database'
})
@antoniopresto
antoniopresto / Form.js
Last active November 30, 2019 14:04
Antd Masked Input
import { Form } from 'antd'
import { FormInput } from './antd-masked-input'
export default () => (
<Form>
<FormInput
form={this.props.form} // antd form
mask={'111.111.111-11'}
placeholder=""
label={''}
@Tomassito
Tomassito / download-file.js
Last active March 11, 2022 23:53 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
link.click();
@Radiergummi
Radiergummi / Spreadsheet.js
Created May 7, 2018 13:26
Updated version
'use strict';
import FileSaver from 'file-saver';
import JSZip from 'jszip';
class Spreadsheet {
/**
* Holds all replacement strings to escape
*
'use strict';
import FileSaver from 'file-saver';
import JSZip from 'jszip';
class Spreadsheet {
/**
* Holds all replacement strings to escape
*
@austintackaberry
austintackaberry / mergeMessages.js
Last active September 18, 2019 16:03
Script that combines react-intl json files
import * as fs from "fs";
import { sync as globSync } from "glob";
import { sync as mkdirpSync } from "mkdirp";
import last from "lodash/last";
const MESSAGES_PATTERN = "./public/messages/**/*.json";
const LANG_DIR = "./public/locales/";
const LANG_PATTERN = "./public/locales/*.json";
// Try to delete current json files from public/locales