Skip to content

Instantly share code, notes, and snippets.

@nawie
nawie / useQuery.ts
Created April 18, 2024 04:28
Composable Tanstack Query for Vue 3
import { z } from 'zod'
import { ref } from 'vue'
import type { DefaultError, QueryKey } from "@tanstack/query-core";
import type { QueryClient } from "@tanstack/vue-query/src/queryClient";
import {
UseQueryDefinedReturnType,
UseQueryOptions,
UseQueryReturnType,
useQuery as useVueQuery,
} from "@tanstack/vue-query";
@nawie
nawie / EnsureQueueListenerIsRunning.php
Created March 17, 2023 13:49 — forked from ivanvermeyen/EnsureQueueListenerIsRunning.php
Ensure that the Laravel queue listener is running with "php artisan queue:checkup" and restart it if necessary. You can run this automatically with a cron job: http://laravel.com/docs/scheduling
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class EnsureQueueListenerIsRunning extends Command
{
/**
* The name and signature of the console command.
@nawie
nawie / DarkReader_GithubThemes.css
Last active August 6, 2021 03:40
Custom dark theme for Dark Reader extension on Github site
body {
background-color: #282a36 !important;
}
.Header, .Header-old {
background-color: #48396C !important;
}
@media (min-width: 1012px) {
.page-responsive .HeaderMenu-link {
color: #dfb4fb;
}
@nawie
nawie / attrdict.py
Created December 18, 2019 02:03 — forked from turicas/attrdict.py
Python class with dict-like get/set item
#!/usr/bin/env python
# coding: utf-8
class AttrDict(object):
def __init__(self, init=None):
if init is not None:
self.__dict__.update(init)
def __getitem__(self, key):
return self.__dict__[key]

VIM do operation on selected column in single line

command: '<,'>s/%V(regex)%V/(operation)&/g

example

change query column into uppercase
@nawie
nawie / multireplace.py
Created October 16, 2019 08:29 — forked from bgusach/multireplace.py
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
"""
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
"""
@nawie
nawie / regexCheatsheet.js
Created September 26, 2019 04:32 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
# KDE
# create right click action, to open xterm alongside konsole
# location: /usr/share/kservices5/ServiceMenus
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openXTerminalHere;
X-KDE-AuthorizeAction=shell_access
@nawie
nawie / xor.py
Last active September 3, 2019 04:52 — forked from revolunet/xor.py
Simple python XOR encrypt/decrypt
#
# NB : this is not secure
# from http://code.activestate.com/recipes/266586-simple-xor-keyword-encryption/
# added base64 encoding for simple querystring :)
#
# modify for compatibility on python 3
import sys
import base64

Setup Android Studio on Fedora

1. install Oracle Java JDK 8+

- download via curl:

    curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm'
  • install: