MAD-Rip!

August 24th, 2010

It’s coming soon!!!



Private Pastebins working again ;)

June 17th, 2010

Sorry it took so long, but I finally hooked back up the private pastebins, so you can do debian.pastebin.org and it will work now ;)



How to make a small Gentoo distro

June 14th, 2010

First off, Gentoo is awesome for making small or custom linux distributions. It allows you (with emerge) to build little package tarballs and make your own image.


Now. to get started add this to your gentoo make.conf

FEATURES="buildpkg"



That will tell portage to create the tarball packages every time you emerge anything.


This next part is up for debate. The bare minimal packages in my opinion are bash, baselayout, busybox, openrc. So lets emerge them


emerge bash baselayout busybox openrc



After this is done. And it can take a while. You should have a nice directory struct in /usr/portage/packages. Look for the 4 that you just built. After you got them. create a directory to load build your minimal gentoo distro in.

mkdir -p /build/minimal



The -p just tells it to make all the parent directories too. so it will make /build and then make /build/minimal



now copy those tarballs into this path like so

cp sys-apps/baselayout-1.12.13.tbz2 /build/minimal/
cp sys-apps/busybox-1.16.0.tbz2 /build/minimal/
cp sys-apps/openrc-0.6.1-r1.tbz2 /build/minimal/
cp app-shells/bash-4.0_p37.tbz2 /build/minimal/

Untar them.

cd /build/minimal
tar -xjvf *

The next step you need to figure out what libraries bash needs to run. do this.

ldd bin/bash

Should give you something like this.

        linux-gate.so.1 =>  (0xb78b8000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb786a000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7866000)
        libc.so.6 => /lib/libc.so.6 (0xb771e000)
        /lib/ld-linux.so.2 (0xb78b9000)

Those are the libs you will need. Go ahead and copy them over.

cp /lib/libncurses.so.5 /build/minimal/lib/
cp /lib/libdl.so.2 /build/minimal/lib/
cp /lib/libc.so.6 /build/minimal/lib/
cp /lib/ld-linux.so.2 /build/minimal/lib/

And now you can chroot inside your minimal enviroment.

chroot /build/minimal/ /bin/bash --login


Ant Macros

June 4th, 2010

Macros are a very slick way to consolidate, simplify, and configure your ANT scripts. For example, if your running a bunch of targets that executes sql queries. Your code could look something like this.


Without Macros (build.xml)


<project default="test">
	<extension-point name="DB.Install.1.0.0.Baseline" />

	<target name="DB.Install.1.0.0.Baseline.Clean" extensionOf="DB.Install.1.0.0.Baseline">
		<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installer}" userid="postgres" password="" autocommit="true"><![CDATA[
			DROP DATABASE IF EXISTS ${DB.Database};
			DROP ROLE IF EXISTS ${DB.Username};
		]]></sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Users" extensionOf="DB.Install.1.0.0.Baseline">
		<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installer}" userid="postgres" password="" autocommit="true"><![CDATA[
			CREATE ROLE ${DB.Username} WITH PASSWORD '${DB.Password}' LOGIN;
		]]></sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Database" extensionOf="DB.Install.1.0.0.Baseline">
		<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installer}" userid="postgres" password="" autocommit="true"><![CDATA[
			CREATE DATABASE ${DB.Database} WITH OWNER ${DB.Username};
		]]></sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Schemas" extensionOf="DB.Install.1.0.0.Baseline">
		<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installee}" userid="postgres" password="" autocommit="true"><![CDATA[
			CREATE SCHEMA ${DB.Schema};
			ALTER SCHEMA ${DB.Schema} OWNER TO ${DB.Username};
			COMMENT ON SCHEMA ${DB.Schema} IS 'My Cool Database Schema';
		]]></sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Tables" extensionOf="DB.Install.1.0.0.Baseline">
		<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installee}" userid="postgres" password="">
			<transaction src="tables.sql"/>
		</sql>
	</target>
<project>




Lots of redundant configurables being used

  • This means if you ever decide to change how you run queries you’ll need to modify each one of these calls to reflect the change
  • This also adds lots of bulk/waste code




Here is a example of how macros can help clean up your code.


With Macros (macros.xml)


<project>
	<!-- ============= -->
	<!-- = My Macros = -->
	<!-- ============= -->
	<macrodef name="run-sql-file">
		<attribute name="file"/>
		<attribute name="delimiter" default=";"/>
		<sequential>
			<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installee}" userid="postgres" password="" delimiter="@{delimiter}">
				<transaction><![CDATA[SET search_path = ${DB.Schema};]]></transaction>
				<transaction src="@{file}"/>
			</sql>
		</sequential>
	</macrodef>

	<macrodef name="run-sql">
		<text name="query"/>
   		<attribute name="transaction" default="false"/>
		<sequential>
			<if>
				<equals arg1="@{transaction}" arg2="true" />
				<then>
					<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installee}" userid="postgres" password="">
						<transaction><![CDATA[SET search_path = ${DB.Schema};]]></transaction>
						<transaction>@{query}</transaction>
					</sql>
				</then>
				<else>
					<sql driver="${JDBC.Driver}" url="${JDBC.URL.Installee}" userid="postgres" password="" autocommit="true">
						<transaction>@{query}</transaction>
					</sql>
				</else>
			</if>
		</sequential>
	</macrodef>
</project>



With Macros (build.xml)


<project default="test">
	<!-- ====================== -->
	<!-- = Include The Macros = -->
	<!-- ====================== -->
	<include file="macros.xml"/>

	<extension-point name="DB.Install.1.0.0.Baseline" />

	<target name="DB.Install.1.0.0.Baseline.Clean" extensionOf="DB.Install.1.0.0.Baseline">
		<run-sql><![CDATA[
			DROP DATABASE IF EXISTS ${DB.Database};
			DROP ROLE IF EXISTS ${DB.Username};
		]]></run-sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Users" extensionOf="DB.Install.1.0.0.Baseline">
		<run-sql><![CDATA[
			CREATE ROLE ${DB.Username} WITH PASSWORD '${DB.Password}' LOGIN;
		]]></run-sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Database" extensionOf="DB.Install.1.0.0.Baseline">
		<run-sql><![CDATA[
			CREATE DATABASE ${DB.Database} WITH OWNER ${DB.Username};
		]]></run-sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Schemas" extensionOf="DB.Install.1.0.0.Baseline">
		<run-sql transaction="false"><![CDATA[
			CREATE SCHEMA ${DB.Schema};
			ALTER SCHEMA ${DB.Schema} OWNER TO ${DB.Username};
			COMMENT ON SCHEMA ${DB.Schema} IS 'Cool Database Database Scheme';
		]]></run-sql>
	</target>

	<target name="DB.Install.1.0.0.Baseline.Tables" extensionOf="DB.Install.1.0.0.Baseline">
		<run-sql-file file="tables.sql" />
	</target>
<project>




Now if we ever want to change how we run our queries, we just modify our macros and all our code is updated. Also in large scale projects, this simplifies the code and shrinks it pretty dramatically.



Bluebird by Bukowski

June 3rd, 2010

There’s a bluebird in my heart that
wants to get out
but I’m too tough for him,
I say, stay in there, I’m not going
to let anybody
see you.


There’s a bluebird in my heart that
wants to get out
but I pour whiskey on him and inhale
cigarette smoke
and the whores and the bartenders
and the grocery clerks
never know that
he’s
in there.


There’s a bluebird in my heart that
wants to get out
but I’m too tough for him,
I say,
stay down, do you want to mess
me up?
you want to screw up the
works?
you want to blow my book sales in
Europe?


There’s a bluebird in my heart that
wants to get out
but I’m too clever, I only let him out
at night sometimes
when everybody’s asleep.
I say, I know that you’re there,
so don’t be
sad.


Then I put him back,
but he’s singing a little
in there, I haven’t quite let him
die
and we sleep together like
that
with our
secret pact
and it’s nice enough to
make a man
weep, but I don’t
weep, do
you?




created By ooyes.net