Skip to content

Instantly share code, notes, and snippets.

@a3linux
a3linux / index.html
Created January 6, 2016 01:57 — forked from agarzon/index.html
My Html5 template with Jquery and Bootstrap from CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Project Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
/*
* Template backbone.js code that encapsulates a
* datatable.net table within a view for a hypothetical ;)
* auction listings application.
*/
var HomeRouter = Backbone.Router.extend({
routes: {
'refresh' : 'refresh',
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''将搜狗拼音导出的文本词库转换成ibus-libpinyin的用户词典
by Conanca
'''
content = open("搜狗词库导出_2014_1_6.txt").read().decode('utf16').encode('utf8')
lines = content.split('\n')
f=open('ibus.txt','w')
# list_detail.object_list replacement with all the things I need
def object_list(request, queryset, extra_context=None,
template_name='', paginate_by=None):
class ObjectList(ListView):
def post(self, request, *args, **kwargs):
return self.get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
c = super(ObjectList, self).get_context_data(**kwargs)
import sys
import boto
import boto.ec2
def _launchAWSInstances():
connection = boto.ec2.connect_to_region(AWS_REGION, aws_access_key_id = AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_ACCESS_KEY_SECRET)
global reservation
reservation = connection.run_instances(AWS_AMI,
key_name=AWS_SSH_KEY_NAME,
instance_type=AWS_INSTANCE_SIZE,
from boto.iam import IAMConnection
iam = IAMConnection(aws_key, aws_secret)
iam.create_user('user')
iam.create_group('group')
iam.put_group_policy('group', 'EC2', '{"Statement":[{"Effect":"Allow","Action":"ec2:*","Resource":"*"}]}')
iam.add_user_to_group('group', 'user')
iam.create_access_key('user')
@a3linux
a3linux / ec2.pp
Created September 9, 2013 23:51 — forked from jperras/ec2.pp
# ec2utils: puppet recipes for use with Amazon's Elastic Compute Cloud (and
# associated services)
#
# Copyright 2009 Flock, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@a3linux
a3linux / motd.erb
Created September 9, 2013 23:47 — forked from harlanbarnes/motd.erb
<% if @banner -%><%= @banner -%><% end -%>
+----------------------------------------
|
| Host name: <%= node[:hostname] %>
| FQDN: <%= node[:fqdn] %>
| Distro / Arch: <%= node[:platform] %> <%= node[:platform_version] %> <%= node.kernel.machine %>
<% if node.attribute?('applogic') -%>
| App name: <%= node[:applogic][:APP_NAME] %>
| Comp name: <%= node[:applogic][:COMP_NAME] %>
<% end -%>
#!/usr/bin/env ruby
require 'aws-sdk'
require 'pp'
AWS.config(:proxy_uri => ENV['http_proxy'])
config_path = File.expand_path(File.dirname(__FILE__)+"/keys.yml")
AWS.config(YAML.load(File.read(config_path)))
ec2 = AWS::EC2.new