Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Sunday, December 15, 2013

(Software) Architecture

(Software) Architecture: "The art of drawing lines, with the interesting rule that once you've drawn the lines all dependencies that cross that line go in the same direction" -- Robert C. Martin

Tuesday, July 16, 2013

Using your own Pre-populated SQLite database in (Xamarin.)Android applications

Problem:

Most of Sqlite-net samples – at least the ones I came across – address creating new databases and populating them with data at runtime through calling web services, or else. Nothing on the other side address the situations when you need to start with a pre-populated database.

Solution:

Thanks to this post, and other questions on StackoverFlow and Xamarin Forums, find below the C# version of the code on the mentioned post. Note that I only “translated” the part that copies the database file from the assets folder to your package data directory. That – off course – requires your SQLite database to be added to you Android project assets folder as an “Android Asset”.

Saturday, May 28, 2011

#Vodafone #Buzz #Fail

I was online through my favorite IM client; Google Talk, when a work-colleague started talking to me, asking me:

دا ايميل مين انا تعبت رابع ايميل يفتح غلط

I am using Vodafone Buzz from my mobile. Get it now for free from http://vf.eg/buzz

After talking for a while, I realized he was a total stranger; not my colleague. He's another user of Vodafone Buzz, like my colleague. The issue was that every time he signs in to Google Talk (using Vodafone Buzz), he signs in with my colleague's account. As far as I remember, Buzz associates your Vodafone number with the passwords you supply for your social networking sites (likes Facebook, Gmail , etc) so you don't have to type them every time you fire up the app.

If that was not scary enough, I'd just direct your attention to the fact: that stranger is not intending harm, (he's not a hacker for eg, or even evil enough to abuse the situation, he probably lack technical expertise too) so I'm expecting a disaster if he intended!! That if he was the only case of compromised password!!

Conclusion: If you're using Vodafone Buzz, just don't! And more importantly: UPDATE EVERY PASSWORD YOU'VE EVER SHARED WITH VODAFONE!

Side note: Thank GOD I don't save my credit card number on their website!!

Wednesday, March 23, 2011

Client-side Form Validation using jQuery Mobile

Lately, I've been involved in a project which is mainly targeting mobile browsers. The decided to use kinda "new" jQuery mobile "library". jQuery Mobile is a ……built over jquery, css, js, multiple browser support, etc…… It's still in beta? Yet, it renders pretty fine, and we didn't have more than a couple of issues with it. But it save us loads of time rendering on a nice range of supported mobile browsers.

For eg, I stepped into a problem with client-side validation lately. When jQuery Mobile renders input of type submit (i.e. a submit button for a form), it actually hides the "input" tag, and replace it with an anchor? (ie "a" tag).

Say, you want to add function to handle "onclick" event, validate the form, before hitting the server-side, and prevent it from submitting if it failed; something like:

<input type="submit" onclick="return ValidateForm()" />

The  function is actually never called because the actual input tag is as jQuery Mobile hides and replaces it by an anchor.

Adding the validation function via js/jquery after the document is ready to the anchor, will allow you to call it on clicking the anchor. Yet, it won't stop the form being submitted.

A nice alternative, is to use an input tag of type button, that is:

 <input type="button" onclick="ValidateForm();" />

And submit the form inside the function handling "onclick", rather than returning true/false, like:

   1:  function ValidateOwnerId() {                
   2:      if (/*form is valid*/) {
   3:          $('#myForm').submit(); // Submit from
   4:      }
   5:      else//not valid
   6:      {
   7:          /*show some error message without submitting form*/
   8:      }
   9:  }

Saturday, March 05, 2011

TEDx, El Sawy Culture Wheel, Bibliotheca Alexandrina, Open Brands, etc

I was having a chat with a friend, who is an enthusiast about community work, about that same topic (more specifically in Suez, my hometown) last week. Our conversation drove me to think about an idea that should have been done a little while ago (IMHO).

We all like the cultural "presence" of "organizations" like El Sawy Culture Wheel, and Bibliotheca Alexandrina. But unfortunately their effect is pretty local to where they exist. Another thing, similar organizations are too limited in resources, to reach out of their physical locations. They might try to expand vertically; creating more services, and enhancing them. But they almost never try to "branch out" in other places.

My idea for them is to spread their spirit/culture, share their experience with others who are willing to create similar experiences for their local communities, in a way similar to TEDx. Imagine if every city/governorate had their own Culture Wheel, which operate the same way, with the same spirit, but totally independent (financially for eg) on El Sawy's. Imagine instead of the usual bureaucratic "cultural palaces" (قصور الثقافة) there's a real cultural experience where people from all ages (specially youth) can find a decent place to mingle with like-minded people talking and sharing ideas, etc.

Thursday, March 03, 2011

"Note in (Google) Reader" issue Fix

Probably you're familiar with the sharing button (at least on Firefox and Chrome) offered by Google reader to help you share stuff that don't have feeds. Today, for some reason I realized that mine wasn't working!

GReader

 

After tweeting about it, thanks to Flavio Gomes and @mtobis, I realized what went wrong. Seems like the JavaScript file used by the button was updated, without updating the button script accordingly.

 

To solve this, all you have to do is set _IS_MULTILOGIN_ENABLED a variable that's not defined (but used) in the script file in the button script. So add something like:

_IS_MULTILOGIN_ENABLED=true;
// or
_IS_MULTILOGIN_ENABLED=false;
// or better
_IS_MULTILOGIN_ENABLED=((typeof(_IS_MULTILOGIN_ENABLED)=="undefined")?false:_IS_MULTILOGIN_ENABLED);

 

at the beginning of the button script, just to set _IS_MULTILOGIN_ENABLED before it's accessed as "undefined" in the script.

Sunday, January 09, 2011

How to force undo checkout? #TFS

Sometimes you'd pop into cases where you find yourself in a situation where you have to force undo pending code changes of someone else (say a colleague who is no more around, or even temporarily) or your own pending changes if say your machine (along with your workspace on it).

Well, there a Visual Studio tool for that.. That's tf command-line utility, which you can look for in your VS directory under Common7\IDE..

Using tf has lots and lots of uses, here's a really LONG list of them. Note: there's 3 sub-lists for VS2005, 2008, 2010. But for our tiny problem here, we mainly have to options, I'm using here the most straight forward ones:

Undoing pending changes for a specific file:

That will need mainly main parameters to start with: The name/path of the file checkout, User name (of the user who did the checkout), and the Workspace in which the checkout was done (usually your machine name if you didn't create an new workspace).

You could have an issue with the third one (workspace name), so you might have to check the Workspaces command for more details, but generally a small command like the one below will do just ok in most cases:

tf workspaces /owner:UserName

Knowing the above you can easily undo the pending changes as below, note: parameters are in squiggly braces like {these}:

tf undo {file path} /workspace:{workspace};{username} /server:{TFS name/IP}

Of course the "/server" part can be removed if you're on the same server running TFS. An example with some data will look like:

tf undo $/myProject/myFile.cs /workspace:mySpace;FCIH\shady /server:FCIH_TFS

Deleting the whole workspace:

The other option is to delete the whole workspace, which in turn delete any related checkouts. A simple command for that could be:

tf workspace /delete {workspace};{username} /server:{TFS name/IP}

which with some example parameters might look like:

tf workspace /delete Shady-PC;FCIH\shady /server:10.0.0.2

UPDATE:

After a comment by Meligy, I think I needed to add this: Most of the above needs you to be logged in as an account with TFS admin privileges, check the exact required permissions for Undo, Workspace and Workspaces commands.

If you're not logged in as the appropriate account, you can append {/login:username, [password]} to provide the authorized username and password.

Meligy, also, mentioned another tool called TFS Sidekicks that can do similar stuff.

Thursday, December 30, 2010

How you do (online) Social!?

Pretty much of the people who follow me, do so for stuff related to Agile or Community events/stuff (along with a few others who knew me for sometime and might really care to follow my news as a person/friend)

I thought it was obvious how I categorize my stuff but lately I realized that it needed to be more explicit, so here is a list of what I'm sharing so you won't get spammed by my other personal stuff (That is the way I do it, what about you?):

ComCal.org: Wanna follow follow technical events and share events with others? Egypt IT community Calendar is a public calendar that includes offline IT community Events held around Egypt. Also, online events both from Egypt and around the world. Choose your way subscription between from the site. You can add events to share it with the community here.

@ASGEgypt: Anything Agile, I was a bit sleepy but probably will be posting there more often soon. Note: this is a "colaborative" twitter account, others (ASGE organizers) post there too.

FCIH Blog: A collaborative blog by many guys from FCIH, I try to blog there as much as I can, but the blog is really full of great posts by my fellow Helwaneez there.. Strangely, we have huge (daily) hits from USA & India compared to those from Egypt.

@FCIH: Speaking of the blog; many guys from FCIH blog might post/reply there to any technical questions.

Google Reader Share items: for more "serious" stuff like articles I read, etc

LinkedIn: my online "professional ID"/CV/Resume.

@mShady: I was always fond of status messages (here's the proof!).. So this is my status messages/shout out/ etc extended and kinda archived! This is "me"; no filters attached!

This Blog: A year or so ago, I've went back through my blog to make sure my tags are more limited. No I have like only 9 (not sure if I should really reduce that again). I'm trying to make sure that all the posts here are either under "Personal" or "Tehcnical" Tag.. All the other tags are just extra tagging..

Facebook: is more for friends and family (or at least I'm trying to do so from now on) though it's wasn't exactly my "policy" before, I used to accept almost everybody as friends as long as they look "human" to me.

BUZZ: A combination of all the above!! I prefer discussions on Buzz and Facebook.. twitter is not made for that!

 

Now that I wrote it down, may be this way I'll be more strict about these rules that they are now public Open-mouthed smile

Saturday, November 27, 2010

Quote of the Moment

“Procrastination is my sin. It brings me naught but sorrow. I know that I should stop it. In fact, I will – tomorrow!” – Gloria Pitzer

Monday, September 13, 2010

Do people in non-English-speaking countries code in English?

I was reading a question with the same name on Stack-Exchange Beta site for Non-programmer-related questions (aka Programmers) when I came across this answer posted by a (probably Ukrainian) developer named Igor.

Accompanied by an earlier attempt by a colleague at work to write an enum in Arabic, I tried to write this piece of code:

Strangely enough it compiled and even ran showing the expected output (10)!! Note, the order above of the 2nd & 3rd line is mingled due to RTL issues in Gist. Visual Studio will show it in the right order (or at least, a more readable order for me, copy it & past it in your IDE to know how it looks).

Off course, I’m pretty convinced that this isn’t the best practice you should follow, (check my answer to the same question). Yet, I find this really hilarious! As a matter of fact, I took the claim that it’s bad practice too much for granted to the extent that I’ve never even tired to write such a strange piece of code :D

Wednesday, September 08, 2010

Does Google Instant really ruin SEO?

I was just reading an article I found on twitter about how Google Instant (the new Google search enhancement to be rolled out to all users soon) will ruin Search Engine Optimization (SEO) which I find kinda wrong.

First: SEO is a way to aid (content providers to provide ways to) internet users to find their way to their content. ie, it’s a mean to an end, not an end! So if Google (or Bing, etc) added new features to enhance the user experience (UX) and personalize search results that might break SEO, SEO should find a way to adapt. Killing innovation is not an option :)

SEO is not about deceiving people to direct them to your content, whether it’s relevant or not!!

Second: & that’s the main point here: As far as I can see, Google Instant is not ruining SEO as Steve claims. Search results are still gonna be shown as the good old days, the only main difference is that you won’t have to click ENTER after typing your search words. You can get instant feedback about where your search results meet your expectations or not. So if content-providers did their SEO job right, their content will show up according to the relevance of their content to the typed keywords.

So, what do you think? correct me if you can see it in any other way..

Update:

I find this tweet by @Bashmohandes more valid though:

Google Instant is cool, but I worry about advertisers, as some of their impression budgets are used while the user didn't show enough intent

Thursday, July 22, 2010

FCIH Initiative Updates

Finally we are glad to announce the launch of
FCIH Initiative Program
On Next Sunday 25/7/2010 at FCI-Helwan
Join our great event; Join a group of carefully selected sessions highly needed in your practical life.
Event Schedule:
Day 1 [Sunday: 25-7-2010]: Let's get started
10:00
10:30
Orientation
10:30
12:30
Object Oriented Blocks
12:30
01:00
Break
01:00
02:30
Good Code
02:30
03:00
Break
03:00
04:00
English for Business
Day 2 [Monday: 26-7-2010]: Develop your path
10:00
11:30
Web Development A – Z
11:30
12:00
Break
12:00
02:00
Software Quality Engineering
02:00
02:30
Break
02:30
04:00
CV Writing and interviewing skills
Day 3 [Wednesday: 28-7-2010]: IT, World of Endless Choices
10:00
11:00
GIS: Geographic information system
11:00
12:00
CMS: Content Management System
12:00
12:30
Break
02:00
02:30
BI: Business Intelligence
02:30
03:30
RIA: Rich Internet Application
Day 4 [Thursday: 29-7-2010]: Into the business world
10:00
01:00
Agile Software Development
01:00
01:30
Break
01:30
3:00
Understanding Business Analysis
03:00
04:30
Global / Local IT Market
04:30
05:00
Closing
Don't miss the chance…..and don't forget our date "25/7/2010" at FCI-Helwan.
Waiting you there :)

Find more about the event here:
Mail: FCIH [dot] Initiative [at] fcih [dot] net
Website: http://www.helwan.edu.eg:90/fcih/details.asp?id=161

               http://www.helwan.edu.eg:90/fcih/details.asp?id=162
FaceBook Event: http://www.facebook.com/event.php?eid=128813070490801

Saturday, July 10, 2010

Creating a simple Open Search Provider/Plug-in

Yesterday, I needed to check/search my delicious bookmarks more than once. I then realized that delicious have its a search plug-in as a part of a tool bar (along with other bookmarking tools, few search tools, though), which -I guess- loads all your bookmarks to browser & make them available for search.
As I’m not so much into too much plug-ins, specially if they load lots of data (in contradiction to Pointy-haired Boss) , not to mention that I won’t need bookmarks when I’m offline, anyway, I decided I should create my search provider.

Creating the Provider:

Here’s an example:



Away from the fact that I badly need a WYSIWYG code hi-lighter, let’s check that XML. First the ShortName which appears in your search box, something like this:
Click to Enlarge Description and Tags are obvious, & I think optional too.
Image is the small icon that appear beside when you select your provider (check the pic above again). You can either supply it as a URL to an image file (usually .ico or .png) or you can replace it with the base 64 string of the image (though I wasted quite sometime to make that work), like:



Finally, URL note that I’m using {SearchTerms} to pass the string typed in the search box. You can send other parameters to your search page. You might want add another URL for suggestions, here I’m only providing the search URL.

Using the Provider:

To add the provider to your browser (as far as I’m concerned it works fine for Firefox & IE) you have one of two options:
Adding it as a suggested search provider: This can be done by adding a single line in your page <Head> tag, note that the attribute title in the below tag refers to the name appearing in the list as [Add “title”], check the image below the tag.



Click to Enlarge
Using JavaScript to add the provider: The other available option is to add the provider using scripting, here’s an eg of how you can do that:



Clicking a link like the one above will pop up a windows asking if you want to add the search provider.
References: http://www.opensearch.org

Friday, July 09, 2010

Changing regional settings for System accounts (including ASPNET) in Windows 7

One of the small issues I faced while switching my development machine to windows 7 was a bug/exception in an application I was working on in parsing date format.

After switching my regional settings to the “expected” format, I still got the same exception. After playing a little with the regional settings, I realized that I was switching only my account date format, not the whole machine's date format. To push those settings to other system accounts (like ASPNET, etc), I did the following steps:

After setting your your account regional settings, switch to “Administrative” tab:

Click to Enlarge

From “Welcome screen and new user accounts”, click “Copy setting”:

Click to EnlargeMake sure “Welcome screen and system accounts”  check box is checked, press ok, and Voila!

Tuesday, March 23, 2010

How to configure SQL Server for ASP.NET SQL Server Session State <sessionState mode="SQLServer" ../>

On your prompt (doesn’t matter if you’re on the SQL server machine or not), run the below command:
”system root”\Microsoft.NET\Framework\”version number”>aspnet_regsql.exe –S “server” -U sa -P “Password” -ssadd -sstype p
for eg:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
OR
C:\WINNT\Microsoft.NET\Framework\v4.0.21006>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
Now you have ASPState database on your servers with the tables, stored procedures, jobs needed to handle SQL server mode session state.

Friday, January 15, 2010

Why would you need a Gender table in your DB??

A friend of mine was tweeting about how he found a drop down control in some application he’s working on that binds on a (“lookup”) table with only the 2 rows for male & female.. Check the short conversation on twitter.

In my humble opinion -as weird it may sound-  this approach (for similar, small lookups) might makes sense, in some way. Not exactly as is, may be it will make sense more if it’s within a lookup module (a single table for all lookups where every entry has a lookup type).

Other “regular” approaches (& their expected problems) :

People usually tackle such small lookups using enums, or just using an “agreed on” key/value pairs convention (not stores anywhere in code or DB, may be only a code comment here or there) which usually tend to get forgotten & you have to  trace code to know which key stands for each lookup value..

Even worse, is using a boolean for such

Benefits of a DB Table approach:

Other than the benefits of avoiding the above, using DB to explicitly state lookup values, is that they are more dynamic, ie: you can always edit them without touching much code, that would be handy in cases like:

  • Clients constantly changing small stuff like spelling, etc
  • Adding other functionalities/features, like multilingual support for eg..

Thus, I find avoiding enums, etc & using tables even for small stuff like that gender much more convenient..

Let me know what you think about it, & (hopefully) suggest a better approach..

Saturday, December 05, 2009

How to create a C# Class from XML file (via xsd.exe)

A friend asked me a couple of times about how to I created the class I used in “twitter common friends” to handle xml as objects (includes reading and writing back). Actually the tool (xsd.exe) is pretty simple and takes no more than a couple of commands to create the class for me.

It’s just that I usually forget the keywords/parameters & their order (you can create a dataset or class that can be C# or VB, and there’s a couple of other option I never used before). I usually refer to its MSDN page when asked..

So I thought a post would be easier to remember. First you should create the xsd file out of the xml, using the VS command prompt:
xsd myFile.xml
That will create “myFile.xsd”, now to create “myFile.cs”, write the below line:
xsd myFile.xsd /c 
Now you can add the cs file to your project and use it as illustrated in my previous post.


Cross-posted from FCIH-Blog

Tuesday, June 09, 2009

Things that piss me off when someone sends me email!!

  • When someone forward a message that was sent before to like 100 mail address, & forgot to delete the (irrelevant) email addresses, & they just went there as a part of the message (& growing)!!
  • When someone send me a message, along with a 100 other addresses (including mine) in the CC or To field not the BCC, while the recipients don't know one another & even won't need to know one another (for eg chain email messages). Off course if this "someone" in this point did put them in the BCC, we will find less "someones" do the previous point by mistake!!
  • When different people in my social network forward to me the same email (which was 1st sent by some in their extended social networks to all of them) & someone (from the chain(s) between the 1st sender & me) gets the idea that it's brilliant to change the message title!! Leaving me, not only suffering of receiving the same message again & again & again!! Naaah!! (s)he give me the extra pain of spreading them across multiple threads in my inbox :@:@ (If you're not using gMail u won't feel the difference, you’re already suffering too much to feel it :D!!)
  • When someone CC me in a conversation that I don't give a "….." about.
  • When someone reply to conversation happening among a number of people (me included) & then replies on behalf of me (usually the reply is a commitment from them that I -Shady- will do something. As if they are my agent/lawyer :D).
  • When someone (specially admins) hijack mailing-lists by sending/allowing mail that is totally irrelevant to the mailing-list main topic.
  • When someone tries to use religion (actually this isn't just about email, I see that all the time) to make sure you forward their SPAM to your whole mailing list. Usually I delete similar email just for the sake of it. (3end)
  • When someone send too old news that circulated the internet for like a 100 times. Specially if they were well known hoax!!
This post was in my drafts for like 6 month, & since I started it I had the Ericsson laptop hoax email –which I have been receiving dozens of times since high school already - for like 2 to 3 time at least over just the past 6 month!!)

Friday, April 17, 2009

Updated: Twitter Common Friends

Earlier I've posted (read it here or here) about the a tiny application that gets two twitter users common friends. I wanted since then to put it online someway without hosting it.. It's not worth the headache. So, today, I've found a couple of twitter blocks on popfly & used them to re-write the application (yes, I've written a couple of little tiny lines of code.. but I'm not even sure what language was that, probably js, lol) Now it is more accessible for me & faster than the desktop version.. Also it has more data about the common friends (including a link to their twitter profile) Here's the embedded version I've shared on popfly, you can also access it here: http://www.popfly.com/users/SMN/Twitter%20Common%20Friends
UPDATE 20090608: Recently, after the above mash-up crashed (coz the block I'm using to consume twitter crashed) @Koraem tweeted about this app, which is more advanced than my mash-up.. Here it's http://twtrfrnd.com/ & it seems like they are intending to add more features later :)

Disclaimer

All the opinions expressed on this blog are my own and don't necessarily represent my employer's positions, strategies or opinions.