Skip to content

Instantly share code, notes, and snippets.

@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@ezhuravlev
ezhuravlev / CentOS chkconfig script headers
Last active December 8, 2021 16:05
service <servicename> does not support chkconfig (CentOS)
/etc/init.d/<servicename>:
# chkconfig: 345 20 80
# description: my service
345 - 3,4,5 runlevels
20 - start priority
80- stop prioroty
@miguelgrinberg
miguelgrinberg / rest-server.py
Last active March 29, 2024 09:05
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
## credit: http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansible/
---
- hosts: alpine_install
user: root
tasks:
# - name: create a complete empty file
# command: /usr/bin/touch /test/test.conf
- name: create a new file with lineinfile
@bmnn
bmnn / gist:8149899
Created December 27, 2013 17:24
emacs; auto-complete; all buffers;
(require 'auto-complete-config)
(ac-config-default)
(setq-default
ac-sources '(
ac-source-words-in-all-buffer
ac-source-words-in-buffer
ac-source-files-in-current-dir
)
)

Emacs Lesson 1

Keybindings Cheatsheet

Getting out
C-x C-cExit emacssave-buffers-kill-terminal
C-gCancel running or partially typed commandkeyboard-quit
@garaud
garaud / pipe-to-emacs.py
Last active October 3, 2023 13:11
Pipe to Emacs: Insert a result from an UNIX command into a new Emacs buffer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Damien Garaud
# Date: 2014-2015
# License: Simplified BSD
"""Allow you to pipe command results into an Emacs buffer. Suppose you have an
Emacs server since you launch 'emacsclient'.
@dragonjet
dragonjet / 1-server.md
Last active July 31, 2021 21:01
Setup Web Server on EC2 Amazon Linux AMI

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
#!/usr/bin/env python
# org-mode-agenda-push-bullet.py
# Load org-mode agenda items, then push each item as a notification with PushBullet.
# Notication form:
# - Title: "Agenda Item: <CATEGORY>"
# - Note: "<TODO ITEM>"
from subprocess import Popen, PIPE
#from time import strptime
@michaelrice
michaelrice / dirty_work_around.patch
Created May 7, 2015 19:53
dirty work around to make python 2.7.9 work for pyvmomi
diff --git a/samples/hello_world_vcenter.py b/samples/hello_world_vcenter.py
index 1320d05..eafa840 100755
--- a/samples/hello_world_vcenter.py
+++ b/samples/hello_world_vcenter.py
@@ -22,6 +22,19 @@ a friendly encouragement to joining the community!
import atexit
import argparse
import getpass
+import requests
+requests.packages.urllib3.disable_warnings()