Skip to content

Instantly share code, notes, and snippets.

View simon-engledew's full-sized avatar
🙈

Simon Engledew simon-engledew

🙈
View GitHub Profile
wut = for-each-ref --no-merged refs/remotes/origin/HEAD --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
<div class="d-inline-block" style="height:<%= size %>px;width:<%= size %>px;position:relative">
<svg aria-label="<%= value %> / <%= total %>" viewBox="0 0 100 100" height="<%= size %>" width="<%= size %>">
<path fill="var(--color-<%= donut_color %>-muted)" d="<%= self.command(100) %>" />
<% if value_percent > 0 %>
<path transform="scale(-1,1) rotate(-90)" transform-origin="50% 50%" fill="var(--color-<%= donut_color %>-emphasis)" d="<%= self.command(self.value_percent) %>" />
<% end %>
</svg>
<%= render(Primer::Beta::Text.new(position: :absolute, color: color, tag: :p, mb: 0, font_size: font_size, font_weight: :bold, style: "top:50%;left:50%;transform:translate(-50%,-50%)")) do %>
<% if total.nonzero? %>
<%= value_percent %><%= render(Primer::Beta::Text.new(tag: :span, font_size: 4, font_weight: :bold)) { "%" } %>
package server
import (
"fmt"
"reflect"
"go.starlark.net/starlark"
)
func toValue(v interface{}) starlark.Value {
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SARIF 2.1.0 for GitHub Code Scanning",
"$id": "https://raw.githubusercontent.com/github/turboscan/main/ts/sarif/v2_1_0_turboscan/v2_1_0_turboscan.json",
"description": "A schema detailing the sections of the SARIF 2.1.0 specification that are used by GitHub Code Scanning.",
"type": "object",
"properties": {
"$schema": {
"description": "The URI of the JSON schema corresponding to the version.",
"type": "string",
require "pathspec/gitignorespec"
class Codeowners
def initialize(codeowners)
@captures, @index = codeowners.each_line(chomp: true).map(&:strip).reject { |line| line.empty? || line.start_with?("#") }.map { |line| line.split(/\s+/, 2) }.map do |glob, owners|
pattern = ::GitIgnoreSpec.new(glob).instance_variable_get(:@regex)
["(#{pattern})", owners.split(/\s+/)]
end.reverse.transpose
@simon-engledew
simon-engledew / git-wut.sh
Created October 30, 2020 21:26
Git wut alias, recent branches last
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
@simon-engledew
simon-engledew / Makefile
Last active September 4, 2020 15:19
tiny random password generator
pwgen: main.c
gcc -lsodium -o $@ $<
@simon-engledew
simon-engledew / retry.go
Created August 21, 2020 10:23
Simple retry mechanism with delay and backoff
package main
import (
"time"
"fmt"
)
func pow(a, b int) int {
p := 1
for b > 0 {
@simon-engledew
simon-engledew / carousel.tsx
Created August 11, 2020 14:52
Animated text carousel with no dependencies.
@simon-engledew
simon-engledew / json_merge_objects.sql
Created July 16, 2020 13:18
Postgres || for json instead of jsonb
CREATE OR REPLACE FUNCTION json_merge_objects(a json, b json) RETURNS json
LANGUAGE SQL IMMUTABLE AS $$
WITH combined AS (
SELECT pair.key, pair.value FROM json_each(a) AS pair
UNION ALL
SELECT pair.key, pair.value FROM json_each(b) AS pair
)
SELECT json_object_agg(key, value)
FROM combined
$$;