Skip to content

Instantly share code, notes, and snippets.

View VassilisPallas's full-sized avatar
🏠
Working from home

Vasileios Pallas VassilisPallas

🏠
Working from home
View GitHub Profile
@VassilisPallas
VassilisPallas / service-workers.md
Created July 20, 2021 23:45 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@VassilisPallas
VassilisPallas / gist:d727600fffa7f60ead0c1decf7255442
Created August 11, 2020 17:54
Show the git branch with colours in bash prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

Keybase proof

I hereby claim:

  • I am vassilispallas on github.
  • I am vpallas (https://keybase.io/vpallas) on keybase.
  • I have a public key ASBiYyTACzt_ae5OA0IVGfyofcTqDGhLqxu9vI5Fts4_LQo

To claim this, I am signing this object:

@VassilisPallas
VassilisPallas / 1. install basic vim
Last active October 23, 2022 22:24
vim cheat sheet
readlink -f `which vi`
If result == /usr/bin/vim.tiny
Install the full VIM:
sudo apt update
sudo apt install vim
Now you should have /usr/bin/vim.basic
@VassilisPallas
VassilisPallas / Dockerfile
Created November 10, 2019 20:39
Dockerfile for serverless with pyhton 3.7 and pipenv
FROM python:3.7
LABEL author="Vassilis Pallas"
# set environment for pipenv
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
@VassilisPallas
VassilisPallas / List.js
Last active April 18, 2019 16:36
High Order Component that removes all the xhr requests and returns a boolean to the component if it's mounted or not
import React from 'react';
import { connect } from 'react-redux';
import { withUnmounted } from '../components';
import propsTypes from './propsTypes';
import state from './state';
import dispatch from './dispatch';
class InvoiceList extends React.Component {
@VassilisPallas
VassilisPallas / axiosInterceptor.js
Last active April 6, 2021 20:05
Axios interceptor that handled the error response and uses the cancel signal in every request
import axios from 'axios';
let signal = axios.CancelToken.source();
/**
* returns if error is being caused by axios cancel
* @function
* @returns {Boolean} - true if the error caused by canceling the request
*/
const areRequestsCanceled = err => {
@VassilisPallas
VassilisPallas / countdown.js
Created March 24, 2019 19:25
Simple countdown timer without the usage of setInterval
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay) ;
}
function convertTime(hours) {
var realHours = Math.floor(hours);
var minutes = (hours - realHours) * 60;
var realMinutes = Math.round(minutes);
var realSeconds = ((hours - realHours) + (minutes - realMinutes)) * 60;
@VassilisPallas
VassilisPallas / Encryption.php
Last active October 12, 2017 13:40
Helper class to create RSA keys, encrypt and decrypt data with public and private key
class Encryption
{
private $path = 'CUSTOM PATH';
public static function generateKeys()
{
$privateKey = openssl_pkey_new(array(
'private_key_bits' => 2048, // Size of Key.
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
@VassilisPallas
VassilisPallas / index.ts
Last active November 25, 2020 03:12
Equivalent to PHP function number_format in Javascript
const assert = require('assert');
const numberFormat = require('./numberFormat');
assert.strictEqual(
numberFormat(132323232320.321, 2, ',', '.'),
'132.323.232.320,32'
);
assert.strictEqual(
numberFormat(10.22),
'10.22'