Skip to content

Instantly share code, notes, and snippets.

@juergenhoetzel
juergenhoetzel / terminal-ssh-host-title.sh
Created December 22, 2010 09:36
Set Window Title using OpenSSHs LocalCommand
LocalCommand echo -ne "\033]0;"%r@%h"\007"
PermitLocalCommand yes
@mdeous
mdeous / gist:823821
Created February 12, 2011 15:27
example: parsing html with lxml and xpath
import lxml.html
html = lxml.html.parse("http://pypi.python.org/pypi") # can take an url, a filename or an object with a .read() method
packages = html.xpath('//tr/td/a/text()') # get the text inside all "<tr><td><a ...>text</a></td></tr>"
print packages
Out[7]:
[u'celery\xa02.2.3',
u'django-celery\xa02.2.3',
u'kombu\xa01.0.3',
@andris9
andris9 / git-cache-meta.sh
Created March 5, 2012 13:15
git-cache-meta
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
@joshellington
joshellington / sftp-ubuntu.md
Created March 28, 2012 07:07
Basic tutorial for creating a SFTP-only user on Ubuntu 9.04 and greater

Adding SFTP-only user to Ubuntu Server

To add a SFTP-only user, you'll need to make sure your SSH config settings are correct, add a new user/group and set permissions for your new user. For step-by-step directions, see below. Omit sudo if you're logged in as root.

Directions

  1. Edit /etc/ssh/sshd_config and make sure to add the following at the end of the file:

     Match group filetransfer
    

ChrootDirectory %h

@hSATAC
hSATAC / hostname.rb
Created June 7, 2012 07:48
aws ec2 set hostname by tag name
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
instance_id = `wget "http://169.254.169.254/latest/meta-data/instance-id" -o /dev/null -O /dev/stdout`
config = {:access_key_id => '',
:secret_access_key => ''}
AWS.config(config)
ec2 = AWS::EC2.new
ec2 = ec2.regions['ap-northeast-1']
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 19, 2024 10:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@gsomoza
gsomoza / gist:3910863
Created October 18, 2012 10:11
EC2 Bash Prompt
#!/bin/bash
#Set colour prompt using the name, platform or instance id and avzone
if [ ! -f "/opt/aws/AWS-INSTID" ]; then
curl -s --fail http://169.254.169.254/latest/meta-data/instance-id > /opt/aws/AWS-INSTID
fi
export INSTID=`cat /opt/aws/AWS-INSTID`
if [ ! -f "/opt/aws/AWS-AVZONE" ]; then
curl -s --fail http://169.254.169.254/latest/meta-data/placement/availability-zone > /opt/aws/AWS-AVZONE
@miguelgrinberg
miguelgrinberg / rest-server.py
Last active August 4, 2024 14:41
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':
@rmoriz
rmoriz / 1_smime-clients.md
Last active November 3, 2024 18:37
S/MIME is the industry standard for secure E-Mail and build into every relevant mail client. From Outlook to Thunderbird, from Blackberry to Apple Mail on OSX and iOS. http://smime.io/
@janich
janich / exportMysqlUsers.php
Created July 31, 2013 13:02
Export MySQL users and permissions
<?php
/**
* Export MySQL users and permissions
*
* This script exports raw CREATE USER and GRANT queries of a given database
* to help migrate MySQL users and permissions to a new server.
* Users will keep their passwords across the migration.
*
* Warning: The import queries expects exactly the same database structure!
*