• Home
Fedrianto Ramadhan Learning all I can

Array PHP To CSV with Sanitizing arrays

17/05/2013 7:41 pm / Leave a Comment / madindo

Found this somewhere I forgot, what this do is when you have bunch of arrays but when a quotes or something else that will mess up the writing to csv, this is the best I could find so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function array_to_scv($array, $header_row = true, $col_sep = ",", $row_sep = "\n", $qut = '"')
    {
        $output = '';
    	if (!is_array($array) or !is_array($array[0])) return false;
    	
    	//Header row.
    	if ($header_row)
    	{
    		foreach ($array[0] as $key => $val)
    		{
    			//Escaping quotes.
    			$key = str_replace($qut, "$qut$qut", $key);
    			$output .= "$col_sep$qut$key$qut";
    		}
    		$output = substr($output, 1)."\n";
    	}
        
    	//Data rows.
    	foreach ($array as $key => $val)
    	{
    		$tmp = '';
    		foreach ($val as $cell_key => $cell_val)
    		{
    			//Escaping quotes.
    			$cell_val = str_replace($qut, "$qut$qut", $cell_val);
    			$tmp .= "$col_sep$qut$cell_val$qut";
    		}
    		$output .= substr($tmp, 1).$row_sep;
    	}
    	
    	return $output;
    }
Posted in: Development

O2danceschool Membership System

06/05/2013 5:48 pm / Leave a Comment / madindo
O2dance Membership_640x396

Position : Freelancer

Tools :  CI, Jquery, Mysql

Live : o2dancemembership.madindo.com

Description : O2danceschool Membership system for a friend of mine

Posted in: Portfolio

Natanashoes.com

06/05/2013 4:24 pm / Leave a Comment / madindo
Natanashoes_640x388

Position : Freelancer

Tools :  CI, Jquery, Mysql

Live : www.natanashoes.com

Description : New ecommerce for women’s shoes

Posted in: Portfolio

Anathassa first birthday

05/04/2013 7:52 am / Leave a Comment / madindo
At 12/10/2012 was my baby’s birthday, we prepared catering, tumpengan  and the birthday cake got it from somewhere in the front of the hospital pertamina. Family & friends came it was fun and hopefully for Tacca as well but for me there was something that I really regret… I didn’t knew how to photograph and can’t speak in public like my father in law… uses my friend’s nikon, it was awesome when you hold it but somehow the result is saddening. I can’t blame anyone but me… No good pictures to remember it was all blurry, I regret next time have to be prepared but next we thought of going for donation for yatim piatu. My friend created this slideshow of us which is nice of him… Thank you
Tacca_B'day-91_640x426
Tacca_B'day-92_640x426

Posted in: Personal

[Exploring] Sari Ater Hotel and Resort

03/04/2013 4:41 am / Leave a Comment / madindo

This slideshow requires JavaScript.

Me and my family went out to find a new to find a new place to go then we found out on the web that there was a hot spring in sari ater in bandung and next to it there’s a park where we could walk… It was really nice for a change, we took a horse ride with the guide I thought it was only a few thousands but they charge around 200 thousand rupiah for both horses because we took a long ride, but really it was long, if I was the guide I wouldn’t been able to walk that far. When we walked around there was also a racing karts and so on, I include a video of us horse riding :)

Posted in: Personal

[Exploring] Swimming at Panglima Polim

28/03/2013 6:00 am / Leave a Comment / madindo
Here are the location of the swimming pool that me and my family went to… Googlemap. I didn’t know that there was a swimming pool in this area, it’s just perfect so close to home… But in there it’s kind of crowded and closes at 14:30 sad can’t go there in the afternoon when it’s not hot. Tacca is trying her new swimming outfit, so cute :) and here’s the video of me and Tacca Swimming… Now she can stand on the water, Awesome.

After that we went to PIM so Tacca can eat first before going to the alternative medical in Bintaro called Chicken Alternative (berobat dengan ayam). At the PIM there was some playground for kids but not suitable for Tacca but the counter said that there’s a playground for baby 0 – 2 years old, so I went there and it was perfect for Tacca, she couldn’t stay still and want to try everything. The price was 40rb / 30 minutes (sucks) but worth it :) and had to buy socks for both of us. I recorded Tacca but unfortunately low on storage damn…

Posted in: Personal

101 creatives notes

27/03/2013 4:14 am / Leave a Comment / madindo

Just read a book about creative notes, in my point of view this books is too much on showing off his galaxy note ( are they the sponsor? ) and his proud work in hard rock… Well good on you…

Well these are his 101 notes and those bolded onces are the one that I want to do or try or maybe agreed
Read More →
Posted in: Book Notes

Feels like I want to study again

26/03/2013 10:32 am / Leave a Comment / madindo
This is my first time doing online course… i thought that online courses are all paid courses but when I saw Coursera all the courses are all free.
The courses are indeed really good they provide video lecture, quizes and exams. I think I start to miss studying again, I want to try  those high quality university. I saw in youtube  class programming methodology from standford, I feel like I want to be there…
Well this is just an info if you want to take a course online go the the url below
Currently I’m taking class
  1. Web Intelligence and big data
  2. Learn to program : crafting a quality code
https://www.coursera.org/
Posted in: Experiences

Android – using contact content provider

26/03/2013 10:04 am / Leave a Comment / madindo

So now we will be listing our contact into a textview

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/contactview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout> 


MainActivity.java

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.widget.TextView;

public class MainActivity extends Activity {
  
/** Called when the activity is first created. */

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView contactView = (TextView) findViewById(R.id.contactview);

    Cursor cursor = getContacts();

    while (cursor.moveToNext()) {

      String displayName = cursor.getString(cursor
          .getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
      contactView.append("Name: ");
      contactView.append(displayName);
      contactView.append("\n");
    }
  }

  private Cursor getContacts() {
    // Run query
    Uri uri = ContactsContract.Contacts.CONTENT_URI;
    String[] projection = new String[] { ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME };
    String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
        + ("1") + "'";
    String[] selectionArgs = null;
    String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
        + " COLLATE LOCALIZED ASC";

    
    return managedQuery(uri, projection, selection, selectionArgs,
        sortOrder);
  }

}
Posted in: Development / Tagged: android

Android – sqllite

26/03/2013 10:02 am / Leave a Comment / madindo

Finally into sqllite, i’ve been wondering where they put the database.

SQLiteDatabase is the base class for working with a SQLite database in Android and provides methods to open, query, update and close the database.
More specifically SQLiteDatabase provides the insert(), update() and delete() methods.
In addition it provides the execSQL() method, which allows to execute an SQL statement directly.
The object ContentValues allows to define key/values. The “key” represents the table column identifier and the “value” represents the content for the table record in this column. ContentValues can be used for inserts and updates of database entries.
Queries can be created via the rawQuery() and query() methods or via the SQLiteQueryBuilder class .
rawQuery() directly accepts an SQL select statement as input.
query() provides a structured interface for specifying the SQL query.
SQLiteQueryBuilder is a convenience class that helps to build SQL queries.

Read More →

Posted in: Development / Tagged: android

Post Navigation

1 2 3 … 13 Next »


Categories

  • Book Notes
  • Development
  • Experiences
  • Info
  • Personal
  • Portfolio
  • Religion

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1 other subscriber

© Copyright 2013 - Fedrianto Ramadhan
Infinity Theme by DesignCoral / WordPress