Skip to content

Instantly share code, notes, and snippets.

Avatar

Mislav Marohnić mislav

View GitHub Profile
@mislav
mislav / gh-rename-master
Last active Jul 30, 2020
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
View gh-rename-master
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@mislav
mislav / hub-graphql-mutation.sh
Created Apr 15, 2020
GraphQL mutation example with hub & jq
View hub-graphql-mutation.sh
jq -R --slurp '{query: ., variables: {input: $ARGS.named}}' \
--arg name "hello-world" \
--arg visibility "PRIVATE" \
--arg ownerId "<ORG-NODEID>" \
--arg teamId "<TEAM-NODEID>" \
<<<'
mutation ($input: CreateRepositoryInput!) {
createRepository(input: $input) {
repository {
nameWithOwner
@mislav
mislav / hub-get.sh
Created Oct 30, 2019
Download `bin/hub` for the current environment
View hub-get.sh
#!/bin/bash
set -e
latest-version() {
curl -fsi https://github.com/github/hub/releases/latest | awk -F/ '/^Location:/ {print $(NF)}'
}
HUB_VERSION="${1#v}"
if [ -z "$HUB_VERSION" ]; then
latest=$(latest-version) || true
@mislav
mislav / hub-api-comments.sh
Last active Apr 27, 2020
hub api example of how to fetch all comments over GraphQL
View hub-api-comments.sh
comments() {
local issue="${1?}"
shift 1
paginate hub api --cache 3600 graphql -F issue="$issue" "$@" -f query='
query ($owner: String = "{owner}", $repo: String = "{repo}", $issue: Int!, $per_page: Int = 30, $after: String) {
repository(owner: $owner, name: $repo) {
issueOrPullRequest(number: $issue) {
... on Issue {
comments(first: $per_page, after: $after) {
...Comments
@mislav
mislav / MultiLinkedList.sol
Created Oct 5, 2018 — forked from benzap/MultiLinkedList.sol
Multi Linked List Implementation in Solidity
View MultiLinkedList.sol
pragma solidity ^0.4.24;
/*
Title:
Multiple Linked List Storage
Description:
Dynamic Storage Contract for storing multiple linked lists each
uniquely identified by a key. Implementation allows for
@mislav
mislav / untar.go
Created Oct 24, 2017
Go program to untar multiple gzipped tarballs listed on the command line
View untar.go
package main
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
)
@mislav
mislav / es6-symbol-iterators.js
Created Aug 31, 2017
DOM iterables on top of es6-symbol polyfill
View es6-symbol-iterators.js
function iterator() {
const self = this
let i = 0
return {
next: function() {
return {
done: i === self.length,
value: self[i++]
}
}
@mislav
mislav / bash_profile.sh
Last active Jul 24, 2017
Open specific editor based on directory contents
View bash_profile.sh
export EDITOR_XCODEPROJ='open -a XCode'
export EDITOR_TSCONFIG='code'
export EDITOR_DEFAULT='atom'
export EDITOR='magic-open'
@mislav
mislav / nginx.conf
Last active Apr 23, 2017
SSL nginx configuration for my personal site using Let's Encrypt https://certbot.eff.org/#ubuntutrusty-nginx
View nginx.conf
# primary HTTPS config
server {
listen 443 ssl;
server_name mislav.net;
ssl_certificate /etc/letsencrypt/live/mislav.net/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/mislav.net/privkey.pem;
root /home/app/blog/_site;
index index.html;
@mislav
mislav / star-trek-all.tsv
Last active Feb 9, 2020
List of Star Trek: The Original Series episodes ranked by their meta-score aggregated from several sites
View star-trek-all.tsv
S-EP episode title score
1-01 The Man Trap -33
1-02 Charlie X 26
1-03 Where No Man Has Gone Before 34
1-04 The Naked Time 64
1-05 The Enemy Within 30
1-06 Mudd's Women -31
1-07 What Are Little Girls Made Of? -1
1-08 Miri -30
1-09 Dagger of the Mind 8
You can’t perform that action at this time.