Chome / Shockwave Flash Crashing

Last 2 months a had an constant issue where Sockwave flash kept crashing after a while. I had to restart chrome to make browser responsive. This is the easiest solution I found to resolve this.

Open Chrome
Copy-Paste this text on Address bar chrome://plugins/
Or go to Options->Under the Hood -> Content Settings -> Disable individual plug-ins… (Click)

Now Locate Flash on this List. If you see Flash (2 files) this is good.

On the right you will see a details button, Expand.

And disable the Flash version with Location
“C:\Windows\SysWOW64\Macromed\Flash\NPSWF32.dll”

Dead Center DIV

body {
margin: 0px
}

#horizon {
color: white;
background-color: #0ff;
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}

#content {
position: absolute;
left: 50%;
width: 250px; /* Overall width of div */
height: 70px; /* Overall height of div */
top: -35px; /* half of the overall height */
margin-left: -125px; /* half of the overall width */
visibility: visible
}

MySQL backup Script

The following script returns a SQL query with all your database data structure and data.

if (!function_exists(‘mysql_dump’)) {

function mysql_dump($database) {

$query = ”;

$tables = @mysql_list_tables($database);
while ($row = @mysql_fetch_row($tables)) { $table_list[] = $row[0]; }

for ($i = 0; $i < @count($table_list); $i++) { $results = mysql_query('DESCRIBE ' . $database . '.' . $table_list[$i]); $query .= 'DROP TABLE IF EXISTS `' . $database . '.' . $table_list[$i] . '`;' . lnbr; $query .= lnbr . 'CREATE TABLE `' . $database . '.' . $table_list[$i] . '` (' . lnbr; $tmp = ''; while ($row = @mysql_fetch_assoc($results)) { $query .= '`' . $row['Field'] . '` ' . $row['Type']; if ($row['Null'] != 'YES') { $query .= ' NOT NULL'; } if ($row['Default'] != '') { $query .= ' DEFAULT \'' . $row['Default'] . '\''; } if ($row['Extra']) { $query .= ' ' . strtoupper($row['Extra']); } if ($row['Key'] == 'PRI') { $tmp = 'primary key(' . $row['Field'] . ')'; } $query .= ','. lnbr; } $query .= $tmp . lnbr . ');' . str_repeat(lnbr, 2); $results = mysql_query('SELECT * FROM ' . $database . '.' . $table_list[$i]); while ($row = @mysql_fetch_assoc($results)) { $query .= 'INSERT INTO `' . $database . '.' . $table_list[$i] .'` ('; $data = Array(); while (list($key, $value) = @each($row)) { $data['keys'][] = $key; $data['values'][] = addslashes($value); } $query .= join($data['keys'], ', ') . ')' . lnbr . 'VALUES (\'' . join($data['values'], '\', \'') . '\');' . lnbr; } $query .= str_repeat(lnbr, 2); } return $query; } } [/sourcecode]

Uninstall XCode / Xcode 4 Preview

There is no application in Mac OSX to uninstall Programs. The only thing you can do is drag an application to the Trash Can.
However, it is quite simple to uninstall applications on MAC OS; you just move the application to the trash bin. Doing this, however, does not completely take care of uninstalling programs on Mac.

To understand why, you need to know that programs on Mac computers are of two types; the bundled programs, which can be uninstalled just by moving them to the Trash bin, and the non-bundled programs, which can be uninstalled using the same method, but additional manual work is required to clean up after them. Many programs leave behind settings and other small files that continue to take up space on your hard drive. These must be cleared out as well to ensure that you efficiently uninstall programs on Mac.

Here are some third-party uninstallers for your Mac, and their features:

Appcleaner

Appcleaner
Finds support files and preferences left behind by programs, and removes them from your hard disk.
Select the program that you want to uninstall and drag and drop it into AppCleaner

Apptrap

Apptrap
Takes care of supporting files, preferences and system files.
When you delete an application, an AppTrap window pops up and asks you if you want to remove the trashed program’s associated files.

Now, what about XCode?

The thing is that XCode is not listed as application, application bunldes and widgets.
To succefully remove XCode you have to run this command

sudo /Library/uninstall-devtools –mode=all

is the directory where the tools are installed. For typical installations the full path is /Developer/Library/uninstall-devtools
Cant find it

find / -type f -name “uninstall-devtools”

Easy enough, just make sure this is what you really intend to do as once it’s gone, it’s gone.

Coredata Resource Links

 

Apple resource

Apple’s Core Data Programming Guide

Efficiently Importing Data

Apple guideline to import data

Cocoa is my Girlfriend

Super easy Fetching Core Data

Cocoa with Love

Core Data Line Fetch

Cocoa Dev Central

nice article with example structure and images

Import Data to CoreData Project

  • Create the model in XCode (it is essential do this first, because XCode uses a specific naming convention and adds several underlying tables to the actual data model.
  • Run the application in the Simulator and with the app running … go and copy the database (/users/library/Application Support/iPhone Simulator/User/Applications/ to some other location
  • Open up the database (I use SQLite Manager plugin in Firefox)
  • From here I import my data from a CSV file once I have updated all of my CSV column names to match the table names
  • Look at the CoreDataRecipies sample code for including a pre-populated database (code is in the Delegate.m file)
  • Import the database in your application and you should be good to go.
/**
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
	
    if (persistentStoreCoordinator != nil) {
        return persistentStoreCoordinator;
    }
		
	NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"Recipes.sqlite"];
	/*
	 Set up the store.
	 For the sake of illustration, provide a pre-populated default store.
	 */
	NSFileManager *fileManager = [NSFileManager defaultManager];
	// If the expected store doesn't exist, copy the default store.
	if (![fileManager fileExistsAtPath:storePath]) {
		NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"Recipes" ofType:@"sqlite"];
		if (defaultStorePath) {
			[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
		}
	}
	
	NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
	
	NSError *error;
    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&amp;amp;error]) {
		// Handle error
		NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
		exit(-1);  // Fail
    }    
		
    return persistentStoreCoordinator;
}

iPhone Wifi MacAddress

#if ! defined(IFT_ETHER)
     #define IFT_ETHER 0x6/* Ethernet CSMACD */
#endif

- (IBAction)testAction:(id)sender
{
      #pragma unused(sender)
      BOOL                              success;
      struct ifaddrs *               addrs;
      const struct ifaddrs *           cursor;
      const struct sockaddr_dl *      dlAddr;
      const uint8_t *               base;
      int                              i;

      success = getifaddrs(&addrs) == 0;
      if (success) {
          cursor = addrs;
          while (cursor != NULL) {
               fprintf(stderr, "%s\n", cursor->ifa_name);
               if ( (cursor->ifa_addr->sa_family == AF_LINK)
               && (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER) ) {
               dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
               fprintf(stderr, " sdl_nlen = %d\n", dlAddr->sdl_nlen);
               fprintf(stderr, " sdl_alen = %d\n", dlAddr->sdl_alen);
               base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen];
               fprintf(stderr, " ");
               for (i = 0; i < dlAddr->sdl_alen; i++) {
                    if (i != 0) {
                    fprintf(stderr, ":");
                       }
                    fprintf(stderr, "%02x", base[i]);
               }
               fprintf(stderr, "\n");
               }
               cursor = cursor->ifa_next;
             }

     freeifaddrs(addrs);
     }
}

Linq Update FK – Operation is not valid due to the current state of the object

sql serverTo update the entity in question you need to get a new entity for it from the context rather than setting it directly.

Wrong Way

OrderRecord.customerId = 105;

Throws an error!
“Operation is not valid due to the current state of the object”

Solution

OrderRecord.tblCustomer = db.tblCustomers.Single(t => t.customerID == 105);

Returns no error!

IT collaboration, Tutorials, Tips