Skip to content

Instantly share code, notes, and snippets.

@envomer
envomer / upgrade.sh
Created May 13, 2023 09:27
Upgrade the current version according to semver of pubspec.yaml file (build, patch, minor, major)
#!/bin/bash
# Function to extract version number from pubspec.yaml file
get_version() {
local version_line=$(grep -m1 "^version:" pubspec.yaml)
local version=$(echo $version_line | cut -d' ' -f2)
echo $version
}
# Function to update the version based on semver
const colors = {
Slate50: '#f8fafc',
Slate100: '#f1f5f9',
Slate200: '#e2e8f0',
Slate300: '#cbd5e1',
Slate400: '#94a3b8',
Slate500: '#64748b',
Slate600: '#475569',
Slate700: '#334155',
Slate800: '#1e293b',
// Authoer: The SwiftUI Lab
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/
import SwiftUI
struct RefreshableScrollView<Content: View>: View {
@State private var previousScrollOffset: CGFloat = 0
@State private var scrollOffset: CGFloat = 0
@State private var frozen: Bool = false
@State private var rotation: Angle = .degrees(0)
@envomer
envomer / CronSchedule.php
Created October 11, 2019 20:29 — forked from m4tthumphrey/CronSchedule.php
CronSchedule.php - Allows one to parse a cron expression into human readable text.
<?php
/*
* Plugin: StreamlineFoundation
*
* Class: Schedule
*
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back
* and forth between scheduled moments in time and translating the created schedule back to a human readable form.
*
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format.
@envomer
envomer / strip_markdown.php
Created September 28, 2019 13:35 — forked from tobsn/strip_markdown.php
Strips Markdown from Text - PHP port of https://github.com/stiang/remove-markdown
<?php
function strip_markdown( $md = '', $options = [] ) {
// char to insert instead of stripped list leaders (default: '')
$options['listUnicodeChar'] = isset( $options['listUnicodeChar'] ) ? $options['listUnicodeChar'] : false;
// strip list leaders (default: true)
$options['stripListLeaders'] = isset( $options['stripListLeaders'] ) ? $options['stripListLeaders'] : true;
// support GitHub-Flavored Markdown (default: true)
$options['gfm'] = isset( $options['gfm'] ) ? $options['gfm'] : true;
@envomer
envomer / golang_pipe_http_response.go
Created July 1, 2019 17:04 — forked from ifels/golang_pipe_http_response.go
golang pipe the http response
package main
import (
"io"
"net/http"
"os/exec"
)
var (
BUF_LEN = 1024
const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
@envomer
envomer / ICS.php
Created January 11, 2019 18:24 — forked from jakebellacera/ICS.php
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* ICS.php
* =======
* Use this class to create an .ics file.
*
* Usage
* -----
* Basic usage - generate ics file contents (see below for available properties):
@envomer
envomer / README.md
Created June 30, 2018 10:27 — forked from potch/README.md
JSON Style Sheets. Because why not.

JSS: JSON Style Sheets

“Wait, what?”

Sometimes you want to include some CSS in a JavaScript file. Maybe it's a standalone widget. A big ol' string is a pain to manage, and won't minify so pretty. Especially if you want your CSS safely namespaced. For example:

.widget {
    background: #abc123;
    width: 100px;

/* ... */

@envomer
envomer / AES-256 encryption and decryption in PHP and C#.md
Created May 27, 2018 10:00
AES-256 encryption and decryption in PHP and C#

AES-256 encryption and decryption in PHP and C#

Update: There is a more secure version available. Details

PHP

<?php

$plaintext = 'My secret message 1234';