Skip to content

Instantly share code, notes, and snippets.

@infews
infews / be.rb
Last active July 5, 2021 22:51
a "better" be "alias" for bundle exec, prioritizing local binstubs
#!/usr/bin/env ruby
# Smarter be for ruby projects that prioritizes local project binstubs
# - uses zsh when needed, assuming MacOS Catalina or later
# - save on your path
# - drop the .rb
# - chmod +x
# - always type `be <command>` and the right thing should happen
#
# - inspired by Justin Searls (@searls)
@swinton
swinton / README.md
Last active September 1, 2024 00: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.

@MineRobber9000
MineRobber9000 / 2fa
Created April 3, 2020 03:45
2-factor authentication terminal app in Python
#!/usr/bin/env python
import os, os.path, stat, sys, base64
# TOTP lib inlined
import time, hmac, base64, hashlib, struct
def pack_counter(t):
return struct.pack(">Q", t)
@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@manasthakur
manasthakur / submodules.md
Last active July 24, 2024 01:20
Using git submodules to version-control Vim plugins

Using git-submodules to version-control Vim plugins

If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need. Thus, you should keep the .vim directory along with your .vimrc version-controlled.

But when you have plugins installed inside .vim/bundle (if you use pathogen), or inside .vim/pack (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

Creating the repository

Initialize a git repository inside your .vim directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:

cd ~/.vim
@danthegoodman
danthegoodman / AppTest.java
Created October 7, 2016 16:33
Ratpack SNI Workaround
import ratpack.http.client.HttpClient;
import ratpack.test.embed.EmbeddedApp;
import javax.net.ssl.SniSslContext;
import java.net.URI;
class AppTest {
static void main(String[] args) throws Exception {
EmbeddedApp.fromHandler(ctx -> {
URI uri = URI.create("#### A URL POINTING TO A SERVER USING SNI SSL ####");

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@childnode
childnode / ServiceModule.java
Created March 7, 2016 16:22
Example Ratpack Server start chain with guice registry and
package de.childno.example.ratpack;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Provides;
public class ServiceModule extends AbstractModule {
@Override
protected void configure() { }