Skip to content

Instantly share code, notes, and snippets.

View ikiranis's full-sized avatar

Ioannis Kyranis ikiranis

View GitHub Profile
@ikiranis
ikiranis / gist:7ecbe2aa8855aeaba28cd96f796bbe6f
Created November 15, 2022 16:35
Fix typescript error when you want to use variable with type any, as index
/**
* Fix any type to index
*
* @param name
*/
const getKeyFromAnyType = (name: any) => {
const str: keyof Element = name
return str;
}
@ikiranis
ikiranis / Photos.vue
Last active April 20, 2020 16:19
Photos component (not working)
<template>
<div>
<div v-for="(photo, index) in photos" class="row my-3 border">
<div class="form-group my-3 col-lg-6 col-12">
<div class="custom-file">
<input type="file" class="custom-file-input" name="uploadFile"
id="customFile"
accept='image/*'
@change="handleFile($event, index)">
<label class="custom-file-label"
@ikiranis
ikiranis / CheckIfUserIsAdmin.php
Created September 12, 2019 01:51
Laravel Middleware to check if a user is admin
class CheckIfUserIsAdmin
{
/**
* Check if user is admin
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
@ikiranis
ikiranis / amka-validator.js
Created August 28, 2019 23:25 — forked from tdoumas/amka-validator.js
Αλγόριθμος ορθότητας AMKA Greek Social Security Number (AMKA)
// Greek Social Security Number Validation (AMKA)
// Αλγόριθμος ορθότητας ΑΜΚΑ
function validateAMKA(amka) {
if (!amka.match(/^\d{11}$/) || amka == '00000000000')
return false;
var iSum = 0;
for (var i = 1; i <= amka.length; i++) {
var iDigit = parseInt(amka.charAt(i - 1), 10);
if (i % 2 === 0) {
@ikiranis
ikiranis / PeriodontalChartToothsTable.vue
Created August 24, 2019 00:45
Display table with rows by date and other filters
<template>
<table class="table table-responsive">
<thead>
<tr>
<th></th>
<th v-for="tooth in teeth" :key="tooth.id"
class="text-center tooth-label">
<img :src="imagePath(tooth.number)" class="toothImage">
@ikiranis
ikiranis / PeriodontalChartToothsTable.vue
Created August 22, 2019 17:19
Filter the duplicate dates from array of objects
/**
* Get all the dates, without duplicates
*
* @returns {*[]}
*/
getDates ()
{
// Get only the dates from array
let dates = [];
@ikiranis
ikiranis / athens-radio.m3u
Created August 13, 2019 19:05 — forked from dennmtr/athens-radio.m3u
Athens Radio
#EXTM3U
#EXTINF:0,095.20 | Athens Deejay FM, Athens (Mainstream Pop, Top Hits) - 95.2 Athens DeeJay
http://94.23.0.114:41972
#EXTINF:0,089.20 | Music, Athens (Mainstream Pop, Top Hits) - Music 89.2
http://ample-02.radiojar.com/k0hua7u1yk5tv
#EXTINF:0,104.60 | Hot FM, Athens (Mainstream Pop, Top Hits) - Hot 104.6
http://hotfm.live24.gr:80/hotfm
#EXTINF:0,101.60 | Radio Paradise, Poros (Mainstream Pop, Top Hits) - Netcast
http://213.239.206.179:8850
#EXTINF:0,088.90 | Hit, Athens (Pop, Top Hits) - HIT 889 radio
@ikiranis
ikiranis / TransactionTest.php
Last active August 10, 2019 17:22
Clean a collection from duplicate entries. Get only unique entries. Remove duplicates.
/**
* Clean a collection from duplicate entries
*
* @param $collection
* @param $field
* @return mixed
*/
protected function cleanCollection($collection, $field)
{
// Group collection by field and then return only the unique items
@ikiranis
ikiranis / PatientsTable.vue
Created July 31, 2019 17:36
Sample of functional component
<template functional>
<div>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">#</th>
<th scope="col">Όνομα</th>
<th scope="col">Επώνυμο</th>