Skip to content

Instantly share code, notes, and snippets.

View kornysietsma's full-sized avatar

Korny Sietsma kornysietsma

View GitHub Profile
@kornysietsma
kornysietsma / fetch_org_repos.rb
Created November 14, 2022 12:38
script to clone all repos for an organisation
#!/usr/bin/env ruby
require "graphql/client"
require "graphql/client/http"
require "json"
require 'set'
require 'pp'
MAX_PAGES = 999
const fooMembers = new Set([1,2]);
const barMembers = new Set([1,3]);
const groups: Map<Set<number>, String> = new Map();
groups.set(fooMembers,"foo");
groups.set(barMembers,"bar");
console.log(groups.get(fooMembers));
console.log(groups.get(new Set([1,2])));
#![forbid(unsafe_code)]
#![warn(clippy::all)]
#![warn(rust_2018_idioms)]
pub mod mymodule;
use std::ffi::OsString;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
@kornysietsma
kornysietsma / main.rs
Created September 7, 2019 18:17
byte regex fail
use regex::bytes::Regex;
fn main() {
let re = Regex::new(r"^(.*)$").unwrap();
let line: Vec<u8> = vec![
46, 45, 191, 87, 110, 176, 108, 158, 46, 45, 191, 87, 110, 176, 108, 158,
];
let s = std::str::from_utf8(&line);
if s.is_err() {
println!("Error in converting from utf8:{:?}", s);
@kornysietsma
kornysietsma / using_slow_to_string.rs
Created April 26, 2019 07:51
experimenting with rust traits and PartialEq
#![warn(clippy::all)]
#![allow(dead_code)]
use serde::ser::SerializeStruct;
use serde::ser::SerializeTuple;
use serde::{Serialize, Serializer};
use std::fmt;
use std::collections::HashMap;
use std::fmt::Debug;
@kornysietsma
kornysietsma / app.rs
Last active February 11, 2019 16:13
Slack actions and buttons in rust
extern crate actix;
extern crate actix_web;
extern crate bytes;
extern crate env_logger;
extern crate futures;
#[macro_use]
extern crate json;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
@kornysietsma
kornysietsma / github_releases.rb
Created June 1, 2018 12:53
Sample ruby code for paginated graphql queries
#!/usr/bin/env ruby
require 'graphql/client'
require 'graphql/client/http'
require 'json'
require 'pp'
require 'slop'
# The GraphQL gem _forces_ us to make the client a constant:
# https://github.com/github/graphql-client/blob/master/guides/dynamic-query-error.md
@kornysietsma
kornysietsma / github_api.sh
Last active October 12, 2021 11:15
curl while hiding secrets for github api
#!/bin/bash -eu
# uses 1pass to get token from 1password vault
export GITHUB_API_TOKEN=`1pass "github api token"`
function ghapi() {
# escape double quotes as we need to insert the passed heredoc into a json string
# optionally we could build this with jq?
local json=$(cat | sed 's/"/\\"/g')
curl -sS -K <(cat <<<"header \"Authorization: token $GITHUB_API_TOKEN\"") -X POST https://api.github.com/graphql -d @- <<EOT
@kornysietsma
kornysietsma / Stream bits
Created March 9, 2017 16:04
Java 8 snippets
// turn a stream into a group
Map<String, Long> counting = items.stream().collect(
Collectors.groupingBy(Item::getName, Collectors.counting()));
@kornysietsma
kornysietsma / Gemfile
Created February 28, 2017 10:58
asciidoc bits
source 'https://rubygems.org'
gem 'asciidoctor-pdf', '>= 1.5.0.alpha.11'
gem 'asciidoctor'
gem 'asciidoctor-diagram', '~> 1.5.1'
gem 'rake'
gem 'coderay'
gem 'pygments.rb'
gem 'git'
gem 'edn'