Skip to content

Instantly share code, notes, and snippets.

@mpvvliet
mpvvliet / gist:2470806
Created April 23, 2012 13:04
Deployit puppet module sample
# Puppet manifest
$DEPLOYIT_VERSION = '3.7.0'
#
# Install the latest Apache webserver
#
exec { "apt-update":
command => "/usr/bin/apt-get update",
}
@nicolargo
nicolargo / gist:4647457
Created January 27, 2013 08:54
Glances 1.6 default configuration file
[cpu]
# Limits values for CPU user in %
# Defaults values if not defined: 50/70/90
user_careful=50
user_warning=70
user_critical=90
# Limits values for CPU system in %
# Defaults values if not defined: 50/70/90
system_careful=50
system_warning=70
@pappu687
pappu687 / angular-feed-reader
Last active December 25, 2017 16:49
Quick Feed Reader with AngularJS
<!DOCTYPE html>
<html ng-app="RSSFeedApp">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>AngularJS Feed Reader - jsFiddle demo</title>
<script type='text/javascript' src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js'></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css">
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-responsive.min.css">
@vgoklani
vgoklani / app.py
Last active December 19, 2022 09:13
Using Flask to output Python data to High Charts
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index(chartID = 'chart_ID', chart_type = 'bar', chart_height = 350):
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}]
title = {"text": 'My Title'}
@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':
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 SP2 64bits AMIs provided by Amazon
#
# Inject this as user-data of a Windows 2008 AMI, like this (edit the adminPassword to your needs):
#
# <powershell>
# Set-ExecutionPolicy Unrestricted
@denji
denji / nginx-tuning.md
Last active April 26, 2024 11:21
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

require 'facter'
require 'aws-sdk'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
ec2 = Aws::EC2::Client.new(region:region)
instance = ec2.describe_instances(instance_ids:[instance_id])
tags = instance.reservations[0].instances[0].tags
tags.each do |tag|
@velocity303
velocity303 / winpf.pp
Last active August 29, 2015 14:21
Windows code snippets for base OS Settings
#profile class for https://forge.puppetlabs.com/ptierno/windowspagefile
class profile::winpf {
case $os[release][major] {
"2008 R2": { if $::issql == 'true' {
$initialpf = 24576
$maximumpf = 24576
}
elsif $memorysize_mb < 16384 {
$initialpf = 1024
$maximumpf = 1024
@iamralch
iamralch / custom_flag.go
Created July 6, 2015 20:40
Custom flag arguments with flag package in Go
package main
import (
"flag"
"fmt"
"net/url"
"strings"
)
type UrlFlag struct {