Skip to content

Instantly share code, notes, and snippets.

@mszkb
mszkb / gist:ec76c41081afed89d10e25ee2646d53f
Created August 15, 2021 18:27
axios - do 20 requests, but 6 at the same time (queue)
import axios from "axios";
import { TaskQueue } from 'cwait';
import "@babel/polyfill";
const MAX_SIMULTANEOUS_DOWNLOADS = 6;
const params = {
method: 'get',
@mszkb
mszkb / csv_to_json.py
Last active February 7, 2021 15:55
very simple csv to json converter
# converts a csv file to json
# naiv and compressed mode
#
# naiv: a typical json file as object key-value pair format
# compressed: no keys, only values as array; headers are kept in a list
# columns: [a, b, c]
# list: [[x, y, z], [x1, y1, z1], [x2, y2,z2]
import csv
import json
@mszkb
mszkb / gist:af1d7d675469cb85521002cfa00a57d8
Created January 22, 2021 09:46
vuex-i18n split up lang.json files

vuex-i18n concat json files: If you developing a component library and you want to decouple it from the app:

  • Create seperate lang.json file
  • require it in i18n/index.js
  • concat with others
const defaultEn = require("./en.json");
const appkitEn = require("@/components/theme/appkit/i18n/en.json");
@mszkb
mszkb / .htaccess
Created November 17, 2020 22:05
nginx reverse proxy - remove .php from URL
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# For LocalHost !.php
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=::1
@mszkb
mszkb / nginx.conf
Last active November 13, 2020 08:59 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# for detailed explaination @see # https://gist.github.com/plentz/6737338
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://assets.zendesk.com; font-src 'self' https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'none'";
# as we use Azure the SSL part is done by the WebApp Service
server {
listen 80 default;
@mszkb
mszkb / shell
Created July 21, 2020 11:00
gitclean: Remove all branches but the master branch + checkout master + pull + safety stash
git stash && git checkout master && git pull && git branch | grep -v "master" | xargs git branch -D
{
"version": 0.1,
"author": "mszkb",
"license": "ISC",
"keys": [
{
"name": "Trustkey G310",
"source": "https://www.trustkeysolutions.com/security-keys/g310/",
"tags": [""],
"price": 0,
@mszkb
mszkb / MockFile.js
Created March 18, 2020 07:21 — forked from josephhanson/MockFile.js
Mock file for JavaScript based file upload - with basic test harness
// mock file
function MockFile() { };
MockFile.prototype.create = function (name, size, mimeType) {
name = name || "mock.txt";
size = size || 1024;
mimeType = mimeType || 'plain/txt';
function range(count) {
var output = "";
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@mszkb
mszkb / es6-spread-immutable-cheatsheet.md
Last active January 14, 2019 08:30 — forked from gorangajic/es6-spread-immutable-cheatsheet.md
es6 spread immutable cheatsheet

EDIT: original uses the var for declaring variables. In this fork all var are replaced with let.

update object

let state = {
    id: 1,
    points: 100,
    name: "Goran"
};