Skip to content

Instantly share code, notes, and snippets.

View mahmoudimus's full-sized avatar
💭
@_@

Mahmoud Rusty Abdelkader mahmoudimus

💭
@_@
View GitHub Profile
@coderanger
coderanger / README.md
Last active August 29, 2015 13:56
Command to run depsolver

To use this snippet first replace the _default in the URL with your environment name if you are using somethign other than the global default. Next in the run list, replace ... with your cookbook names. Unlike other run lists, you cannot have roles here, and you don't use the 'recipe[foo]' syntax, just 'foo'.

# run #1 - run with just --db sqlite, one test is generated/runs
classics-MacBook-Pro-2:sqlalchemy classic$ py.test test/dialect/test_suite.py --db sqlite -k HasTableTest
============================================================= test session starts ==============================================================
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2 -- /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
plugins: cov
collected 121 items
test/dialect/test_suite.py <- lib/sqlalchemy/testing/suite/test_reflection.py:31: HasTableTest_sqlite_pysqlite.test_has_table PASSED
#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end
Ideias on a nicer ActiveResource API
= ActiveResource
== Guidelines
ARes is a platform to build clients to restful-like web services. It maps resources to objects that complies with the ActiveModel API.
To enjoy the advantages of being restful (whose discussion is beyond the scope of this gist), ARes should support:
* using HTTP verbs, headers and status code as they are meant;
import time
from contextlib import contextmanager
@contextmanager
def easyprofile(msg):
before = time.time()
yield
print '%s took %0.2fsec' % (msg, time.time() - before)
@joakimk
joakimk / bot.rb
Created April 29, 2011 06:05 — forked from jpr5/bot.rb
XMPP/Ruby Bot for HipChat with support for multiple rooms
#!/usr/bin/env ruby
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/muc/helper/simplemucclient'
# Most of this is borrowed from https://gist.github.com/941931
# Added support for multiple rooms and external handling of messages.
# We want the MUC functionality to just handle shit for us. Unfortunately we
# have to override/repeat the join method in order to add the directive that
@kdoi
kdoi / EasyProxy.json
Created September 3, 2011 23:06
JSON for AWS CloudFormation to launch an EC2 instance running web proxy (Squid) and a security group to protect the instance without SSHing at all.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Launch an EC2 instance with Squid configured for user specified network and port and a security group.",
"Parameters" : {
"SourceNetwork" : {
"Description" : "Squid proxies instances in this network. Example: 123.123.123.0/24",
"Type" : "String"
},
@shageman
shageman / .ideamodules.xml
Created February 8, 2012 01:38
InetlliJ Modules in Rubymine
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/custom_engine1/module1.iml" filepath="$PROJECT_DIR$/custom_engine1/custom_engine1.iml" />
<module fileurl="file://$PROJECT_DIR$/custom_engine2/module2.iml" filepath="$PROJECT_DIR$/custom_engine2/custom_engine2.iml" />
</modules>
</component>
</project>
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
#!/bin/bash
#Which
Grep="`/usr/bin/which grep`"
Awk="`/usr/bin/which awk`"
Cat="`/usr/bin/which cat`"
Sed="`/usr/bin/which sed`"
Curl="`/usr/bin/which curl`"
# Scrape Nagios