Skip to content

Instantly share code, notes, and snippets.

View osbre's full-sized avatar
🇺🇦
#StandWithUkraine

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
class StreamPot {
num = 0;
doIt() {
this.num += 42;
return this;
}
}
const streamPotFactory = () => new Proxy(new StreamPot, {
get: (target, prop, receiver) => {
# Set default values
repository="git@github.com:user/project.git"
branch="main"
new_release=$(date '+%s')
set -e
mkdir -p releases
cd releases || exit 1
function deploy() {
@osbre
osbre / RemoveReturnTypesFromControllersRector.php
Last active September 15, 2023 11:18
Laravel Shift broke the project by adding return types to controller methods when upgrading to Laravel 10. This rector removes the return types from the controller methods.
<?php
namespace App\Rector;
use Illuminate\Routing\Controller;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* Re-creates all <template> tags within <svg> elements as "DOM" elements to overcome browser limitations.
* This is necessary because HTML tags inside an SVG element have an SVG namespace, which may lack proper support.
* https://github.com/whatwg/html/issues/3563
* https://github.com/alpinejs/alpine/issues/637#issuecomment-654856538
*/
const recreateTemplates = (templates: NodeListOf<Element>) => {
let el: Element,
template: HTMLTemplateElement,
attrs: NamedNodeMap,
@osbre
osbre / sublime-text.json
Last active August 26, 2023 21:50
My Sublime Text 4 settings. Plugins: Editorconfig, LSP, LSP, Vue, LSP Vue, LSP Elixir
{
"ignored_packages":
[
"Vintage",
],
"color_scheme": "Packages/Inspired GitHub Color Scheme/InspiredGitHub.tmTheme",
"font_face": "IBM Plex Mono",
"font_size": 20,
"line_padding_top": 10,
"line_padding_bottom": 10,
@osbre
osbre / fix-sublime-package-control-on-mac-os.sh
Created August 5, 2023 12:33
How to fix Sublime Text 4 Package Control on macOS Venture
ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/
@osbre
osbre / howto.sh
Last active April 27, 2023 15:43
Run local PostgreSQL 15 container via Docker
docker run \
--name postgres15 \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=justpgdb \
-v pgdata:/var/lib/postgresql/data \
-d \
postgres:15
@osbre
osbre / payments.ex
Last active January 18, 2023 21:45
From ChatGPT, Paddle API module
defmodule MyApp.Payments do
use HTTPoison.Base
@moduledoc """
Payment processing using the Paddle API with HTTPoison.
"""
@paddle_vendor_id "12345"
@paddle_vendor_auth_code "abcdefg"
@paddle_base_url "https://vendors.paddle.com/api/2.0"
<script setup>
defineProps({
modelValue: {
type: Boolean,
required: true,
},
title: {
type: String,
required: true,
},
<!--
Usage: <Switch v-model="notifications" />
-->
<script setup>
import {Switch} from '@headlessui/vue'
const props = defineProps({
modelValue: {
type: Boolean,