Skip to content

Instantly share code, notes, and snippets.

View caironoleto's full-sized avatar
🎯
Focusing

Cairo Noleto caironoleto

🎯
Focusing
View GitHub Profile
#!/bin/bash
read -p "Type your domain: " domain
apt-get install postfix postfix-tls libsasl2-2 sasl2-bin libsasl2-modules telnet
cp /etc/postfix/sasl/smtpd.conf /etc/postfix/sasl/smtpd.conf.backup
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf
@caironoleto
caironoleto / tuning-primer.sh
Created December 18, 2009 13:08
MySQL Tuning Primer
#!/usr/bin/env bash
#########################################################################
# #
# MySQL performance tuning primer script #
# Writen by: Matthew Montgomery <[email protected]> #
# Inspired by: MySQLARd (http://gert.sos.be/demo/mysqlar/) #
# Version 1.2-r6 #
# Licenced under GPLv2 #
# #
def auth
user = `/usr/local/git/bin/git config --global github.user`.strip
token = `/usr/local/git/bin/git config --global github.token`.strip
user.empty? ? {} : { 'login' => user, 'token' => token }
end
#raffle numbers for the mega sena
@nums = []
def avoid_repeating(current)
if @nums.include?(current) == true or current == 0
avoid_repeating(rand(61))
else
@nums << current
end
def interesting_tables
ActiveRecord::Base.connection.tables
end
class BackupDB < ActiveRecord::Base
end
destination_db = 'new'
BackupDB.establish_connection destination_db.intern
./configure \
--prefix=/usr \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access_log \
--error-log-path=/var/log/nginx/error_log \
--pid-path=/var/run/nginx.pid \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--with-md5-asm --with-md5=/usr/include \
# The basic idea is that we take the existing data via ActiveRecord
# and create new documents in MongoDB using MongoMapper.
# This method is necessary as we want to keep all the associations of existing dataset
# and by the way, clean up empty columns
# We rely on models still being ActiveRecord::Base, I bet you can figure out how the look like.
# And have the newer MongoDB ones here in a module, painful as we have to set the collection_name
# Don't put a +timestamps!+ into your MongoMapper models yet because this would change the updated_at if existing
# As you see in the MongoDB models, a few loose their indepence, e.g. Source as I
# plan to add other sources besides flickr, or Page and Album which only make sense in
# their parent Website
require 'rubygems'
require 'active_record'
require 'net/http'
require 'uri'
email = "YOUR_EMAIL_HERE"
password = "YOUR_PASSWORD_HERE"
ActiveRecord::Base.establish_connection(:adapter => "mysql", :socket => "/tmp/mysql.sock", :user => "root", :password => "root", :database => "YOUR_DATABASE_HERE")
results = ActiveRecord::Base.connection.execute("SELECT * FROM `wp_posts` WHERE post_type = 'post' and post_status='publish' order by post_date asc;")
[whatever@server ~]$ curl http://api.twitter.com/1/account/rate_limit_status.xml
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<reset-time type="datetime">2010-04-17T02:00:08+00:00</reset-time>
<remaining-hits type="integer">19963</remaining-hits>
<hourly-limit type="integer">20000</hourly-limit>
<reset-time-in-seconds type="integer">1271469608</reset-time-in-seconds>
</hash>
[whatever@server ~]$ lol
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
if RUBY_VERSION == "1.8.6"
check_auth_args user, secret, authtype if user or secret