Skip to content

Instantly share code, notes, and snippets.

View eschmar's full-sized avatar

Marcel Eschmann eschmar

View GitHub Profile
eschmar / BlogCaptureXcodePlayground.swift
Last active March 5, 2023 15:54
Blog: Capture Xcode Playground SwiftUI animations as mp4
* **Step 3**: Render all the frames
* This is the accompayning code of a blog post. Read more at
import SwiftUI
import PlaygroundSupport
struct MyExperimentalView: View {
eschmar / AngularGradient.swift
Created February 27, 2023 19:07
SwiftUI gradient along a circular path animation
//: A SwiftUI based playground.
import SwiftUI
import PlaygroundSupport
struct MyShape : Shape {
var startAngle: Double
var progress: Double
func path(in rect: CGRect) -> Path {
eschmar /
Last active December 5, 2022 10:38
Google sheets (Apps Script) custom function to count cells with a given background color.
* Counts cell values in a range if they have the given background color
* =countByColor("V16", "S12:W20")
* @param {String} Cell reference for color to compare as String.
* @param {String} Range to iterate through as String.
* @return {int} Count of all cells matching background color.
function countByColor(cellColorToCompare, rangeToCount) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
eschmar /
Last active August 15, 2020 12:38
Bash script to iterate over set of images, setting creation date
# Whatsapp 'WhatsApp Image 2020-08-13 at 21.06.23.jpeg'
for file in ./*.jpeg; do
echo " > $file"
eschmar / index.twig
Created October 28, 2018 10:20
Inject the data encoded in JSON
Inject the data encoded in JSON in a `<script type="application/json">` tag.
Then access to this element in JS and call `JSON.parse`.
It's secure, elegant and works even with the strictest CSPs.
# Create display override file to force Mac OS X to use RGB mode for Display
# see
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
eschmar /
Created December 22, 2014 10:03
Large MySQL dump import
# shorthand
mysql -u root <database_name> < <sql_file_path>
# long
mysql -u root -p
use <database_name>
source <sql_file_path>
# windows phpmyadmin alias
importmysql=C:\xampp\mysql\bin\mysql.exe -u root $1 < $2
eschmar / queries.sql
Last active January 2, 2016 20:29
Handy mysql queries
-- Average length of a text column
SELECT AVG(LENGTH(content)) AS length FROM `column` WHERE content!='';
-- Maximum length of a text column
SELECT MAX(LENGTH(content)) AS length FROM `column` WHERE content!='';