This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chmouel.ukcloud.test; | |
import java.util.Properties; | |
import org.jclouds.blobstore.BlobStoreContext; | |
import org.jclouds.blobstore.BlobStoreContextFactory; | |
public class Main { | |
public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.chmouel.ukcloud.test; | |
import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.withDetails; | |
import java.util.Properties; | |
import java.util.Set; | |
import org.jclouds.compute.ComputeServiceContext; | |
import org.jclouds.compute.ComputeServiceContextFactory; | |
import org.jclouds.rackspace.cloudservers.CloudServersClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libcloud.types import Provider | |
from libcloud.providers import get_driver | |
RACKSPACE_USER="USERNAME" | |
RACKSPACE_KEY="API_KEY" | |
Driver = get_driver(Provider.RACKSPACE_LON) | |
conn = Driver(RACKSPACE_USER, RACKSPACE_KEY) | |
print conn.list_nodes() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: snippet -*- | |
# name: newt | |
# -- | |
${1:TYPE} ${1:$(downcase text)} = new $1(); | |
$0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRENT_SEL=$(pbpaste) | |
if [[ -n $1 ]];then | |
URL=$1 | |
fi | |
if [[ -z $URL ]];then | |
if [[ ${CURRENT_SEL} == http://* ]];then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
__author__ = "Chmouel Boudjnah <[email protected]>" | |
binhexjpg="ffd8ffe000104a464946" | |
import sys | |
import binascii | |
if len(sys.argv) >= 2: | |
ff = sys.argv[1] | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun get-ip (interface) | |
(save-excursion | |
(with-temp-buffer | |
(call-process "/sbin/ifconfig" nil t nil "-a") | |
(goto-char (point-min)) | |
(when (re-search-forward interface nil t) | |
(case system-type | |
(gnu/linux (re-search-forward "inet addr:\\([^ ]*\\)")) | |
(darwin (re-search-forward "inet \\([^ ]*\\)" nil t))) | |
(buffer-substring (match-beginning 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reboot server by ID | |
Requirement: python-cloudservers library from | |
https://github.com/chmouel/python-cloudservers | |
""" | |
import cloudservers | |
# Server ID to shut-down | |
SERVER_ID = 10010547 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Implement a client for Rackspace Cloud Servers or Cloud | |
Files using pure python. | |
''' | |
import httplib | |
import urlparse | |
def get_auth(username, key, auth_url): | |
u = urlparse.urlparse(auth_url) | |
cls = u.scheme == 'https' and \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -c 'import socket;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect(("localhost", 2022))' >/dev/null 2>/dev/null || blah_launch_server |