Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
# First, close Google Chrome.
# unload the Keystone agent
find /Library/Launch* ~/Library/LaunchAgents -maxdepth 1 -iname 'com.google.*' | xargs -L1 launchctl unload
# prevent it from starting again (note: you could also back up the files by moving them elsewhere)
find /Library/Launch* ~/Library/LaunchAgents -maxdepth 1 -iname 'com.google.*' | xargs rm -v
# Warning: it's likely that running Google Chrome after this will restore these files.
# If it doesn't, consider that automatic Chrome updates will be DISABLED. Use at own risk.
@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/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 April 15, 2020 11:59
GraphQL mutation example with hub & jq
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 October 30, 2019 16:27
Download `bin/hub` for the current environment
#!/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 January 24, 2024 23:38
hub api example of how to fetch all comments over GraphQL
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 October 5, 2018 18:33 — forked from benzap/MultiLinkedList.sol
Multi Linked List Implementation in Solidity
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 October 24, 2017 10:18
Go program to untar multiple gzipped tarballs listed on the command line
package main
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
)
@mislav
mislav / es6-symbol-iterators.js
Created August 31, 2017 11:38
DOM iterables on top of es6-symbol polyfill
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 July 24, 2017 22:32
Open specific editor based on directory contents
export EDITOR_XCODEPROJ='open -a XCode'
export EDITOR_TSCONFIG='code'
export EDITOR_DEFAULT='atom'
export EDITOR='magic-open'
@mislav
mislav / nginx.conf
Last active December 12, 2024 04:19
SSL nginx configuration for my personal site using Let's Encrypt https://certbot.eff.org/#ubuntutrusty-nginx
# 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;