Thursday, April 19, 2012

Not able to install SQL Server

I am trying to install SQL Server 2008 on Windows 7.



But it gives me error




Invoke or BeginInvoke cannot be called on a control until the
window handle had been created..




Please help me in this regards.



Thanks in advance...





"Lock down" app on BlackBerry PlayBook to prevent navigation away?

I was wondering if its possible to lock an app so that the user can't select any hardware buttons to get out of the app.



The app will be used for display purposes at a conference and want to display a video constantly. When finished the app can be closed from within the app by entering a password.





Python Tkinter Error, "Too Early to Create Image"

So I have an assignment that I have to use Tkinter to create a board game. This is just one part of the program where I want to bring in the image of the board. But I keep on getting the error, "Too early to create image" and I'm not sure what I'm doing wrong.



Here's my code so far:



from Tkinter import *
from pprint import pprint

# Which variable is currently updating
from variableColors import Variables
VariableIndex = 0
VariableText = Variables[VariableIndex]

Ids = None # Current canvas ids of the text and 4 player tokens:
# Will be None if not committed

VariableCoords = { } # Where store variable and coordinates


im = PhotoImage(file="C:\Users\Kiki\Desktop\Assignment\\")
photo = can.create_image(0,0,anchor=NW, image=im)

can.pack()


root.mainloop()


Any help would be appreciated. Thanks :)





jquery function not being called

I'm trying to call a jquery function from a asp link button. Here is my link button html:



        <div style="padding-left:75px">
<asp:LinkButton ID="lbAddCC" runat="server" ClientIDMode="Static" OnClick="ShowCCControls()" Text="Add CC"></asp:LinkButton>
</div>


Here is my jquery function:



        function ShowCCControls() {

$('#lblCC').show();
$('#txtCC').show();
} //end ShowCCControls()


When I try to build, I get the error:



ASP.internal_email_aspx does not contain a definition for 'ShowCCControls' and no extension method 'ShowCCControls' accepting a first argument of type 'ASP.internal_email_aspx' could be found (are you missing a using directive or an assembly reference?)



I have this working on another page using a check box:



                   <asp:CheckBox ID="chkNew" TabIndex="8" runat="server" Text="New Tank" OnClick="SetNewTankControls()"
ClientIDMode="Static" />


Anybody see an issue? Thanks





vim :gsearch (greplace plugin) escaping characters

I am using the greplace plugin for vim and am not sure how to escape brackets in a search.



I want to search for cookies[:parent] and have tried:



:Gsearch cookies[:parent] # returns nothing
:Gsearch cookies\[:parent\] # returns nothing


How should I be doing this?



Thanks





OS X editor (or IDE) that is really good for "node.js" development?

I'm an old Emacs user. I've used it for about 10years now. When i switch to Mac i started to use Aquamacs, which is great in many ways.



But now most my development is in Node.js/Express.js with JavaScript, Jade and Stylus. Emacs has many shortcomings in that regard. Specially when working remote with ExpanDrive and MacFUSE mounts.



And i really want real code folding.



Is there any Editor which is really good for this. Even better is there any IDE for Mac (at all)?



Thanks





How Do I Read a Multi-line File of JSON and Count Words in Specific Field in Python

I have a file with many hundreds of lines of json encoded tweets pulled from python-tweetstreamer. The lines look like:



{"favorited": false, "in_reply_to_user_id": null, "contributors": null, "truncated": false, "text": "kasian pak weking :| RT @veNikenD: Kasian kenapa???RT @SaputraJordhy: kasian \u256e(\u256f_\u2570)\u256d RT @veNikenD: Tak ingin lg kudengar kata2 yg tak ......", "created_at": "Tue Apr 03 14:07:59 +0000 2012", "retweeted": false, "in_reply_to_status_id": null, "coordinates": null, "in_reply_to_user_id_str": null, "entities": {"user_mentions": [{"indices": [24, 33], "screen_name": "veNikenD", "id": 64910664, "name": "Ve Damayanti", "id_str": "64910664"}, {"indices": [54, 68], "screen_name": "SaputraJordhy", "id": 414675856, "name": "jordhy_ynwa", "id_str": "414675856"}, {"indices": [88, 97], "screen_name": "veNikenD", "id": 64910664, "name": "Ve Damayanti", "id_str": "64910664"}], "hashtags": [], "urls": []}, "in_reply_to_status_id_str": null, "id_str": "187179645026836481", "in_reply_to_screen_name": null, "user": {"follow_request_sent": null, "profile_use_background_image": true, "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/418679759/Young_Minato_and_Kushina_by_HaNa7.jpg", "verified": false, "profile_image_url_https": "https://si0.twimg.com/profile_images/1953774147/Untitled1_normal.png", "profile_sidebar_fill_color": "DDEEF6", "is_translator": false, "id": 414675856, "profile_text_color": "1c181c", "followers_count": 46, "protected": false, "location": "", "default_profile_image": false, "listed_count": 0, "utc_offset": 25200, "statuses_count": 409, "description": "never walk alone", "friends_count": 76, "profile_link_color": "0084B4", "profile_image_url": "http://a0.twimg.com/profile_images/1953774147/Untitled1_normal.png", "notifications": null, "show_all_inline_media": false, "geo_enabled": false, "profile_background_color": "C0DEED", "id_str": "414675856", "profile_background_image_url": "http://a0.twimg.com/profile_background_images/418679759/Young_Minato_and_Kushina_by_HaNa7.jpg", "screen_name": "SaputraJordhy", "lang": "id", "profile_background_tile": true, "favourites_count": 0, "name": "jordhy_ynwa", "url": null, "created_at": "Thu Nov 17 10:41:05 +0000 2011", "contributors_enabled": false, "time_zone": "Jakarta", "profile_sidebar_border_color": "C0DEED", "default_profile": false, "following": null}, "place": null, "retweet_count": 0, "geo": null, "id": 187179645026836481, "source": "<a href=\"https://embr.in\" rel=\"nofollow\">embr</a>"}
{"favorited": false, "in_reply_to_user_id": 441527150, "contributors": null, "truncated": false, "text": "@akoriko1046 \u5bdd\u308b\u306e\uff1f\u3000\u5f85\u3063\u3066\u50d5\u3082\u884c\u304f\u3088\u2026\u5e03\u56e3\u307e\u3067\u304a\u59eb\u69d8\u62b1\u3063\u3053\u3057\u3066\u3044\u3063\u3066\u3042\u3052\u308b", "created_at": "Tue Apr 03 14:07:59 +0000 2012", "retweeted": false, "in_reply_to_status_id": 187179532103598080, "coordinates": null, "in_reply_to_user_id_str": "441527150", "entities": {"user_mentions": [{"indices": [0, 12], "screen_name": "akoriko1046", "id": 441527150, "name": "\u30a2\u30b3\u30ea\u30b3", "id_str": "441527150"}], "hashtags": [], "urls": []}, "in_reply_to_status_id_str": "187179532103598080", "id_str": "187179645014253568", "in_reply_to_screen_name": "akoriko1046", "user": {"follow_request_sent": null, "profile_use_background_image": true, "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/440543906/122004876_org.jpg", "verified": false, "profile_image_url_https": "https://si0.twimg.com/profile_images/1870697453/__________bg_normal.jpg", "profile_sidebar_fill_color": "DDEEF6", "is_translator": false, "id": 513679998, "profile_text_color": "333333", "followers_count": 169, "protected": false, "location": "\u3042\u306a\u305f\u306e\u96a3", "default_profile_image": false, "listed_count": 2, "utc_offset": 32400, "statuses_count": 6024, "description": "\u8584\u685c\u9b3c\u6c96\u7530\u7dcf\u53f8\u306e\u975e\u516c\u5f0fbot\u3067\u3059\u7518\u7518/\u30a8\u30ed\u8a2d\u5b9a\u3000\uff8c\uff6b\uff9b\uff70\u306e\u518d\u306f\u5fc5\u305a\u8aac\u660e\u66f8\u3092\u4e00\u8aad\u4e0b\u3055\u3044http://www.pixiv.net/novel/show.php?id=934499 \u624b\u52d5\u3067\u30d5\u30a9\u30ed\u8fd4\u3057\u3092\u884c\u3063\u3066\u307e\u3059\u3000\u7a00\u306b\u4e2d\u306b\u7ba1\u7406\u4eba\u304c\u3044\u307e\u3059\u3000\u7ba1\u7406\u4eba@akanemam1 18\u7981\u7dcf\u53f8\u2192 @sou_oki_18bot", "friends_count": 166, "profile_link_color": "0084B4", "profile_image_url": "http://a0.twimg.com/profile_images/1870697453/__________bg_normal.jpg", "notifications": null, "show_all_inline_media": false, "geo_enabled": false, "profile_background_color": "C0DEED", "id_str": "513679998", "profile_background_image_url": "http://a0.twimg.com/profile_background_images/440543906/122004876_org.jpg", "screen_name": "sou_oki_bot", "lang": "ja", "profile_background_tile": false, "favourites_count": 1, "name": "\u7dcf\u53f8(bot)", "url": null, "created_at": "Sat Mar 03 22:36:15 +0000 2012", "contributors_enabled": false, "time_zone": "Irkutsk", "profile_sidebar_border_color": "C0DEED", "default_profile": false, "following": null}, "place": null, "retweet_count": 0, "geo": null, "id": 187179645014253568, "source": "<a href=\"http://twittbot.net/\" rel=\"nofollow\">twittbot.net</a>"}
{"favorited": false, "in_reply_to_user_id": 141448885, "contributors": null, "truncated": false, "text": "@nobuttu3 \u6642\u9593\u304c\u904e\u304e\u308b\u306e\u304c\u7269\u51c4\u304f\u65e9\u3044\u3067\u3059\u3088\u306d\u2026", "created_at": "Tue Apr 03 14:07:59 +0000 2012", "retweeted": false, "in_reply_to_status_id": 187179547098234880, "coordinates": null, "in_reply_to_user_id_str": "141448885", "entities": {"user_mentions": [{"indices": [0, 9], "screen_name": "nobuttu3", "id": 141448885, "name": "\u306e\u4ecf \uf8ff \u30bf\u30ab\u30cf\u30b7", "id_str": "141448885"}], "hashtags": [], "urls": []}, "in_reply_to_status_id_str": "187179547098234880", "id_str": "187179645047799808", "in_reply_to_screen_name": "nobuttu3", "user": {"follow_request_sent": null, "profile_use_background_image": true, "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/424878981/tw_hvt_nz.jpg", "verified": false, "profile_image_url_https": "https://si0.twimg.com/profile_images/1223811261/twitter_icon_normal.png", "profile_sidebar_fill_color": "daecf4", "is_translator": false, "id": 97481308, "profile_text_color": "663B12", "followers_count": 436, "protected": false, "location": "\u6771\u4eac\u90fd\u53f0\u6771\u533a", "default_profile_image": false, "listed_count": 20, "utc_offset": 32400, "statuses_count": 63704, "description": "\u591a\u5206PG\u3001\u6642\u3005SE\u307d\u3044\u4ed5\u4e8b\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u30e9\u30ce\u30d9\u597d\u304d\u3001\u97f3\u697d\u597d\u304d(\u7279\u5b9a\u306e\u5206\u91ce\u3067\u3059\u304c)\u3002\u30bd\u30b3\u30bd\u30b3\u306e\u983b\u5ea6\u3067\u79cb\u8449\u539f\u306b\u3044\u305f\u308a\u3082\u3057\u307e\u3059\u3002 ", "friends_count": 896, "profile_link_color": "1F98C7", "profile_image_url": "http://a0.twimg.com/profile_images/1223811261/twitter_icon_normal.png", "notifications": null, "show_all_inline_media": false, "geo_enabled": false, "profile_background_color": "ffffff", "id_str": "97481308", "profile_background_image_url": "http://a0.twimg.com/profile_background_images/424878981/tw_hvt_nz.jpg", "screen_name": "xi6", "lang": "ja", "profile_background_tile": false, "favourites_count": 4473, "name": "\u3055\u304f", "url": null, "created_at": "Thu Dec 17 16:55:25 +0000 2009", "contributors_enabled": false, "time_zone": "Tokyo", "profile_sidebar_border_color": "C6E2EE", "default_profile": false, "following": null}, "place": null, "retweet_count": 0, "geo": null, "id": 187179645047799808, "source": "<a href=\"http://tapbots.com/tweetbot\" rel=\"nofollow\">Tweetbot for iOS</a>"}
{"favorited": false, "in_reply_to_user_id": null, "contributors": null, "truncated": false, "text": "#ImSingleBecause lolz I'm not. Happily taken by @GarrettBettler &lt;33 I love him, forever :)", "created_at": "Tue Apr 03 14:07:59 +0000 2012", "retweeted": false, "in_reply_to_status_id": null, "coordinates": null, "in_reply_to_user_id_str": null, "entities": {"user_mentions": [{"indices": [48, 63], "screen_name": "GarrettBettler", "id": 460816116, "name": "Garrett Bettler", "id_str": "460816116"}], "hashtags": [{"indices": [0, 16], "text": "ImSingleBecause"}], "urls": []}, "in_reply_to_status_id_str": null, "id_str": "187179645039427584", "in_reply_to_screen_name": null, "user": {"follow_request_sent": null, "profile_use_background_image": true, "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/452188318/tanja_beach_2007_001.JPG", "verified": false, "profile_image_url_https": "https://si0.twimg.com/profile_images/1971847266/image_normal.jpg", "profile_sidebar_fill_color": "f6ffd1", "is_translator": false, "id": 461432420, "profile_text_color": "333333", "followers_count": 222, "protected": false, "location": "", "default_profile_image": false, "listed_count": 0, "utc_offset": null, "statuses_count": 2334, "description": "", "friends_count": 192, "profile_link_color": "0099CC", "profile_image_url": "http://a0.twimg.com/profile_images/1971847266/image_normal.jpg", "notifications": null, "show_all_inline_media": false, "geo_enabled": false, "profile_background_color": "FFF04D", "id_str": "461432420", "profile_background_image_url": "http://a0.twimg.com/profile_background_images/452188318/tanja_beach_2007_001.JPG", "screen_name": "LeahOswalt", "lang": "en", "profile_background_tile": false, "favourites_count": 86, "name": "Leah Oswalt", "url": null, "created_at": "Wed Jan 11 20:07:24 +0000 2012", "contributors_enabled": false, "time_zone": null, "profile_sidebar_border_color": "fff8ad", "default_profile": false, "following": null}, "place": null, "retweet_count": 0, "geo": null, "id": 187179645039427584, "source": "<a href=\"http://twitter.com/#!/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>"}
{"favorited": false, "in_reply_to_user_id": 434884235, "contributors": null, "truncated": false, "text": "@nomimushi_ttk \u3068\u30fc\u3084\u3082\u7d20\u6575\u3060\u3051\u3069\u306e\u307f\u3080\u3057\u306e\u30a2\u30a4\u30b3\u30f3\u5929\u4f7f\u3059\u304e\u3066", "created_at": "Tue Apr 03 14:07:59 +0000 2012", "retweeted": false, "in_reply_to_status_id": 187179241664815105, "coordinates": null, "in_reply_to_user_id_str": "434884235", "entities": {"user_mentions": [{"indices": [0, 14], "screen_name": "nomimushi_ttk", "id": 434884235, "name": "\u306e\u307f\u3080\u3057", "id_str": "434884235"}], "hashtags": [], "urls": []}, "in_reply_to_status_id_str": "187179241664815105", "id_str": "187179645026836480", "in_reply_to_screen_name": "nomimushi_ttk", "user": {"follow_request_sent": null, "profile_use_background_image": true, "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png", "verified": false, "profile_image_url_https": "https://si0.twimg.com/profile_images/2023688835/6222d8ae387e6fb5b220895d2fd2d41a_normal.gif", "profile_sidebar_fill_color": "DDEEF6", "is_translator": false, "id": 365471550, "profile_text_color": "333333", "followers_count": 308, "protected": false, "location": "\u5b66\u5712\u30a2\u30ea\u30b9\u306b\u518d\u71b1\u306a\u3046", "default_profile_image": false, "listed_count": 17, "utc_offset": 32400, "statuses_count": 25562, "description": "\uff8c\uff9e\uff9a10/\u3046\u305f\u30d7\u30ea/HTF/\u3044\u306c\u307c\u304f\u306a\u3069\u306b\u304a\u71b1/\u5d50\u306e\u5927\u91ce\u304f\u3093\u3059\u304d\uff01\u64ec\u4eba\u5316\u3082\u3050\u3082\u3050/\u30a4\u30ca\u30a4\u30ec/RKRN/pkmn/\uff83\uff86\uff8c\uff9f\uff98/\u4e59\u5973\uff79\uff9e\uff70\u5168\u822c\u3082 [\u30bf\u30ab\u4e38\u3055\u3093\u30e2\u30b0\u30e2\u30b0\u30da\u30c3\u3063\u3066\u3057\u968a\u54e1No.2\uff3c\u526f\u968a\u9577\uff0f]\u3000\u898f\u5236\u57a2\u3010@ao_sanagi_2\u3011\u30a2\u30a4\u30b3\u30f3\u306f\u3068\u30fc\u3084\u304b\u3089\uff01", "friends_count": 284, "profile_link_color": "0084B4", "profile_image_url": "http://a0.twimg.com/profile_images/2023688835/6222d8ae387e6fb5b220895d2fd2d41a_normal.gif", "notifications": null, "show_all_inline_media": false, "geo_enabled": false, "profile_background_color": "C0DEED", "id_str": "365471550", "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png", "screen_name": "ao_sanagi", "lang": "ja", "profile_background_tile": false, "favourites_count": 1071, "name": "\u8475@\u6284\u82b1\u306e\u5ac1", "url": null, "created_at": "Wed Aug 31 14:07:23 +0000 2011", "contributors_enabled": false, "time_zone": "Tokyo", "profile_sidebar_border_color": "C0DEED", "default_profile": true, "following": null}, "place": null, "retweet_count": 0, "geo": null, "id": 187179645026836480, "source": "<a href=\"http://www.movatwi.jp\" rel=\"nofollow\">\u30e2\u30d0\u30c4\u30a4 / www.movatwi.jp .</a>"}


My end goal is to count the number of times a specific word occurs in the "text" field of all the tweets. I have tried a number of different approaches with varying degrees of success but here's where I'm at:



import fileinput
import json
import sys
import os

line = []

inputfilename = sys.argv[1]

for line in fileinput.input([inputfilename]):
tweettext = json.loads(line).get('text').split()
print tweettext


This loops through the file and splits the text up into the individual words from each lines "text" field but does not create a single list of words. To add to the issue when it runs into a blank line it fails:



[u'RT', u'@keenakan:', u'kamu', u'tidak', u'perlu', u'memperjuangkan', u'aku.', u'Yang', u'perlu', u'ialah', u'aku', u'dan', u'kamu', u'yang', u'memperjuangkan', u'kita.', u'-@commaditya']
[u'RT', u'@TheRealToxicBoi:', u'#LiesBeforeSex', u"I'll", u'be', u'Gentle!']
[u'@coliriostar', u'Quer', u'GANHAR', u'R$', u'300,00', u'em', u'vale', u'compra?', u'SIGA', u'@eucompronanet', u'e', u'saiba', u'como', u'participar,', u'\xe9', u'simples', u'e', u'r\xe1pido!', u'at\xe9', u'+', u'ci']
Traceback (most recent call last):
File "newexample.py", line 11, in <module>
tweettext = json.loads(line).get('text').split()
AttributeError: 'NoneType' object has no attribute 'split'


Can anyone suggest a solution?



edit:



Based on the first comment I've edited the code as follows based on my understanding:



import fileinput
import json
import sys
import os

line = []
tw = 0

inputfilename = sys.argv[1]

for line in fileinput.input([inputfilename]):
line = line.strip();
if not line: continue
tweettext = json.loads(line).get('text')
if not json.loads(line).get('text'):
continue
words = tweettext.split()
print words
tw = len(words)

print "total number of words", tw


my output is looking better, at least I'm not getting the "Attribute Error: NoneType" anymore. Now the output seems to consist of individual dictionaries instead of just one large dict. Again my goal is count how many times each word occurs and I'm not sure how to do that unless they are all in one dict. Here's a sample of the output at this point:



[u'L', u'Lawliet', u'(Sweets', u'Addict)', u'+', u'Kenshin', u'Himura', u'(Samurai)', u'+', u'Kyon', u'(Lazy', u'and', u'Carefree', u'Bum)', u'=', u'Sakata', u'Gintoki', u'xD', u'May...', u'http://t.co/LD4E1j1v']
[u'Yay', u'~', u'I', u'have', u'ice~I', u'can', u'reach', u'the', u'ice', u'maker!', u'ch', u'sees', u'gaps', u'in', u'the', u'freezer', u'as', u'a', u'challenge', u'and', u"it's", u'usually', u'full', u'to', u'busting.', u'But', u'not', u'now', u'Haha!']
[u'Hoi']
[u'everyones', u'on', u'twitter.']
total number of words 429023


I would guess that I can probably setup counters for each word within the for loop somehow.? As you you can see the total word count works fine because it adds the number of words from each line, but I can't quite see how I would do it to determine unique words like:



len(set(words))


EDIT:



Here's my final solution:



import fileinput
import json
import sys
import os
from collections import defaultdict

line = []
tw = 0

inputfilename = sys.argv[1]

word_count = defaultdict(int)

for line in fileinput.input([inputfilename]):
line = line.strip();
if not line: continue
tweettext = json.loads(line).get('text')
if not json.loads(line).get('text'):
continue
words = tweettext.split()
tw += len(words)
for word in words:
word_count[word]+=1

print word_count
print "total number of words", tw




PHP objects that stay in memory

I recall reading on php.net (although unfortunately can't seem to find the page) that the PHP interpreter can run in different ways - most commonly, every time a page is requested, an instance of the PHP interpreter is created, runs its course, and then is destroyed, along with all the memory associated with that particular page call. Apparently, it is also possible to allow all the memory to linger, so that it can be used again in future page calls; as I understood it, essentially allowing multiple different PHP scripts to access and modify the same objects, without losing them after the script is complete.



Or at least, so I remember. Is there any truth to this? If so, how would I set it up?





How to format a varchar in a gridview in military time to standard time

There is a varchar column in the database table in this format of military time 1230 or 1750 or 1320 and that field get populated into a gridview in asp. I need to convert that string to standard time. I have tried the DateFormatString and nothing seems to work.



the asp is



<asp:BoundColumn DataField="ScanTime" SortExpression="ScanTime" ReadOnly="True" 
HeaderText="Scan Time" DataFormatString="{0:hh}:{0:mm} {tt}">
<ItemStyle Width="80px"></ItemStyle>
</asp:BoundColumn>


that DateFormatString causes Input string was not in a correct format. error.



Please help I have tried combinations of hh:mm and things like that but since its a varchar I think its failing





mingw g++ gives foreign language warnings instead of english ones

My problem is the following:

When I compile a C++ Project with eclipse (Juno, 64bit, Java 7u3) on my Windows 7 laptop, I get german errors/warnings. This results in warnings showing as errors in eclipse.



Windows (7, 64bit) is set to:

Display Language: English

Format: German (Switzerland)

Location: Switzerland

Language for non Unicode programs: English (Canada)



On my other Windows 7 (64bit) PC I have the exact same settings and don't have any problems.



I tried:




  • Adding -Duser.language=en to the end of my eclipse.ini file.

    Which did not work

  • Changing the Format to English.

    Which actually worked but is not
    really an option due to the wrong format in other places

  • Many different things I can't remember (e.g. Environment variables in
    eclipse, etc.)

    Again, nothing helped





Creating a web based point of sale system

I am considering of prototyping a web based point-of-sale system.
I don't have programming skills but I'm thinking of using this project in order to learn.



I would like to ask you the following two questions:




  1. Do you think the above task is achievable within the period of 6 months (for building a rough prototype of the basic functions of a POS)?

  2. If yes, which programming language would you recommend me and why? (I was thinking of Python)



Your advice is greatly appreciated!





Why is my application icon not transparent?

In XAML, I am attempting to bind the window/application icon to an icon on the file system.



In Window.xaml



Icon="{Binding ApplicationIcon}"


In AppViewModel.cs



public ImageSource ApplicationIcon
{
get
{
return new BitmapImage(new Uri(pathReadFromConfigFile));
}
}


When I do this, the icon is shown but it is not transparent. However, if I set the icon within the project (not using binding), the icon is added to the project and it is transparent when I start the application. Why is it acting differently between these two scenarios?





Asp.net mvc entity framework 4.1 saving on sub model codefirst

ok i have model



    public long prop1 { get; set; }   

[Required]
public string prop2 { get; set; }

[Required]
public string prop3 { get; set; }

[Required]
public string prop4 { get; set; }


this table is the part of database generated from code first.



now the requirement arises that there will be a form with prop3 only and after submitting it it will be updated on the bases of prop1. how will i make it work with regard to creation of model and dbcontext? what is the usual practise here?





Creating Primary Key field on MVC class

I am new to MVC and C#. I just stumbled on it and found it interesting. I encountered an issue which will not allow me proceed.
Here is my code:



`using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyHotel.Models
{
public class AccountTypes
{
public int AccountTypeID { get; set; }
public string AccountTypeName { get; set; }
}
}


`
I created the controler and the view thereafter.



And for this, I keep got this error:



One or more validation errors were detected during model generation:



`System.Data.Edm.EdmEntityType: : EntityType 'AccountTypes' has no key defined. Define      the key for this EntityType.


System.Data.Edm.EdmEntitySet: EntityType: EntitySet "AccountTypes" is based on type "AccountTypes" that has no keys defined.`



I google that the answers were to add [Key] over the public int AccountTypeID { get; set; } so it could look like this:



`namespace MyHotel.Models
{
public class AccountTypes
{
[Key]
public int AccountTypeID { get; set; }
public string AccountTypeName { get; set; }
}
}
`


But no result till now.
I will appreciate any help.
Note: I am using MVC 4



Peter





Creating dynamic objects to a parent object and assigning keys and values?

I am almost there with this but cannot seem to get this functionality going as planned.



I have two arrays: keyArray and ValArray;



What I am trying to do is to have a function pass two arguments (keyArr,valArr). Within this function, a parent object is declared and a (for-loop) loops through the passed argument's length (in this case "keyArr") creates new objects according the length of the passed argument. And then, the newly created objects are assigned the keys and values.



The issue is that I am able to create the parent object"mObj", and children Objects to "mObj", but am only able to assgin keys and values to the first child object "obj0" not rest of the children objects correctly. At the end of the code, this is what I would like to get:



enter code heremObj.obj0.firstname = John;
mObj.obj0.lastname = superfly;
mObj.obj0.email = "john.superfly@yahoo.com";

mObj.obj1.firstname = John;
mObj.obj1.lastname = superfly;
mObj.obj1.email = "john.superfly@yahoo.com";

mObj.obj2.firstname = John;
mObj.obj2.lastname = superfly;
mObj.obj2.email = "john.superfly@yahoo.com";


This is my code:



 var keyArr = ["firstname","lastname","email"];
var valArr = ["John","Superfly","jsuperfly@yahoo.com"];

function test(keys,vals) // FUNCTION TEST ACCEPTS TWO ARGS
{
var mObj = {}; // PARENT OBJECT
var len = (keys.length); //ARGUMENT KEY'S LENGTH

for(var i=0; i<len; i++)
{
mObj["obj" + i] = {}; //CHILDREN OBJECTS ARE CREATED TO PARENT "mObj" OBJECT
mObj["obj" + i][keys[i]] = vals[i]; //KEYS AND VALUES ARE ASSIGNED HERE
}

alert(mObj.obj1.firstname); // CURRENTLY RETURNS "UNDEFINED"
}

test(keyArr,valArr);


Any insight into this would highly be appreciated.
Thank you.





rails model association using has_many: through

i have a lessons table and a tags table. i associate both of the them using a has_many :through relationship and my middle table is tags_relationship.rb



class Lesson < ActiveRecord::Base
attr_accessible :title, :desc, :content, :tag_name
belongs_to :user

has_many :tag_relationships
has_many :tags, :through => :tag_relationships
end

class Tag < ActiveRecord::Base
attr_accessible :name

has_many :tag_relationships
has_many :lessons, :through => :tag_relationships
end


in one of my views, im trying to create a a virtual attribute. i have...



    <div class="tags">
<%= f.label :tag_name, "Tags" %>
<%= f.text_field :tag_name, data: { autocomplete_source: tags_path} %>
</div>


but my lessons table doesn't have that attribute, tag_name, so it calls my method instead



    def tag_name
????????
end

def tag_name=(name)
self.tag = Tag.find_or_initialize_by_name(name) if name.present?
end


however im not sure what to put inside the ????????. im trying to refer the :name attribute inside my tags table.



back then i used a has_many and belongs_to relationship. my lesson belonged to a tag (which was wrong) but i was able to write...



tag.name


and it worked. but since its a has_many :through now, im not sure. i tried using tags.name, Lessons.tags.name, etc but i cant seem to get it to work. how can i refer to the tags table name attribute? thank you





Is it possible, via PowerShell, to subscribe to and execute code on the the event raised when a new mailbox is created in Exchange 2010

Using PowerShell, it is possible to subscribe to a .NET, WMI or engine event via Register-ObjectEvent, Register-WmiEvent or Register-EngineEvent, respectfully, and each of these cmdlets have an –Action parameter to which you can hand a block of code that is to be invoked when the event occurs. I'm not sure if this would be the appropriate mechanism to do this, but the goal would be to be able to run some C# code that would make a call to an API when a new mailbox is added in Exchange.



To provide some context here, I have a cloud based mail service that needs to know how many users a given organization is using. Doing something like an AD sync is not an option. I have access to the Exchange Server 2010 server during the initial provisioning of the service and I will be able to remotely execute PowerShell scripts against Exchange (I should be able to access AD, as well, via Exchange) during that initial provisioning.



Any help here would be greatly appreciated. I think the biggest difficulty here is finding the event I would need to hook into. There's no sense in my exploring this any further if I can't hook into that New-Mailbox event and execute some code off of that event.





Security Login Problems in VS VB

I have added 2 types of user to my website using the security pages for asp.net secraty and just general registered users.



Firstly, when I come to login I can login with any username and password wether it has been registered or not.



I cant keep loggied in between pages, because I am unsure how to do it.



Thanks.





Java: How do i create objects in a static method and also call for methods from another class?

I am doing this Java assignment for hours and stuck with this tester class for very almost 5 hours.



In this assignment, I have created a Product class, a Money class, a LineItem class and an Inventory class. Now i need to create a test class to test the program by putting new lineitems into the inventory array.



In the tester class, I am trying to create a static method public static void addTestItems(Inventory theInventory) which suppose to add 4 items. For each item I will need to create a product object followed by a LineItem object to contain the newly created product. next i need to use a method from the inventory class to add the items into the array in the inventory class.



What i have tried too so far:



private static void addTestItems(Inventory theInventory)
{
Inventory[] _items;
Product product1 = new Product("Book","Objects first with Java"," An excellent introductory Java textbook");
Product product2 = new Product("CD","The dark side of the moon","The all-time classic Pink Floyd album");
Product product3 = new Product("DVD", "Transformers","Robots in disguise");
Product product4 = new Product("Laptop","Lenovo T42","A good yet affordabble laptop");
Money unitPrice1 = new Money(29,99);
Money unitPrice2 = new Money(4,99);
Money unitPrice3 = new Money(9,99);
Money unitPrice4 = new Money(450,0);
_items[1] = new LineItem(product1,5,unitPrice1);
_items[2] = new LineItem(product2,8,unitPrice2);
_items[3] = new LineItem(product3,200,unitPrice3);
_items[4] = new LineItem(product4,9,unitPrice4);
}


The current error is incompatible types- found LineItem but expected Inventory so i tried changing Inventory[] _items; to LineItem[] _items;. But the error was variable _items may not be initialise.



Sorry guys I am a real noob in Java, I tried searching on-line for ages but I do not quite understand most results. The only one i understand was http://forums.devshed.com/java-help-9/bluej-compiler-error-cannot-find-symbol-variable-object-688573.html but i tired putting into my context but failed. I also found lot of results but they had constructors and instance variables in them which my teacher specifically mentioned that I will not need them.



Wonder if expert could guide me along like let me know my mistakes. Thanks thanks.





How to get an ocra application to be accepted by antiviruses

Alright, so judging by the title (if you practice Ruby), you should know what Ocra is. If you don't, here's a brief explanation:

Ocra is a command added to the command prompt in order to convert ruby programs to executable. So .rb to .exe.


In order for one to convert a ruby program to executable, they would type in the command prompt:



cd <locationOfFile>
ocra rubyProgram.rb


and then ocra would run the program and when that's done, it runs some scripts which completes the program. Then afterwards the executable version of the program would be in the same directory as the original ruby version and the same name.

So recently I noticed that my antiviruses are removing the program from my computer telling me it's a bloodhound. It's getting really annoying and I'm getting tired of having to use ocra over and over again just to remake a program.

I have two antiviruses: McAffee and Symnatec; so that means double the security. What can I change so that my antiviruses ignore the program?





How is it possible that loop-recur throws a StackOverflowError?

I´ve been trying to implement a tail-recursive version of chainl1, but even with the loop-recur it throws a StackOverflowError. How is that possible and what can i do to change that?



(defn atest [state]
(when-not (and (= "" state) (not (= (first state) \a)))
(list (first state) (. state (substring 1)))))
(defn op [state]
(when-not (and (= "" state) (not (= (first state) \a)))
(list #(list :| %1 %2) (. state (substring 1)))))
(defn chainl1-helper [x p op]
(fn [state]
(loop [x x
state state]
(if-let [xs (op state)]
(when-let [xs2 (p (second xs))]
(recur ((first xs) x (first xs2)) (second xs2)))
(list x state)))))

(defn chainl1 [p op]
(fn [state]
(when-let [[v s] (p state)]
((chainl1-helper v p op) s))))
(def test-parse (chainl1 atest op))
(defn stress-test [n] (test-parse (apply str (take n (interleave (repeat "a") (repeat "+"))))))
(stress-test 99999)




transforming rules into lists

i want to get data from rules into a list in order to be farther processed,
for example i have:



course_meetings(comm401,tutorial,t07,mohamed_esameldin,'tutorial for t07').
course_meetings(comm401,tutorial,t08,sally_mahmoud,'tutorial for t08').
course_meetings(comm401,tutorial,t09,mohamed_esameldin,'tutorial for t09').
course_meetings(comm401,tutorial,t10,sally_mahmoud,'tutorial for t10').
course_meetings(comm401,lecture,all_group_4,dr_amr_talaat,'lecture 1').



i want to transform this rules into a list like this:
[[comm401,tutorial,t07,mohamed_esameldin,'tutorial for t07'], [comm401,tutorial,t08,sally_mahmoud,'tutorial for t08'],
[comm401,tutorial,t09,mohamed_esameldin,'tutorial for t09']]



Thanks in advance for your help i am a newbie in prolog and hope my question isnt Vague,
also if there is a better way to process this data please direct me,
thanks.





Does GoDaddy linux web hosting plan supports JDBC?

I want to know if some of the linux web hosting 4GH plans supports JDBC.
My only needs is to host a mysql server that will be accessed from a java desktop application.
Thanks!





DataContract class for Facebook 'Like' Graph API

So I'm trying to decode the json returned by the Facebook Graph API for user likes into objects using the DataContractJsonSerializer. I've tried creating a couple different [DataContract] classes now but with no luck.



What is the correct way to create a [DataContract] class for this data.



{
"data": [
{
"name": "Earlyups",
"category": "Recreation/sports",
"id": "170410902986097",
"created_time": "2012-04-09T03:34:11+0000"
},
{
"name": "pictureline inc.",
"category": "Local business",
"id": "28861182380",
"created_time": "2012-03-28T02:02:24+0000"
},
{
"name": "Jackson Hole Mountain Resort",
"category": "Sports/recreation/activities",
"id": "24718308041",
"created_time": "2012-03-20T16:10:45+0000"
}
],
"paging": {
"next": "next_page_request_url"
}
}




NSAssert in Singleton : why this code is valid?

i don't understand the use of NSAssert in +alloc, as when +alloc is called from +sharedGameManager, the static _sharedGameManager variable is nil (so NSAssert should stop execution the first time [self alloc] init] is called...)



+(GameManager*)sharedGameManager {
@synchronized([GameManager class])
{
if(!_sharedGameManager)
[[self alloc] init];
return _sharedGameManager;
}
return nil;
}

+(id)alloc
{
@synchronized ([GameManager class])
{
NSAssert(_sharedGameManager == nil,
@"Attempted to allocated a second instance of the Game Manager singleton");
_sharedGameManager = [super alloc];
return _sharedGameManager;
}
return nil;
}


Thanks for your answer





Dynamically set Access-Allow-Control-Origin

I've read about getting around the same origin policy when sending POST requests here and here and feel like I have a decent understanding of how the dynamic works. Modern browsers support it by setting Access-Allow-Control-Origin on the receiving server, and all browsers work by submitting the request through an iframe.



My question is two fold:
1. Is there a way to dynamically set the origin allowed so that you don't have to set Access-Allow-Control-Origin: *. More precisely is there a way to do it with a particular view or set of views in django. ( I know there is this gist which is usable as a middleware, but there doesn't seem to be a way to set the origin you are allowing on the fly.



2.Is there a wrapper you can use that has the deprecation built in? In other words it will try to use Access-Allow-Control-Origin and if the browser doesn't support it it will use an iframe instead.





$_GET with Switch Statement

i have alot of get values that define the page the user gonna see , for example for "profile" i will show the profile page and so on..



to find out what page to display i tried to do something like that:



switch ($_GET) {
case 'profile':
require_once('function/profile.php');
break;
case 'team':
require_once('function/team.php');
break;


but it shows no result..



i send the GET request like that : index.php?profile , for example..



what is the problem here and how can i can manage to do something similar that work as well. thank you in advance!





Return an array of objects from a REST enabled WCF service

I am returning a complex type from my WCF service (which is hosted in SharePoint 2010) and I wan to be able to return an array (or collection of some type) as a property.
The aim is to have a generic Type that contains standard stuff like Error, Message and an array of Data.
On the server I am using proper types and only want the array of objects to be returned in the JSON.
It works fine if I return an collection of the real type...but casting to objects causes a login challenge (which seem weird) and even as the admin...I can't get past it.



    public class MyServiceReponse
{
public List<string> Errors { get; set; }
public List<string> Messages { get; set; }
public bool Success { get; set; }
public int DataCount { get; set; }
public object[] ResponseData { get; set; }
public IEnumerable<MyOtherType> Sites { get; set; }

public MyServiceReponse()
{
Errors = new List<string>();
Messages = new List<string>();
Success = true;
}

public void AddError(Exception ex)
{
Success = false;
Errors.Add("Oooops, there seems to be a problem. (" + ex.Message + ")");
}
}
public class MyOtherType
{
public string Name { get; set; }
public string Ticker { get; set; }
public string Other { get; set; }
}


How would I go about achieving this?
First I though I would just have ResponseData as an object...setting my collection to it...but that doesn't work either.
Thx





Find and Replace with ASP Classic

I have an function in ASP VB. and I need to replace the exact word in it. For example I have an string like "wool|silk/wool|silk". I want to replace just silk and not silk/wool.



' "|" is a devider
cur_val = "wool|silk/wool|silk"
cur_val_spl = Split("wool|silk/wool|silk", "|")
key_val = "silk"
For Each i In cur_val_spl
If i = key_val Then
cur_val = Replace(cur_val, ("|" & i), "")
cur_val = Replace(cur_val, i, "")
End If
Next
Response.Write(cur_val)


In this case my result would be "wool/wool" but what I really want is this "wool|silk/wool".

I really appreciate any help.





Niblack algorithm for Document binarization

i've this photo :



enter image description here



and i'm trying to make Document binarization using niblack algorithm
i've implemented the simple Niblack algorithm



T = mean + K* standardDiviation



and that was it's result:



enter image description here



the problem is there's some parts of the image in which the window doesn't contain any objects so it detects the noise as objects and elaborates them .



i tried to apply blurring filter then global thresholding
that was the result :



enter image description here



which wont be solved by any other filter
i guess the only solution is preventing the algorithm from detecting global noise if the window i free from object



i'm interested to do this using niblack algorithm not using other algorithm so any suggestions ?