Skip to content

Instantly share code, notes, and snippets.

antoni

Block or report user

Report or block antoni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Keybase identity proof
### Keybase proof
I hereby claim:
* I am antoni on github.
* I am antoni (https://keybase.io/antoni) on keybase.
* I have a public key ASAPlJzPyid_8vQoMmG2Dj5nzdugiKAYEtNIAJFGIA0AFgo
To claim this, I am signing this object:
View gist:ab29e5d2a9aee3aeea41
# Move code from one repo to another, preserving commit history
# Source: http://stackoverflow.com/a/17373088/963881
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
git merge r1remote/master
git remote rm r1remote
# Push to master without having to --set-upstream-to first
@antoni
antoni / keybase.md
Created Mar 18, 2019 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key
View keybase.md

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key

@antoni
antoni / sudo-keepalive-example.sh
Created Jan 6, 2019 — forked from cowboy/sudo-keepalive-example.sh
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
View sudo-keepalive-example.sh
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {
View replace_in_origin.sh
#!/usr/bin/env bash
: ' Usage:
bash <(wget --quiet --output-document=- https://gist.githubusercontent.com/antoni/0baa816895d7155c7f41e155e2ee7f70/raw)
'
# Replaces $1 with $2 in the origin named 'origin' of Git repo
# Should be executed from inside of the repository folder
function replace_in_origin() {
View gist:a98b6e4b7ecea3b0374faa95cd3a5d6a
### Keybase proof
I hereby claim:
* I am antoni on github.
* I am antoni (https://keybase.io/antoni) on keybase.
* I have a public key ASBjyuQy5Z1RKEScj1d1U_KBa_wNzjunfSWleyf_ITIoLAo
To claim this, I am signing this object:
@antoni
antoni / tmux-cheats.md
Created Feb 11, 2018 — forked from Starefossen/tmux-cheats.md
My personal tmux cheat sheet for working with sessions, windows, and panes. `NB` I have remapped the command prefix to `ctrl` + `a`.
View tmux-cheats.md

Sessions

New Session

  • tmux new [-s name] [cmd] (:new) - new session

Switch Session

  • tmux ls (:ls) - list sessions
  • tmux switch [-t name] (:switch) - switches to an existing session
@antoni
antoni / json_stringify_once.js
Created Aug 1, 2017
Dumps an object in JSON. Works with circular JSON structures
View json_stringify_once.js
// Dumps an object in JSON. Works with circular structures like:
//
// var o = {};
// o.o = o;
JSON.stringifyOnce = function(obj, replacer, indent){
var printedObjects = [];
var printedObjectKeys = [];
function printOnceReplacer(key, value){
if ( printedObjects.length > 2000){ // browsers will not print more than 20K, I don't see the point to allow 2K.. algorithm will not be fast anyway if we have too many objects
View stdc++.h
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@antoni
antoni / custom_json.go
Created Jul 12, 2017 — forked from mdwhatcott/custom_json.go
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
View custom_json.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
You can’t perform that action at this time.