Skip to content

Instantly share code, notes, and snippets.

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
---
@tyrcho
tyrcho / git-subline-merge
Last active March 28, 2023 16:16
Script to accept Gitlab MRs when the pipeline has succeeded. Sample : https://gitlab.com/tyrcho/michel-steward/-/blob/master/.gitlab-ci.yml
#!/usr/bin/env python3
#
# git-subline-merge
#
# Created by Paul Altin on 02.03.18.
# Downloaded from https://github.com/paulaltin/git-subline-merge
#
# An interactive git merge driver which can resolve non-overlapping conflicts on individual or adjacent lines.
@tyrcho
tyrcho / mockHttpServer.sc
Created September 24, 2019 10:36
Demo of a mock HTTP server in scala (uses ammonite)
import $ivy.`com.squareup.okhttp:mockwebserver:2.5.0`
import com.squareup.okhttp.mockwebserver._
val ws = new MockWebServer
ws.start()
val url = ws.url("/test")
println(url)
val response = new MockResponse
response.setBody( """ { "key" : "value" } """)
@tyrcho
tyrcho / rebase_all.sh
Created August 26, 2019 13:07
Rebase on source branch all open MR for a user in a group
curl \
--header "PRIVATE-TOKEN: $GITLAB_PAT" \
"https://gitlab.com/api/v4/groups/$GROUP_ID/merge_requests?state=opened&scope=all&author_id=$AUTHOR_ID" \
| jq -r '.[] | "\(.project_id) \(.iid)"' \
| while read -r projectid mrid; do
curl -X PUT --header "PRIVATE-TOKEN: $GITLAB_PAT" "https://gitlab.com/api/v4/projects/$projectid/merge_requests/$mrid/rebase"
done
@tyrcho
tyrcho / google.js
Last active December 5, 2018 10:31
set google domain users as choices in a form
// see https://stackoverflow.com/questions/51025018/referenceerror-admindirectory-is-not-defined to activate AdminDirectory
// - resources > advanced google services > Admin Directory API > Activate
// - https://console.cloud.google.com/apis/api/admin.googleapis.com/overview?project=project-id-123456&authuser=1
function onOpen(e) {
FormApp.getUi()
.createAddonMenu()
.addItem('Update users', 'setUsers')
.addToUi();
}
@tyrcho
tyrcho / howto.md
Last active November 22, 2023 02:04
Git secret and CI
@tyrcho
tyrcho / activity.gpi
Last active May 18, 2021 07:10
Code Maat (Your Code as a Crime Scene) script
set xdata time
set timefmt "%Y-%m-%d"
set datafile separator ","
set format x "%Y-%m-%d"
set terminal png size 768,768 enhanced truecolor font 'Roboto,9'
set xlabel "Date"
set xlabel "LoC"
set pointsize 0.8
set border 11
set xtics out
@tyrcho
tyrcho / DemoFreeSpacingRegex.java
Created April 19, 2018 21:56
free-spacing regex demo in Java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DemoFreeSpacingRegex {
public static void main(String[] args) {
String re = "(?x)\n"
+ "# ?x is free-spacing flag to allow #comments, must be right at start of String\n"
+ "(19|20\\d\\d) # year (group 1)\n"
+ "[- /.] # separator\n"
@tyrcho
tyrcho / free-spacing-regex.scala
Last active April 19, 2018 19:42
Free Spacing Demo in Scala (add comments to your Regex)
val re = """(?x)
# Match a 20th or 21st century date in yyyy-mm-dd format
# ?x is free-spacing flag to allow #comments, must be right at start of String
(19|20)\d\d # year (group 1)
[- /.] # separator
(0[1-9]|1[012]) # month (group 2)
@tyrcho
tyrcho / install.sh
Last active September 7, 2017 10:18
My install commands for manjaro
#i3 window manager
sudo -E pacman -S --needed rofi i3-wm i3lock i3blocks i3status-manjaro i3-theme-dark lxappearance-gtk3
#need to run lxapparence afterwards to restore icons