Skip to content

Instantly share code, notes, and snippets.

View ikarasz's full-sized avatar

István Kárász ikarasz

  • Budapest, Hungary
View GitHub Profile
@ikarasz
ikarasz / change_extensions.sh
Created March 9, 2020 19:38
Change file extensions
#!/bin/bash
$FOLDER = $1
for f in $FOLDER/*.html; do
echo "${f/.html/.js}"
git mv -- "$f" "${f/.html/.js}"
done
@ikarasz
ikarasz / shuffle-array.js
Last active November 21, 2019 04:14
js shuffle-array
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
@ikarasz
ikarasz / APIService.js
Last active October 23, 2019 05:08
Stackoverflow [58498581]
import axios from 'axios';
const config = {
baseURL: 'https://chain-chess.glitch.me',
};
const APIService = axios.create(config);
APIService.interceptors.request.use(request => {
const token = 'blah';
const dates = [
'2018-06-10',
'2013-03-21',
'2010-08-03',
'2016-02-05',
'2019-06-17',
];
const toDate = d => new Date(d);
const extractYear = d => d.getFullYear();
@ikarasz
ikarasz / array-to-matrix.js
Created August 9, 2018 05:05
arrayToMatrix
function arrayToMatrix(items) {
const matrixSize = Math.sqrt(items.length);
return new Array(matrixSize)
.fill(null)
.map(() => items.splice(0, matrixSize));
}
@ikarasz
ikarasz / external-links.css
Last active August 7, 2018 05:08
append an icon to all external link on a website