Daily Archives

Articles indexed Saturday February 26 2011

Page 6/10 | < Previous Page | 2 3 4 5 6 7 8 9 10  | Next Page >

  • Is there an easy way to merge C# dynamic objects

    - by ajma
    Let's say I have two dynamic objects like this: var objA = new { test = "test", blah = "blah" }; var objB = new { foo = "foo", bar = "bar" }; I want to combine them to get: new { test = "test", blah = "blah", foo = "foo", bar = "bar" }; I won't know what the properties are for both objA and objB at compile time. I want this to be like jquery's extend method. Anybody know of a library or a .net framework class that can help me do this?

    Read the article

  • Passing report values to a query

    - by Beavis
    I'm a novice with Microsoft Access as my background is mostly .NET. I'm sure what I'm trying to accomplish is dead simple but I need some direction. I have a report and a query. The query returns a single numeric value based on a single numeric criteria. Select total from table where id = [topic] I have placed a text box on my report so I can feed the id to this query and in return get the total. It seems like DLookUp is what I want but no matter how I construct it, I get an "#Error" in the text box when I run the report. Currently my DLookUp looks like this (I just hard-coded now for simplicity): =DLookUp("[total]","myquery","[topic] = 3") How can I pass a value from a field on my report to a query so I can return the query's single numeric value? Thanks.

    Read the article

  • Trying to draw 2 objects on screen and store the selected item names in an array

    - by thefonso
    Ok...this is a homework question, here is what i'm asked to do.... "Allow the user to draw two Shapes, which when instantiated, get put into the array myShapes...(store the shapes in the createShape() method." I want to know if I'm going in the right direction. Do I need to modify only Model.java or GUIDemo.java as well? Am I sufficient in thinking of only storing the values for the array via a loop inside my createShape() method? How do I go a bout checking to see if things work so far. There are many steps for this homework project after this one but i'm stuck here. Please point me in the right direction. The array myShapes lives inside my model class inside Model.java: package model; import java.awt.Color; import java.awt.Container; import shapes.Line; import shapes.Oval; import shapes.Rectangle; import shapes.Shape; import shapes.Triangle; import interfaces.Resettable; public class Model implements Resettable { private Container container; private String message; public final static String DRAW = "Draw"; public final static String MOVE = "Move"; public final static String REMOVE = "Remove"; public final static String RESIZE = "Resize"; public final static String FILL = "Fill"; public final static String CHANGE = "Change"; public final static String RECTANGLE = "Rectangle"; public final static String OVAL = "Oval"; public final static String LINE = "Line"; public final static String TRIANGLE = "Triangle"; private String action = DRAW; private boolean fill = false; public static String[] selections = {"Rectangle", "Oval", "Line", "Triangle"}; //project 9 begin public Shape[] myShapes = new Shape[2]; //project 9 stop private String currentShapeType; private Shape currentShape; public Color lineColor; private Color fillColor = Color.gray; public Shape createShape() { if(currentShapeType == RECTANGLE){ currentShape = new Rectangle(0, 0, 0, 0, lineColor, fillColor, fill); } if(currentShapeType == OVAL) { currentShape = new Oval(0,0,0,0, lineColor, fillColor, fill); } if(currentShapeType == LINE) { currentShape = new Line(0,0,0,0, lineColor, fillColor, fill); } if(currentShapeType == TRIANGLE) { currentShape = new Triangle(0,0,0,0, lineColor, fillColor, fill); } //project 9 start if(myShapes[0] == null) { myShapes[0]=currentShape; } else { myShapes[1]=currentShape; } //project 9 stop return currentShape; } public Shape getCurrentShape() { return currentShape; } public String getCurrentShapeType(){ return currentShapeType; } public void setCurrentShapeType(String shapeType){ currentShapeType = shapeType; } public Model(Container container) { this.container = container; } public void repaint() { container.repaint(); } public void resetComponents() { action = DRAW; currentShape = null; if (container instanceof Resettable) { ((Resettable) container).resetComponents(); } } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public boolean isFill() { return fill; } public void setFill(boolean fill) { this.fill = fill; } public void setMessage(String msg) { this.message = msg; } public String getMessage() { return this.message; } public Color getLineColor() { return this.lineColor; } public void setLineColor(Color c) { this.lineColor = c; } public String toString() { return "Model:\n\tAction: " + action + "\n\tFill: " + fill; } } The application is run from GUIDemo.java: package ui.applet; import interfaces.Resettable; import java.applet.Applet; import java.awt.Graphics; import event.ShapeMouseHandler; import shapes.Shape; //import ui.panels.ButtonPanel; import ui.panels.ChoicePanel; import ui.panels.MainPanel; import model.Model; @SuppressWarnings("serial") public class GUIDemo extends Applet implements Resettable { MainPanel mainPanel; Model model; ChoicePanel choicePanel; public void init() { resize(600,400); model = new Model(this); choicePanel = new ChoicePanel(model); mainPanel = new MainPanel(model); this.add(choicePanel);//this is the drop down list this.add(mainPanel);//these are the radio buttons and reset button ShapeMouseHandler mouseHandler = new ShapeMouseHandler(model); addMouseListener(mouseHandler); addMouseMotionListener(mouseHandler); } public void paint(Graphics g) { Shape shape; shape = model.getCurrentShape(); if(shape != null) { shape.draw(g); } System.out.println(model); System.out.println(shape); } public void resetComponents() { mainPanel.resetComponents(); choicePanel.resetComponents(); } }

    Read the article

  • Animated record deletion with jquery like mootools example

    - by twitter
    I was reading around and saw this example from David Walsh about how to animate record deletion with mootools. Does the exact same effect exist in jquery? This is his mootools code. window.addEvent('domready',function() { $$('a.delete').each(function(el) { el.addEvent('click',function(e) { e.stop(); var parent = el.getParent('div'); var request = new Request({ url: 'mootools-record-delete.php', link: 'chain', method: 'get', data: { 'delete': parent.get('id').replace('record-',''), ajax: 1 }, onRequest: function() { new Fx.Tween(parent,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function() { new Fx.Slide(parent,{ duration:300, onComplete: function() { parent.dispose(); } }).slideOut(); } }).send(); }); }); });

    Read the article

  • How to I display results of phpcs in VIM?

    - by Matt
    I am presently trying to use PHP Codesniffer (PEAR) in vim for PHP Files. I have found 2 sites that give code to add into the $HOME/.vim/plugin/phpcs.vim file. I have added the code and I "think" it is working, but I cannot see the results, I only see one line at the very bottom of vim that says (1 of 32) but I cannot see any of the 32 errors. Here is my .vimrc file " Backup Options -> Some People may not want this... it generates extra files set backup " Enable Backups set backupext=.bak " Add .bak extention to modified files set patchmode=.orig " Copy original file to with .orig extention Before saving. " Set Tabs and spacing for PHP as recomended by PEAR and Zend set expandtab set shiftwidth=4 set softtabstop=4 set tabstop=4 " Set Auto-indent options set cindent set smartindent set autoindent " Show lines that exceed 80 characters match ErrorMsg '\%80v.\+' " Set Colors set background=dark " Show a status bar set ruler set laststatus=2 " Set Search options highlight, and wrap search set hls is set wrapscan " File Type detection filetype on filetype plugin on " Enable Spell Checking set spell " Enable Code Folding set foldenable set foldmethod=syntax " PHP Specific options let php_sql_query=1 " Highlight sql in php strings let php_htmlInStrings=1 " Highlight HTML in php strings let php_noShortTags=1 " Disable PHP Short Tags let php_folding=1 " Enable Ability to FOLD html Code I have tried 2 different versions of phpcs.vim, and I get the same results for both: Version 1 (found at: VIM an a PHP IDE) function! RunPhpcs() let l:filename=@% let l:phpcs_output=system('phpcs --report=csv --standard=YMC '.l:filename) " echo l:phpcs_output let l:phpcs_list=split(l:phpcs_output, "\n") unlet l:phpcs_list[0] cexpr l:phpcs_list cwindow endfunction set errorformat+=\"%f\"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,\"%m\" command! Phpcs execute RunPhpcs() Version 2: (found at Integrated PHP Codesniffer in VIM ) function! RunPhpcs() let l:filename=@% let l:phpcs_output=system('phpcs --report=csv --standard=YMC '.l:filename) let l:phpcs_list=split(l:phpcs_output, "\n") unlet l:phpcs_list[0] cexpr l:phpcs_list cwindow endfunction set errorformat+="%f"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,"%m" command! Phpcs execute RunPhpcs() Both of these produce identical results. phpcs is installed on my system, and I am able to generate results outside of vim. Any help would be appreciated I am just learning more about vim...

    Read the article

  • ASP.NET MVC static-asset aides/practices

    - by shannon
    I want to keep assets that are only used by one view in a view-specific folder, so my Search.aspx properly finds images/*.jpg, and helps me maintain my convention: ~/Areas/Candidate/Views/Job/Search.aspx -> ~/Assets/Candidate/Job/Search/images/*.jpg Perhaps with the ability to easily reference controller- or area-common assets manually or automatically: ~/Assets/Candidate/Job/images/*.jpg ~/Assets/Candidate/images/*.jpg If you wonder why I'm doing this, then speak up; I'm probably missing something. But here's why: I don't want stale static assets sitting in my ASP.NET MVC projects, which I expect to be an automatic outcome of the ~/Assets/Images folder: i.e. As a shared asset loses its last reference-count, who knows to delete it, especially with it being so difficult to trace content link validity in MVC projects? How do you, personally, do this? I can imagine, for example: Implement HtmlHelper extension methods for URL-generation. Extending ViewPage and ViewMasterPage with URL-generation methods. Implementing an inbound request filter to search related folders for static assets. and, are there good libraries out there for this? For example, something that also automatically appends timestamps for .JS and .CSS files, writes the / tags for me, and maybe even that allows me to inject includes in the head section from outside head code?

    Read the article

  • maven and unit testing - combining maven surefire plugin AND testNG eclipse plugin

    - by lisak
    Hey, could you please share your way of unit testing in eclipse ? Are you using surefire plugin, m2eclipse & maven, or only testNG eclipse plugin ? Do you combine these alternatives ? I'm using testNG + maven surefire-plugin and I had been using the testNG eclipse plugin a year ago so that I could see the results in testNG view. Then I started using Maven, but when I do "maven test phase" using m2eclipse, there is only console output and surefire reports that I can check in browser and to choose what test suite, test, or test method can be set up only via testng.xml. On the other hand, if you use only surefire plugin and you have some specific settings regarding classpath etc., that you rely on, then running tests via testNG eclipse plugin doesn't have to be compatible with your code. Using surefire plugin, the classpath is different - target/test-classes and target/classes - than using testNG plugin, that is using the project classpath. How do you go about what I was just talking about? Is it possible to synchronize "maven test" using m2eclipse and surefire plugin WITH testNG eclipse plugin and view ? EDITED: I'm also wondering, why the Maven project ("Java build path") output folder is target/classes for src/main and src/test whereas surefire plugin makes two locations target/test-classes and target/classes Thank you very much for your your opinions.

    Read the article

  • How can you block access form internet explorer in asp mvc

    - by Chase Aucoin
    I love microsoft development products! I hate microsoft browsers... I have made the decision to cut ties with internet explorer until they add support for some common W3 approved items. Namely 'multiple' in forms as well as about 5 other things... and as such I would like to urge my visitors to use a better browser. is there a way to setup an http handler or perhaps something in the asax file to route all ie users to a custom page? Thanks for the help! p.s. microsoft why must you make me love you and hate you.

    Read the article

  • When is a Google Maps API key required?

    - by Thomas
    Recently Google changed it's policy on the use API keys. You're now supposed to no longer need an API key to place Google Maps on your website. And this worked perfectly. But now I have this map (without API key) running on my localhost, which works fine. But as soon as I place it online, I get a popup saying that I need another API key. And on another page on that website, Google Maps does work. Could it maybe have something to do with that the map that doesn't work have a lot (30+) of markers on it? Actually using an API key wouldn't be a very nice solution to me, as this is part of a Wordpress plugin used on many websites.

    Read the article

  • Using abstract base to implement private parts of a template class?

    - by StackedCrooked
    When using templates to implement mix-ins (as an alternative to multiple inheritance) there is the problem that all code must be in the header file. I'm thinking of using an abstract base class to get around that problem. Here's a code sample: class Widget { public: virtual ~Widget() {} }; // Abstract base class allows to put code in .cpp file. class AbstractDrawable { public: virtual ~AbstractDrawable() = 0; virtual void draw(); virtual int getMinimumSize() const; }; // Drawable mix-in template<class T> class Drawable : public T, public AbstractDrawable { public: virtual ~Drawable() {} virtual void draw() { AbstractDrawable::draw(); } virtual int getMinimumSize() const { return AbstractDrawable::getMinimumSize(); } }; class Image : public Drawable< Widget > { }; int main() { Image i; i.draw(); return 0; } Has anyone walked that road before? Are there any pitfalls that I should be aware of?

    Read the article

  • Override Linq-to-Sql Datetime.ToString() Default Convert Values

    - by snmcdonald
    Is it possible to override the default CONVERT style? I would like the default CONVERT function to always return ISO8601 style 126. Steps To Reproduce: DROP TABLE DATES; CREATE TABLE DATES ( ID INT IDENTITY(1,1) PRIMARY KEY, MYDATE DATETIME DEFAULT(GETUTCDATE()) ); INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; SELECT CONVERT(NVARCHAR,MYDATE) AS CONVERTED, CONVERT(NVARCHAR(4000),MYDATE,126) AS ISO, MYDATE FROM DATES WHERE MYDATE LIKE'Feb%' Output: CONVERTED ISO MYDATE --------------------------- ---------------------------- ----------------------- Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Linq-to-Sql calls CONVERT(NVARCHAR,@p) when I cast ToString(). However, I am displaying all my data in the ISO8601 format. I would like to override the database default if possible to CONVERT(NVARCHAR,@p,126). I am using Dynamic Linq-to-Sql as demoed by ScottGu to process my data. PropertyInfo piField = typeof(T).GetProperty(rule.field); if (piField != null) { Type typeField = piField.PropertyType; if (typeField.IsGenericType && typeField.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { filter = filter .Select(x => x) .Where(string.Format("{0} != null", rule.field)) .Where(string.Format("{0}.Value.ToString().Contains(\"{1}\")", rule.field, rule.data)); } else { filter = filter .Select(x => x) .Where(string.Format("{0} != null", rule.field)) .Where(string.Format("{0}.ToString().Contains(\"{1}\")", rule.field, rule.data)); } } I was hoping my property would convert the expression from CONVERT(NVARCHAR,@p) to CONVERT(NVARCHAR,@p,126), however I get a NotSupportedException: ... has no supported translation to SQL. public string IsoDate { get { if (SUBMIT_DATE.HasValue) { return SUBMIT_DATE.Value.ToString("o"); } else { return string.Empty; } } }

    Read the article

  • problem using default_scope on a model table

    - by DannyRe
    Hey. In my controller/index action I use the following query: @course_enrollments = current_user.course_enrollments This is what my table looks like. It is referencing a course table. The course table has a colum 'title'. create_table "course_enrollments", :force => true do |t| t.integer "user_id", :null => false t.integer "course_id", :null => false t.datetime "created_at" t.datetime "updated_at" end I want to be able to order my course_enrollments by course in my index view. Furthermore Id like to do a default_scope in my model, like this: default_scope :order => 'title asc' any suggestions? Thx for your time

    Read the article

  • Flex 4 hideEffect transition bug

    - by xerious87
    I'm trying to create a slide effect. Everything works fine except when the hideEffect animation is shown for the first time. The content does not become invisible when crossing the TabNavigator's border, which looks really ugly in my current project. The following simple example demonstrates the problem: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" backgroundColor="0xDDDDDD"> <fx:Declarations> <s:Move id="hideEffect" xTo="700" /> </fx:Declarations> <mx:TabNavigator width="500" height="300" x="100" y="0"> <s:NavigatorContent label="ONE" hideEffect="{hideEffect}"> <s:BorderContainer backgroundColor="0xFF0000" height="100" width="100"/> </s:NavigatorContent> <s:NavigatorContent label="TWO" hideEffect="{hideEffect}"> <s:BorderContainer backgroundColor="0xFF0000" height="100" width="100"/> </s:NavigatorContent> <s:NavigatorContent label="THREE" hideEffect="{hideEffect}"> <s:BorderContainer backgroundColor="0xFF0000" height="100" width="100"/> </s:NavigatorContent> <s:NavigatorContent label="FOUR" hideEffect="{hideEffect}"> <s:BorderContainer backgroundColor="0xFF0000" height="100" width="100"/> </s:NavigatorContent> </mx:TabNavigator> </s:Application> Screenshot: hideEffectBug Any ideas how to fix this bug?

    Read the article

  • Send post to a different domain using JS

    - by Lior
    Hello, I'd like a post request to be sent once a certain text input field is changed, using javascript. So here is my current code: <input name="message" onchange="$.ajax({type: \"POST\", url: \"http://example.com/example.php\", data: \"message=\" + document.getElementsByName(\"message\")[0].value});" /> Now, it's working on a regular connection, but it's not working on a secured connection (SSL). I mean, the page is secured, but the request is sent to a non secured page. Is there a solution?

    Read the article

  • PHP session_write_close() keeps sending a set-cookie header

    - by Chiraag Mundhe
    In my framework, I make a number of calls to session_write_close(). Let's assume that a session has been initiated with a user agent. The following code... foreach($i = 0; $i < 3; $i++) { session_start(); session_write_close(); } ...will send the following request header to the browser: Set-Cookie PHPSESSID=bv4d0n31vj2otb8mjtr59ln322; path=/ PHPSESSID=bv4d0n31vj2otb8mjtr59ln322; path=/ There should be no Set-Cookie header because, as I stipulated, the session cookie has already been created on the user's end. But every call to session_write_close() after the first one in the script above will result in PHP instructing the browser to set the current session again. This is not breaking my app or anything, but it is annoying. Does anyone have any insight into preventing PHP from re-setting the cookie with each subsequent call to session_write_close? EDIT The problem seems to be that with every subsequent call to session_start(), PHP re-sets the session cookie to its own SID and sends a Set-Cookie response header. But why??

    Read the article

  • What can I do to get Mozilla Firefox to preload the eventual image result?

    - by Dalal
    I am attempting to preload images using JavaScript. I have declared an array as follows with image links from different places: var imageArray = new Array(); imageArray[0] = new Image(); imageArray[1] = new Image(); imageArray[2] = new Image(); imageArray[3] = new Image(); imageArray[0].src = "http://www.bollywoodhott.com/wp-content/uploads/2008/12/arjun-rampal.jpg"; imageArray[1].src = "http://labelleetleblog.files.wordpress.com/2009/06/josie-maran.jpg"; imageArray[2].src = "http://1.bp.blogspot.com/_22EXDJCJp3s/SxbIcZHTHTI/AAAAAAAAIXc/fkaDiOKjd-I/s400/black-male-model.jpg"; imageArray[3].src = "http://www.iill.net/wp-content/uploads/images/hot-chick.jpg"; The image fade and transformation effects that I am doing using this array work properly for the first 3 images, but for the last one, imageArray[3], the actual image data of the image does not get preloaded and it completely ruins the effect, since the actual image data loads AFTERWARDS, only at the time it needs to be displayed, it seems. This happens because the last link http://www.iill.net/wp-content/uploads/images/hot-chick.jpg is not a direct link to the image. If you go to that link, your browser will redirect you to the ACTUAL location. Now, my image preloading code in Chrome works perfectly well, and the effects look great. Because it seems that Chrome preloads the actual data - the EVENTUAL image that is to be shown. This means that in Chrome if I preloaded an image that will redirect to 'stop stealing my bandwidth', then the image that gets preloaded is 'stop stealing my bandwidth'. How can I modify my code to get Firefox to behave the same way?

    Read the article

  • Android: preferences not being stored automatically

    - by Vitaly
    I'm trying to use preference screen. I'm following all steps from online tutorial (once I couldn't get it working, I found other tutorials, and steps seem to be fine). I get to preferences screen, edit values, return to calling activity (via hardware return button). In DDMS perspective FileExplorer shows package_name_preferences.xml file with preferences that should be stored. It contains: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <string name="false">kg</string> </map> while I expect (data line only shown). <string name="weight">kg</string> Also, if I go change only 1 preference, the same value changes, not a new row is created. I'm just tempted to write my own preference classes that would store data in files or DB, but I know that preferences should work, it just doesn't save properly my stuff. Edit Tutorials used: Main Tutorial - Was using this as a base, simplified, as I needed only 3 listPreferences so far. Another One - Used this one back when first installed android, so referred to this one for its section on preferences Code: (Screen loads, so I'm not showing Manifest) public class MyPrefs extends PreferenceActivity { @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); addPreferencesFromResource(R.xml.my_prefs); } } my_prefs.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="Value Settings"> <ListPreference android:title="Distance" android:summary="Metric (Kilometer) vs Imperial (Imperial)" android:defaultValue="km" android:key="@+id/distanceMesurement" android:entries="@array/distance" android:entryValues="@array/distance_values"/> <ListPreference android:title="Weight" android:summary="Metric (Kilogram) vs Imperial (Pound)" android:defaultValue="kg" android:key="@+id/weightMesurement" android:entries="@array/weight" android:entryValues="@array/weight_values"/> </PreferenceCategory> </PreferenceScreen> calling MyPrefs from MainScreen Intent i = new Intent(MainScreen.this, MyPrefs.class); startActivity(i); arrays.xml <resources> <string-array name="weight"> <item name="kg">Kilogram (kg)</item> <item name="lb">Pound (lb)</item> </string-array> <string-array name="weight_values"> <item name="kg">kg</item> <item name="lb">lb</item> </string-array> <string-array name="distance"> <item name="km">Kilometer (km)</item> <item name="mi">Mile (mi)</item> </string-array> <string-array name="distance_values"> <item name="km">km</item> <item name="mi">mi</item> </string-array> </resources>

    Read the article

  • what are the best practices to prevent sql injections

    - by s2xi
    Hi, I have done some research and still confused, This is my outcome of that research. Can someone please comment and advise to how I can make these better or if there is a rock solid implementation already out there I can use? Method 1: array_map('trim', $_GET); array_map('stripslashes', $_GET); array_map('mysql_real_escape_string', $_GET); Method 2: function filter($data) { $data = trim(htmlentities(strip_tags($data))); if (get_magic_quotes_gpc()) $data = stripslashes($data); $data = mysql_real_escape_string($data); return $data; } foreach($_GET as $key => $value) { $data[$key] = filter($value); }

    Read the article

  • django: control json serialization

    - by abolotnov
    Is there a way to control json serialization in django? Simple code below will return serialized object in json: co = Collection.objects.all() c = serializers.serialize('json',co) The json will look similar to this: [ { "pk": 1, "model": "picviewer.collection", "fields": { "urlName": "architecture", "name": "\u0413\u043e\u0440\u043e\u0434 \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430", "sortOrder": 0 } }, { "pk": 2, "model": "picviewer.collection", "fields": { "urlName": "nature", "name": "\u041f\u0440\u0438\u0440\u043e\u0434\u0430", "sortOrder": 1 } }, { "pk": 3, "model": "picviewer.collection", "fields": { "urlName": "objects", "name": "\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043d\u0430\u0442\u044e\u0440\u043c\u043e\u0440\u0442", "sortOrder": 2 } } ] You can see it's serializing it in a way that you are able to re-create the whole model, shall you want to do this at some point - fair enough, but not very handy for simple JS ajax in my case: I want bring the traffic to minimum and make the whole thing little clearer. What I did is I created a view that passes the object to a .json template and the template will do something like this to generate "nicer" json output: [ {% if collections %} {% for c in collections %} {"id": {{c.id}},"sortOrder": {{c.sortOrder}},"name": "{{c.name}}","urlName": "{{c.urlName}}"}{% if not forloop.last %},{% endif %} {% endfor %} {% endif %} ] This does work and the output is much (?) nicer: [ { "id": 1, "sortOrder": 0, "name": "????? ? ???????????", "urlName": "architecture" }, { "id": 2, "sortOrder": 1, "name": "???????", "urlName": "nature" }, { "id": 3, "sortOrder": 2, "name": "??????? ? ?????????", "urlName": "objects" } ] However, I'm bothered by the fast that my solution uses templates (an extra step in processing and possible performance impact) and it will take manual work to maintain shall I update the model, for example. I'm thinking json generating should be part of the model (correct me if I'm wrong) and done with either native python-json and django implementation but can't figure how to make it strip the bits that I don't want. One more thing - even when I restrict it to a set of fields to serialize, it will keep the id always outside the element container and instead present it as "pk" outside of it.

    Read the article

  • How exactly does fopen(), fclose() work?

    - by user625672
    Hi, I was just wondering about the functions fopen, fclose, socket and closesocket. When calling fopen or opening a socket, what exactly is happening (especially memory wise)? Can opening files/sockets without closing them cause memory leaks? And third, how are sockets created and what do they look like memory wise? I'm also interrested in the role of the operating system (Windows) in reading the sockets and sending the data.

    Read the article

  • Linq To SQL: Behaviour for table field which is NotNull and having Default value or binding

    - by kaushalparik27
    I found this something interesting while wandering over community which I would like to share. The post is whole about: DBML is not considering the table field's "Default value or Binding" setting which is a NotNull. I mean the field which can not be null but having default value set needs to be set IsDbGenerated = true in DBML file explicitly.Consider this situation: There is a simple tblEmployee table with below structure: The fields are simple. EmployeeID is a Primary Key with Identity Specification = True with Identity Seed = 1 to autogenerate numeric value for this field. EmployeeName and their EmailAddress to store in rest of 2 fields. And the last one is "DateAdded" with DateTime datatype which doesn't allow NULL but having Default Value/Binding with "GetDate()". That means if we don't pass any value to this field then SQL will insert current date in "DateAdded" field.So, I start with a new website, add a DBML file and dropped the said table to generate LINQ To SQL context class. Finally, I write a simple code snippet to insert data into the tblEmployee table; BUT, I am not passing any value to "DateAdded" field. Because I am considering SQL Server's "Default Value or Binding (GetDate())" setting to this field and understand that SQL will insert current date to this field.        using (TestDatabaseDataContext context = new TestDatabaseDataContext())        {            tblEmployee tblEmpObjet = new tblEmployee();            tblEmpObjet.EmployeeName = "KaushaL";            tblEmpObjet.EmployeeEmailAddress = "[email protected]";            context.tblEmployees.InsertOnSubmit(tblEmpObjet);            context.SubmitChanges();        }Here comes the twist when application give me below error:  This is something not expecting! From the error it clearly depicts that LINQ is passing NULL value to "DateAdded" Field while according to my understanding it should respect Sql Server's "Default value or Binding" setting for this field. A bit googling and I found very interesting related to this problem.When we set Primary Key to any field with "Identity Specification" Property set to true; DBML set one important property "IsDbGenerated=true" for this field. BUT, when we set "Default Value or Biding" property for some field; we need to explicitly tell the DBML/LINQ to let it know that this field is having default binding at DB side that needs to be respected if I don't pass any value. So, the solution is: You need to explicitly set "IsDbGenerated=true" for such field to tell the LINQ that the field is having default value or binding at Sql Server side so, please don't worry if i don't pass any value for it.You can select the field and set this property from property window in DBML Designer file or write the property in DBML.Designer.cs file directly. I have attached a working example with required table script with this post here. I hope this would be helpful for someone hunting for the same. Happy Discovery!

    Read the article

  • SQL Server Interview Questions

    - by Rodney Vinyard
    User-Defined Functions Scalar User-Defined Function A Scalar user-defined function returns one of the scalar data types. Text, ntext, image and timestamp data types are not supported. These are the type of user-defined functions that most developers are used to in other programming languages. Table-Value User-Defined Function An Inline Table-Value user-defined function returns a table data type and is an exceptional alternative to a view as the user-defined function can pass parameters into a T-SQL select command and in essence provide us with a parameterized, non-updateable view of the underlying tables. Multi-statement Table-Value User-Defined Function A Multi-Statement Table-Value user-defined function returns a table and is also an exceptional alternative to a view as the function can support multiple T-SQL statements to build the final result where the view is limited to a single SELECT statement. Also, the ability to pass parameters into a T-SQL select command or a group of them gives us the capability to in essence create a parameterized, non-updateable view of the data in the underlying tables. Within the create function command you must define the table structure that is being returned. After creating this type of user-defined function, I can use it in the FROM clause of a T-SQL command unlike the behavior found when using a stored procedure which can also return record sets.

    Read the article

  • Craig Mundie's video

    - by GGBlogger
    Timothy recently posted “Microsoft Shows Off Radical New UI, Could Be Used In Windows 8” on Slashdot. I took such grave exception to his post that I found it necessary to my senses to write this blog. We need to go back many years to the days of hand cranked calculators and early main frame computers. These devices had singular purposes – they were “number crunchers” used to make accounting easier. The front facing display in early mainframes was “blinken lights.” The calculators did provide printing – in the form of paper tape and the mainframes used line printers to generate reports as needed. We had other metaphors to work with. The typewriter was/is a mechanical device that substitutes for a type setting machine. The originals go back to 1867 and the keyboard layout has remained much the same to this day. In the earlier years the Morse code telegraphs gave way to Teletype machines. The old ASR33, seen on the left in this photo of one of the first computers I help manufacture, used a keyboard very similar to the keyboards in use today. It also generated punched paper tape that we generated to program this computer in machine language. Everything considered this computer which dates back to the late 1960s has a keyboard for input and a roll of paper as output. So in a very rudimentary fashion little has changed. Oh – we didn’t have a mouse! The entire point of this exercise is to point out that we still use very similar methods to get data into and out of a computer regardless of the operating system involved. The Altair, IMSAI, Apple, Commodore and onward to our modern machines changed the hardware that we interfaced to but changed little in the way we input, view and output the results of our computing effort. The mouse made some changes and the advent of windowed interfaces such as Windows and Apple made things somewhat easier for the user. My 4 year old granddaughter plays here Dora games on our computer. She knows how to start programs, use the mouse, play the game and is quite adept so we have come some distance in making computers useable. One of my chief bitches is the constant harangues leveled at Microsoft. Yup – they are a money making organization. You like Apple? No problem for me. I don’t use Apple mostly because I’m comfortable in the Windows environment but probably more because I don’t like Apple’s “Holier than thou” attitude. Some think they do superior things and that’s also fine with me. Obviously the iPhone has not done badly and other Apple products have fared well. But they are expensive. I just build a new machine with 4 Terabytes of storage, an Intel i7 Core 950 processor and 12 GB of RAMIII. It cost me – with dual monitors – less than 2000 dollars. Now to the chief reason for this blog. I’m going to continue developing software for as long as I’m able. For that reason I don’t see my keyboard, mouse and displays changing much for many years. I also don’t think Microsoft is going to spoil that for me by making radical changes to my developer experience. What Craig Mundie does in his video here:  http://www.ispyce.com/2011/02/microsoft-shows-off-radical-new-ui.html is explore the potential future of computer interfaces for the masses of potential users. Using a computer today requires a person to have rudimentary capabilities with keyboards and the mouse. Wouldn’t it be great if all they needed was hand gestures? Although not mentioned it would also be nice if computers responded intelligently to a user’s voice. There is absolutely no argument with the fact that user interaction with these machines is going to change over time. My personal prediction is that it will take years for much of what Craig discusses to come to a cost effective reality but it is certainly coming. I just don’t believe that what Craig discusses will be the future look of a Window 8.

    Read the article

  • Silverlight Cream for February 26, 2011 -- #1052

    - by Dave Campbell
    In this Issue: Mark Monster, Gill Cleeren, Pencho Popadiyn, Kevin Dockx, Joost van Schaik, Jesse Liberty, John Papa, Jeremy Likness, Arik Poznanski(-2-), Page Brooks, Deborah Kurata, Mike Snow, Alfred Astort, Samuel Jack, XAMLNinja, and Shawn Wildermuth. Above the Fold: Silverlight: "Asynchronous Callbacks with Rx" Jesse Liberty WP7: "Phoney Windows Phone 7 Project Now Available!" Shawn Wildermuth MVVM: "Validating our ViewModel" Mark Monster Shoutouts: Shawn Wildermuth has a video up of his FadingMessage class to show it off: Introducing Phoney's FadingMessage Class From SilverlightCream.com: Validating our ViewModel Mark Monster discusses Validation in his latest post... using INotifyDataErrorInfo and his own implementation of a ViewModel base that supports it and INPC. Getting ready for Microsoft Silverlight Exam 70-506 (Part 7) Gill Cleeren hits part 7 of his series at SilverlightShow on a great walk through Silverlight and getting ready for the exam. This is the final part and concentrates on deploying apps. Windows Phone 7–Creating Custom Keyboard Pencho Popadiyn has a post at SilverlightShow discussing problems with WP7 keyboards in his native Bulgaria, and his solution to the problem... create his own. 360 Degrees Feedback by Kevin Dockx Kevin Dockx produced a white paper for his company about an employee review solution they did in Silverlight. The white paper is available, and SilverlightShow interviewd Kevin to answer questions about the app. Extended Windows Phone 7 page for handling rotation, focused element updates and back key press Looks like Joost van Schaik has a few posts I've missed... and I'm not going to get to them all today! ... this one is about the base class he uses for WP7 apps... a bunch of utilities he uses... definitely worth a look (and a take). Asynchronous Callbacks with Rx Jesse Liberty has his 8th post in the Rx series up and this one's on Asynchronous Callbacks... if you haven't seen this before, you should definitely look into it... cool stuff, Jesse! Silverlight TV 63: Exploring National Instruments' App Using Data and Business Features John Papa has Silverlight TV number 63 up and is talking to Steve Lasker about National Instruments and their Lab View product. Great demo and discussion. Jounce Part 11: Debugging MEF Jeremy Likness's latest (number 11) in his series on his MVVM framework Jounce is out, and he's discussing how to debug MEF, which Jounce handles nicely through the logging he provides... and you can use it externally to Jounce. Get Twitter Trends on Windows Phone 7 Arik Poznanski has a couple Twitter for WP7 posts up... first is one for pulling Twitter trends from whatthetrend.com... plus the code to do it. Searching Twitter on Windows Phone 7 In his next post, Arik Poznanski shows how to search twitter from your WP7 ... again with code. Tiled Background Control in Silverlight Page Brooks shows how to get a tiled background control in Silverlight ... did you know there was one in the JetPack them? Silverlight Charting: Displaying Data Above the Column Deborah Kurata continues her charting posts with this one displaying the column value above the column. I like this... it has a clean look and all the data is available at a glance. Silverlight: Tasks on the Win7 Mobile Phone Mike Snow has a list of the WP7 tasks available and an example of using them... looks like a pretty good reference! 10 of 10 - Aesthetics and alignment matter Alfred Astort discusses aesthetics and WP7 dev... looks like it's the same as any app development, but if you're not doing it, you should be. Simon Squared – We have Multi-player: Days 4, 5 and (ahem!) 6 Samuel Jack details the completion of his multi-player game for WP7 utilizing Azure, in the hour-by-hour detail he's done the rest... plus a video of the final product! Who ate all the pies!! XAMLNinja has a very good discussion/link set of Charting posts all leading up to a portrait-only version of charting for WP7 with labels that looks looks great Phoney Windows Phone 7 Project Now Available! Shawn Wildermuth has a collection of classes he always uses with WP7 dev, and he's sharing them with all of us a "Phoney" Tools project on Codeplex... and now has a NuGet project also. Stay in the 'Light! Twitter SilverlightNews | Twitter WynApse | WynApse.com | Tagged Posts | SilverlightCream Join me @ SilverlightCream | Phoenix Silverlight User Group Technorati Tags: Silverlight    Silverlight 3    Silverlight 4    Windows Phone MIX10

    Read the article

  • Slides, Scripts, and Photos from SharePoint Saturday New Orleans 2011

    - by Brian Jackett
    This weekend I presented “Managing SharePoint 2010 Farms with PowerShell” at SharePoint Saturday New Orleans.  This was my first time visiting New Orleans so I was excited for the experience.  A big thanks to everyone who attended my session.  I condensed the material a little but the slides and scripts below have additional material that we couldn’t cover.  Let me know if you have any comments, questions, or feedback.  Thanks. Slides and Scripts     Managing SharePoint 2010 Farms with PowerShell   Photos     <coming soon since the conference is still ongoing>         -Frog Out

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10  | Next Page >