Skip to content

Instantly share code, notes, and snippets.

View fakiolinho's full-sized avatar
🤘
Leading as usual...

Fakiolas Marios fakiolinho

🤘
Leading as usual...
View GitHub Profile
@fakiolinho
fakiolinho / HTML: HTML5 Default Template
Created April 21, 2013 11:38
HTML: HTML5 Default Template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<!-- Favicons Start -->
<!-- In case image.ico -->
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
@fakiolinho
fakiolinho / jQuery: Validate Email with Regex
Last active March 25, 2022 05:47
jQuery: Validate Email with Regex
/* jQuery Validate Emails with Regex */
function validateEmail(Email) {
var pattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
return $.trim(Email).match(pattern) ? true : false;
}
@fakiolinho
fakiolinho / jQuery: Validate Strings with Regex
Last active December 13, 2021 18:44
jQuery: Validate Strings with Regex
/* jQuery Validate Strings with Regex */
function validateStrings(string) {
var pattern = /^[0-9a-zA-Z@_-]+$/;
return $.trim(string).match(pattern) ? true : false;
}
@fakiolinho
fakiolinho / server.js
Last active May 8, 2020 23:23
Proxy an xhr request by using sapper, polka and http-proxy-middleware
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import { createProxyMiddleware } from 'http-proxy-middleware';
import * as sapper from '@sapper/server';
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
const server = polka();
@fakiolinho
fakiolinho / api.js
Last active November 11, 2019 13:33
import request from 'utils/request';
export const downloadFileRequest = id =>
request.get(`/files/${id}`, {
responseType: 'blob',
timeout: 30000,
});
import fileSaver from 'utils/fileSaver';
import fileReader from 'utils/fileReader';
import { downloadFileRequest } from './api';
import * as types from './actionTypes';
export const downloadFile = id => async dispatch => {
try {
dispatch({
type: types.DOWNLOAD_FILE_REQUEST,
});
export default file => {
const fileReader = new FileReader();
return new Promise((resolve, reject) => {
fileReader.onerror = () => {
fileReader.abort();
reject(new Error('Problem parsing file'));
};
fileReader.onload = () => {
import fileSaver from 'utils/fileSaver';
import { downloadFileRequest } from './api';
import * as types from './actionTypes';
export const downloadFile = id => async dispatch => {
try {
dispatch({
type: types.DOWNLOAD_FILE_REQUEST,
});
import FileSaver from 'file-saver';
export default (fileData, fileName) => FileSaver.saveAs(fileData, fileName);
import { uploadFileRequest } from './api';
import * as types from './actionTypes';
export const uploadFile = data => async dispatch => {
try {
dispatch({
type: types.UPLOAD_FILE_REQUEST,
});
await uploadFileRequest(data);