Skip to content

Instantly share code, notes, and snippets.

@Fleshgrinder
Fleshgrinder / gh-delete-workflow.sh
Last active October 6, 2022 14:45
Deletes a GitHub Workflow by deleting all its Runs.
#!/usr/bin/env bash
set -Eeuo pipefail
# There is no button in the interface of GitHub (and as it seems also no API) with which workflows can be deleted.
# They are eventually removed automatically, but in case you want to clean up your Actions UI it is sometimes nice
# to have the possibility to get rid of workflows that are not required anymore. This interactive script allows you
# to achieve exactly that by deleting each individual run of a workflow, after which GitHub deletes the workflow.
declare -ir CONCURRENCY=${CONCURRENCY:-8}
@masklinn
masklinn / cheatsheet.md
Last active March 24, 2024 09:21
launchctl/launchd cheat sheet

I've never had great understanding of launchctl but the deprecation of the old commands with launchctl 2 (10.10) has been terrible as all resources only cover the old commands, and documentation for Apple utilities is generally disgracefully bad, with launchctl not dissembling.

Mad props to https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/ which contains most details

domains

Internally, launchd has several domains, but launchctl 1 would only ask for service names,

@boxdot
boxdot / async.rs
Last active November 9, 2022 12:03
Async stdin reading with thread and futures in Rust
extern crate futures;
use std::io::{self, BufRead};
use std::thread;
use futures::{Future, Sink, Stream};
use futures::stream::BoxStream;
use futures::sync::mpsc::channel;
fn stdin() -> impl Stream<String, io::Error> {
@kixorz
kixorz / aws_iam_policy.json
Last active April 11, 2022 10:32
Update Route53 DNS records from your EC2 instance using this simple Ruby script. You can call it from rc.local after setting your hostname locally. First parameter is the desired <hostname>.<domain> Domain and other parameters are hardcoded. This script is useful for handling internal DNS changes in your systems after instance changes. Attached …
{
"Statement": [
{
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect": "Allow",
"Resource": [
@gferon
gferon / PaginationSkin.java
Created January 24, 2013 19:16
The PaginationSkin.java class from OpenJFX 2.2.2 controls/rt without the page flip animation. It's quite barbaric right now, but I needed a quick fix. I'll refactor the class to remove everything dealing with the page flip animation later.
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@mystix
mystix / Observer.php
Last active July 6, 2021 05:23
Delete abandoned Magento shopping carts -- see http://www.magentocommerce.com/boards/viewthread/53981/P15/
<?php
/*
To make the cleaning expired carts automatic, override cleanExpiredQuotes with the following
version which will also take care of the old active carts: app/code/core/Mage/Sales/Model/Observer.php
*/
public function cleanExpiredQuotes($schedule)
{
// extending limit
@rnagle
rnagle / otf_get_attachment_image_src.php
Created April 12, 2012 12:46
WordPress: Generate thumbnails on-the-fly
<?php
/*
* Check for thumb of $size and generate it if it doesn't exist.
*
* @param int $post_id Post ID for which you want to retrieve thumbnail
* @param string $size Name of thumbnail size to check for; same as
* the slug used to add custom thumb sizes with add_image_size().
* @return array An array containing: array( 0 => url, 1 => width, 2 => height )
*
@msabramo
msabramo / git_prompt_info.zsh
Created April 11, 2012 00:07
The slowness of my zsh prompt when in a git-svn managed directory was killing me. I improved it by removing the git status stuff that slows it down...
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}