Skip to content

Instantly share code, notes, and snippets.

@Kristjan-Reinsberg
Kristjan-Reinsberg / csv-in-out.py
Last active June 18, 2025 13:36
PYHON - CSV - KEEP
# https://colab.research.google.com/drive/1xpvf6F7pPlwmQIOR_-_F2rN7KyQa-Tsl#scrollTo=PRwadWWMFiXh
import csv
import json
input_file = 'export (1).csv'
output_file = 'filtered_services.json'
desired_columns = [
"IT teenuse nimi",
"Lühinimi",
"Lühikirjeldus",
@Kristjan-Reinsberg
Kristjan-Reinsberg / .bash_aliases
Created March 13, 2025 08:06
.bash_aliases (ssh connections and useful list)
# DEPENDS: .bashrc must include this file
# LOAD CHANGES MANUALLY: source ~/.bash_aliases OR ~/.bash_aliases
# LIST ALL ALIASES: alias
#INFO MESSAGE
echo -e "\e[1;34m.bash aliases LOADED"
# VARIABLES
export eis_user='firstname.lastname'
export info_color='\e[1;34mINFO: '
@Kristjan-Reinsberg
Kristjan-Reinsberg / vscode.nemo_action
Created March 6, 2025 07:54
LINUX mouse right click add vs code
# cd ~/.local/share/nemo/actions
# touch vscode.nemo_action
# nano vscode.nemo_action
[Nemo Action]
Name=Open in VS Code
Comment=Open in VS Code
Exec=code "%F"
Icon-Name=visual-studio-code
Selection=Any
@Kristjan-Reinsberg
Kristjan-Reinsberg / functions.php
Created March 1, 2025 10:01
WP ACF colorpicker has theme colors
function adm_enqueue_custom_acf_color_picker_script() {
//wp_enqueue_script('jquery'); // ACF filters requirement. If not working
$eas_theme__colors = [
'#003cff', //light blue
'#0000b4', //darker blue
'#3c0078', //purple
'#1d4432', //green
'#fcedc5', //yellow
@Kristjan-Reinsberg
Kristjan-Reinsberg / functions.php
Last active February 24, 2025 04:08
WP add columns to Posts, Pages, CPT (template path and last modified)
<?php
//WHY THIS FILE? - Find templates fast and get better overview of a new project
//Posts, Pages, CPT get columns: "template path" and "last modified"
// Add custom columns
function add_custom_columns($columns) {
$columns['modified_date'] = 'Last Modified';
$columns['page_template'] = 'Page Template';
return $columns;
}
<script>
import { onMount } from "svelte";
let { posts } = $props();
let current = $state(0);
let interval;
onMount(() => {
interval = setInterval(() => {
current = (current + 1) % posts.length;
@Kristjan-Reinsberg
Kristjan-Reinsberg / gist:add79724408e743c9e3351493fd4a897
Created October 31, 2020 18:05
WP PLUGIN HOW TO ADD EDIT PAGE (as request parameter for X plugin page)
# NB! DO NOT USE add_page or add_sub_page for that
# EXAMPLE: just use plugin main page and add request parameters
global $wp;
$query = add_query_arg( admin_url() , $wp->query_vars );
$edit_query = add_query_arg( array(
'page' => "plugin-page-home",
'car_id' => $car->id,
'work_id' => $work->id
), $query );
@Kristjan-Reinsberg
Kristjan-Reinsberg / gist:707a48fca4fd814541671d3e4fad686e
Created October 6, 2020 21:06
LARAVEL STORAGE LINK IN SHARED HOSTING
<?php
#Please note that project folder is one level from public_html (/../projects/laravel/)
#Plese note that laravel public folder files must be in public_html (configure the location)
#1 Remove storage folder in public_html/public/storage if you perfomed storage:link in local
#2 Create a php file: mysymlink.php @ public_html folder
#3 Add below codes to mysymlink.php file
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/../projects/laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/storage';
symlink($targetFolder,$linkFolder);
SELECT DISTINCT
clients.papers_email_address,
LEFT(clients.name , LOCATE(' ',clients.name) - 1) AS eesnimi_tyhikuni /* MARI TAMM -> MARI (täisnime hoitakse)*/
FROM
policies
LEFT JOIN clients ON clients.id = policies.client_id
WHERE
@Kristjan-Reinsberg
Kristjan-Reinsberg / gist:287f692bf6b5c8d382f9ff09d3edd098
Created May 21, 2020 12:31
SQL same table join and find difference in days
SELECT
renewals.start_date AS UUS_POLIIS_start_date
,policies.end_date AS EELMINE_POOLIIS_end_date
,renewals.id AS UUS_POLIIS_id
,policies.id AS EELMINE_POOLIIS
,DATEDIFF( renewals.start_date , policies.end_date ) AS DATE_DIFF
FROM
policies