Skip to content

Instantly share code, notes, and snippets.

View mislav's full-sized avatar

Mislav Marohnić mislav

View GitHub Profile
@nat
nat / auth.py
Last active December 7, 2020 05:33
Authenticate with GitHub from Python using the new device auth flow
#!/usr/bin/env python3
#
# Implements the GitHub device auth flow described here:
# https://docs.github.com/en/free-pro-team@latest/developers/apps/authorizing-oauth-apps#device-flow
from urllib.parse import parse_qs
import urllib, requests, time, webbrowser, json
client_id ='a945f87ad537bfddb109'
@swinton
swinton / README.md
Last active December 5, 2024 15:41
Automatically sign your commits from GitHub Actions, using the REST API

Verified commits made easy with GitHub Actions

image

So you want to commit changes generated by a GitHub Actions workflow back to your repo, and have that commit signed automatically?

Here's one way this is possible, using the REST API, the auto-generated GITHUB_TOKEN, and the GitHub CLI, gh, which is pre-installed on GitHub's hosted Actions runners.

You don't have to configure the git client, just add a step like the one below... Be sure to edit FILE_TO_COMMIT and DESTINATION_BRANCH to suit your needs.

@imjasonh
imjasonh / markdown.css
Last active November 6, 2024 14:26
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@sjl
sjl / ext.vim
Created December 15, 2014 18:58
ways to run external commands in vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@tpope
tpope / githubmail.rb
Created March 19, 2014 01:00
Add a gmail label to all closed issues where I the tpope last commented
require 'gmail'
require 'github_api'
require 'netrc'
require 'pry'
netrc = Netrc.read
github = Github.new(basic_auth: netrc['api.github.com'].join(':'))
Gmail.new(*netrc['imap.gmail.com']) do |gmail|
gmail.inbox.emails(from: 'github.com').each do |message|
begin
@martijnvermaat
martijnvermaat / ssh-agent-forwarding-screen.md
Created December 21, 2013 15:06
SSH agent forwarding and screen

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@jasonrudolph
jasonrudolph / 00-about-search-api-examples.md
Last active November 25, 2024 09:57
5 entertaining things you can find with the GitHub Search API
@stympy
stympy / campfire.rb
Last active December 18, 2015 10:09
Easy post to a campfire room using faraday
class Campfire
def initialize(domain, token)
@client = Faraday.new(:url => "https://#{domain}.campfirenow.com") do |faraday|
faraday.basic_auth(token, 'X')
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
end
end
def speak(room, message)
@sstephenson
sstephenson / Simple Encryption.md
Created April 11, 2013 23:48
Simple file/stream encryption using OpenSSL

Simple file/stream encryption using OpenSSL

Create and store a 512-byte random encryption key named secret:

$ mkkey secret

Encrypt the contents of file with the secret key and write it to file.enc:

$ encrypt secret < file > file.enc
@sstephenson
sstephenson / super.bash
Last active January 30, 2017 01:40
`super` in Bash
#!/usr/bin/env bash
source super.bash
foo() {
echo hello
}
super_function foo
foo() {