RSS

Monthly Archives: November 2012

The Agora

“Power is in the hands not of the minority but of the whole people.When it is a question of settling private disputes,everyone is equal before the law; when it is  a question of putting one person before another in positions of public responsibility,what counts is not the membership of a particular class,but the actual ability which the man possesses.No one so long as he has it in him to be of service to the state,should be kept in political obscurity because of poverty………..” Pericles view on democracy

“When your spirit is strained and you limited to change
The lyrics in your limericks will change
A different hook, the way the sentences arranged
More demented in your deliverance, more sinister in your slang..”

The Question :“Are Political structure and Ideological developments Independent of Economic changes?”

Early historians believed that history was primarily influenced by spiritual and intellectual changes.This idea progressively changed as…

View original post 774 more words

 
Leave a comment

Posted by on November 28, 2012 in Uncategorized

 

De Morgan’s law

Hey so a bit of math here.

So I want to prove:  (A U B)’ = A’ ∩ B’ —> De Morgan’s law.

General case: In set theory, at least how I remember it is, if A = B then A is a subset of B and B a subset of A. Which is really obviously true. In mathy terms A ⊆ B and B ⊆ A. (⊆ means subset).

So what we want to do here is prove that (A U B)’ ⊆ A’ ∩ B’ and then prove also A’ ∩ B’ ⊆ (A U B)’ – just reversed the order.

STEP 1 – (A U B)’ ⊆ A’ ∩ B’

General case: The prove that A ⊆ B (A is a subset of B)  we show that there is a value common to both A and B.

suppose x ∈ (A U B)’ (∈ means ‘is contained in’). This wuld mean that x ∉ A U B and hence x ∉ A and x ∉ B (draw a Venn diagram if this is not too clear). which leads us to x ∈ A’ and x ∈ B’when combined is x ∈ A’ ∩ B’

And hence we have proven that x is in both A’ ∩ B’ and (A U B)’ which means (A U B)’ ⊆ A’ ∩ B’

STEP 2 – A’ ∩ B’ ⊆ (A U B)’

Try this on your own.

……………………

and finally (A U B)’ = A’ ∩ B’

 
Leave a comment

Posted by on November 21, 2012 in Uncategorized

 

Coder/Blogger/Subaru Fan

So he is finally graduating ….yes Jaymo is finally getting that piece of paper that will persuade mum that all the money she spent on me was not wasted. So as I was thinking of going for my Gown at Juja  a pal of mine asked me what I would tell the younger version of me if I could teleport back to 2008. back to when I was a freshman at JKUAT. Well after much pondering I came up with a list of the things I would tell first year Jaymo.

1.Campus will be over  before you know it,so have fun.I know it seems like all those Math lessons last forever but before you know it you will be doing your finals asking the crew when you will be having the last rave.You will have mad fun, you will get into trouble also…but the guys you call the crew will make campo rock the most. Marto,Pato,Ritchie,Mogaka,kush,mash and Brayo will have the weirdest plots.From kuchinja…

View original post 1,144 more words

 
Leave a comment

Posted by on November 21, 2012 in Uncategorized

 

Apps << gPlayer

Finally a music player – Still working on a few things. But in the end, u shuld be able to see the lyrics of the song playing, album arts, music visualisations… and so much more. I got the background service going – pretty cool. 

 
Leave a comment

Posted by on November 18, 2012 in Uncategorized

 

The music Code

SongData.java


package com.gilo.gplayer.songsUtils;

import java.util.ArrayList;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio.Albums;
import android.util.Log;

import com.gilo.gplayer.classes.Album;
import com.gilo.gplayer.classes.Artist;
import com.gilo.gplayer.classes.Song;
 /*
 * This class is instantiated when I need songs at any point on my app.
 * */
public class SongData {

Context context;

//This are the Uri's to the particular contents we want:
 final Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; //the songs
 final Uri album_uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI; //the albums
 final Uri artist_uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI; //the artits

 //This are the columns we want
 final String[] cursor_cols = { MediaStore.Audio.Media._ID,
 MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM,
 MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DURATION, MediaStore.Audio.Media.DATA };

final String[] album_cols = { MediaStore.Audio.Albums._ID,
 MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ARTIST,
 MediaStore.Audio.Albums.NUMBER_OF_SONGS, MediaStore.Audio.Albums.ALBUM_ART};

 final String[] artist_cols = { MediaStore.Audio.Artists._ID,
 MediaStore.Audio.Artists.ARTIST, MediaStore.Audio.Artists.NUMBER_OF_ALBUMS,
 MediaStore.Audio.Artists.NUMBER_OF_TRACKS};

 //Constructor
 public SongData(Context context) {
 this.context = context;
 }

/*
 * This method will return an arraylist containing objects of Song class. Each object has
 * the title of the song, artist, album, duration, album art, and the path on the sd-card
 */
 public ArrayList<Song> GetSongs() {
 final Cursor cursor = context.getContentResolver().query(uri,
 cursor_cols, null, null, MediaStore.Audio.Media.TITLE + " ASC");
 ArrayList<Song> song_list = new ArrayList<Song>();

while (cursor.moveToNext()) {

Song song = new Song();

// get the song info
 final String artist = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
 final String album = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));
 final String title = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
 String duration = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
 String path = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));

 //correctly set the duration from milliseconds to a samthing like 2:55
 duration = setCorrectDuration(duration);

// this gets the album art
 Cursor cur = context.getContentResolver().query(
 Albums.EXTERNAL_CONTENT_URI,
 new String[] { Albums.ALBUM_ART }, Albums.ALBUM + "=?",
 new String[] { album }, null);
 cur.moveToFirst();
 String album_art = cur.getString(cur
 .getColumnIndex(Albums.ALBUM_ART));

song.setTitle(title);
 song.setArtist(artist);
 song.setAlbum(album);
 song.setDuration(duration);
 song.setAlbumArt(album_art);
 song.setPath(path);

song_list.add(song);

 Log.d("music added", title );
 Log.d("Path", path );
 }

return song_list;
 }
 /*
 * Same as above but returns the albums
 */
public ArrayList<Album> GetAlbums() {
 final Cursor cursor = context.getContentResolver().query(album_uri,
 album_cols, null, null, MediaStore.Audio.Media.ALBUM + " ASC");
 ArrayList<Album> album_list = new ArrayList<Album>();

while (cursor.moveToNext()) {

Album album = new Album();

// get the album info
 final String title = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
 final String artist = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST));
 final String no_Of_Songs = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS));
 String album_art = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM_ART));

 album.setTitle(title);
 album.setArtist(artist);
 album.setNoSongs(no_Of_Songs);
 album.setAlbumArt(album_art);

album_list.add(album);

 }

return album_list;
 }
 /*
 * Returns the artists
 */
public ArrayList<Artist> GetArtists() {
 final Cursor cursor = context.getContentResolver().query(artist_uri,
 artist_cols, null, null, MediaStore.Audio.Artists.ARTIST + " ASC");
 ArrayList<Artist> artist_list = new ArrayList<Artist>();

while (cursor.moveToNext()) {
 Artist artist = new Artist();

// get the album info
 final String name = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
 final String no_Of_Songs = cursor.getString(cursor
 .getColumnIndexOrThrow(MediaStore.Audio.Artists.NUMBER_OF_TRACKS));

 artist.setName(name);

 artist.setSongNo(no_Of_Songs);

 Cursor cur = context.getContentResolver().query(
 Albums.EXTERNAL_CONTENT_URI,
 new String[] { Albums.ALBUM_ART }, Albums.ARTIST + "=?",
 new String[] { name }, null);
 cur.moveToFirst();

 String album_art = cur.getString(cur
 .getColumnIndex(Albums.ALBUM_ART));

 artist.setAlbumArt(album_art);
 artist.setAlbumNo(String.valueOf(cur.getCount()));

 artist_list.add(artist);

}

return artist_list;
}

public String setCorrectDuration(String duration) {
 // TODO Auto-generated method stub
 int time = Integer.valueOf(duration);

 int seconds = time/1000;
 int minutes = seconds/60;
 seconds = seconds % 60;

 if(seconds<10)
 return String.valueOf(minutes) + ":0" + String.valueOf(seconds);

 return String.valueOf(minutes) + ":" + String.valueOf(seconds);
 }
}

Then the Song.java jst as an example:

</pre>
package com.gilo.gplayer.classes;

public class Song {

String title;
String artist;
String album;
String duration;
String album_art;
String path;
// String size;

// the getter methods
public String getTitle() {
return this.title;
}

public String getArtist() {
return this.artist;
}

public String getAlbum() {
return this.album;
}

public String getDuration() {
return this.duration;
}

public String getAlbumArt() {
return this.album_art;
}

public String getPath() {
return this.path;
}

// the setter methods
public void setTitle(String title) {
this.title = title;
}

public void setArtist(String artist) {
this.artist = artist;
}

public void setAlbum(String album) {
this.album = album;
}

public void setDuration(String duration) {
this.duration = duration;
}

public void setAlbumArt(String album_art) {
this.album_art = album_art;
}

public void setPath(String path) {
this.path = path;
}
}
<pre>
 
Leave a comment

Posted by on November 5, 2012 in Uncategorized

 

My Apps << ∑μrεkα


Another one here. This one started out just playing with API’s on android. It utilises the Wolfram||Alpha Api. Mainly used the iphone TableView. Anyway here are the screenshots:

 

 
2 Comments

Posted by on November 2, 2012 in Apps