Search Results

Search found 602 results on 25 pages for 'victor lin'.

Page 15/25 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • How can this closure test be written in other languages?

    - by Jian Lin
    I wonder how the following closure test can be written in other languages, such as C and Java. Can the same result be expected also in Perl, Python, and PHP? Ideally, we don't need to make a new local variable such as x and assign it the value of i inside the loop, but just so that i has a new copy in the new scope each time. (if possible). (some discussion is in this question.) The following is in Ruby, the "1.8.6" on the first line of result is the Ruby version which can be ignored. p RUBY_VERSION $foo = [] (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out is: [MacBook01:~] $ ruby scope.rb "1.8.6" 1 2 3 4 5 [MacBook01:~] $ Contrast that with another test, with i defined outside: p RUBY_VERSION $foo = [] i = 0 (1..5).each do |i| $foo[i] = lambda { p i } end (1..5).each do |j| $foo[j].call() end the print out: [MacBook01:~] $ ruby scope2.rb "1.8.6" 5 5 5 5 5 [MacBook01:~] $

    Read the article

  • Rails Mikel Mail Gem How to use Views

    - by Victor Martins
    I'm trying to use mikel gem mail on my 2.3.5 Rails App http://github.com/mikel/mail I have it working like this. I've made a MailComHelper, made a method like this : def self.welcome(user,password) @user = user m = Mail.new m.from = '[email protected]' m.to = @user.email m.subject = 'welcome' m.body = 'The body' m.delivery_method :sendmail m.deliver! end And it works, I receive the mail. But I wish I could use the old way of calling a view ( html.erb ) file and send that code has the body. I've read the documentation but haven't found a way to do it. Has anyone found a way to do it?

    Read the article

  • Did anyone have this issue with a simple Facebook app or know how to solve it?

    - by Jian Lin
    I have a really simple few lines of Facebook app, using the new Facebook API: <pre> <?php require 'facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' => '117676584930569', 'secret' => '**********', // hidden here on the post... 'cookie' => true, )); var_dump($facebook); ?> but it is giving me the following output: http://apps.facebook.com/woolaladev/i2.php would give out object(Facebook)#1 (6) { ["appId:protected"]=> string(15) "117676584930569" ["apiSecret:protected"]=> string(32) "**********" <--- just hidden on this post ["session:protected"]=> NULL ["sessionLoaded:protected"]=> bool(false) ["cookieSupport:protected"]=> bool(true) ["baseDomain:protected"]=> string(0) "" } Session is NULL for some reason, but I am logged in and can access my home and profile and run other apps on Facebook (to see that I am logged on). I am following the sample on: http://github.com/facebook/php-sdk/blob/master/examples/example.php http://github.com/facebook/php-sdk/blob/master/src/facebook.php (download using raw URL: wget http://github.com/facebook/php-sdk/raw/master/src/facebook.php ) Trying on both hosting companies at dreamhost.com and netfirms.com, and the results are the same.

    Read the article

  • How to create a closure and pass in variable length argument list?

    - by Jian Lin
    We can create a closure p by capturing the arguments in the scope in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that p = console.log; works well in Firefox and IE 8 but not on Chrome.

    Read the article

  • How to get compatibility between C# and SQL2k8 AES Encryption?

    - by Victor Rodrigues
    I have an AES encryption being made on two columns: one of these columns is stored at a SQL Server 2000 database; the other is stored at a SQL Server 2008 database. As the first column's database (2000) doesn't have native functionality for encryption / decryption, we've decided to do the cryptography logic at application level, with .NET classes, for both. But as the second column's database (2008) allow this kind of functionality, we'd like to make the data migration using the database functions to be faster, since the data migration in SQL 2k is much smaller than this second and it will last more than 50 hours because of being made at application level. My problem started at this point: using the same key, I didn't achieve the same result when encrypting a value, neither the same result size. Below we have the full logic in both sides.. Of course I'm not showing the key, but everything else is the same: private byte[] RijndaelEncrypt(byte[] clearData, byte[] Key) { var memoryStream = new MemoryStream(); Rijndael algorithm = Rijndael.Create(); algorithm.Key = Key; algorithm.IV = InitializationVector; var criptoStream = new CryptoStream(memoryStream, algorithm.CreateEncryptor(), CryptoStreamMode.Write); criptoStream.Write(clearData, 0, clearData.Length); criptoStream.Close(); byte[] encryptedData = memoryStream.ToArray(); return encryptedData; } private byte[] RijndaelDecrypt(byte[] cipherData, byte[] Key) { var memoryStream = new MemoryStream(); Rijndael algorithm = Rijndael.Create(); algorithm.Key = Key; algorithm.IV = InitializationVector; var criptoStream = new CryptoStream(memoryStream, algorithm.CreateDecryptor(), CryptoStreamMode.Write); criptoStream.Write(cipherData, 0, cipherData.Length); criptoStream.Close(); byte[] decryptedData = memoryStream.ToArray(); return decryptedData; } This is the SQL Code sample: open symmetric key columnKey decryption by password = N'{pwd!!i_ll_not_show_it_here}' declare @enc varchar(max) set @enc = dbo.VarBinarytoBase64(EncryptByKey(Key_GUID('columnKey'), 'blablabla')) select LEN(@enc), @enc This varbinaryToBase64 is a tested sql function we use to convert varbinary to the same format we use to store strings in the .net application. The result in C# is: eg0wgTeR3noWYgvdmpzTKijkdtTsdvnvKzh+uhyN3Lo= The same result in SQL2k8 is: AI0zI7D77EmqgTQrdgMBHAEAAACyACXb+P3HvctA0yBduAuwPS4Ah3AB4Dbdj2KBGC1Dk4b8GEbtXs5fINzvusp8FRBknF15Br2xI1CqP0Qb/M4w I just didn't get yet what I'm doing wrong. Do you have any ideas? EDIT: One point I think is crucial: I have one Initialization Vector at my C# code, 16 bytes. This IV is not set at SQL symmetric key, could I do this? But even not filling the IV in C#, I get very different results, both in content and length.

    Read the article

  • how to handle it if the management just keep on giving me spec after spec non-stop?

    - by Jian Lin
    As a programmer, I feel burnt out if the management give me spec after spec, day after day. I think I can code 6 hours a day very focused, but non-stop coding does burn me out a little, especially it is 1 year or 18 months non-stop. A mere 1 week or 2 week vacation per year isn't going to help much. Sometimes I want to take some time to learn new things, or just to take a break for a month so as to re-charge, like back in college when we have holidays for 1 month during winter or 2.5 months during summer. What do you think?

    Read the article

  • How can I modify my classes to use it's collections in WPF TreeView

    - by Victor
    Hello, i'am trying to modify my objects to make hierarchical collection model. I need help. My objects are Good and GoodCategory: public class Good { int _ID; int _GoodCategory; string _GoodtName; public int ID { get { return _ID; } } public int GoodCategory { get { return _GoodCategory; } set { _GoodCategory = value; } } public string GoodName { get { return _GoodName; } set { _GoodName = value; } } public Good(IDataRecord record) { _ID = (int)record["ID"]; _GoodtCategory = (int)record["GoodCategory"]; } } public class GoodCategory { int _ID; string _CategoryName; public int ID { get { return _ID; } } public string CategoryName { get { return _CategoryName; } set { _CategoryName = value; } } public GoodCategory(IDataRecord record) { _ID = (int)record["ID"]; _CategoryName = (string)record["CategoryName"]; } } And I have two Collections of these objects: public class GoodsList : ObservableCollection<Good> { public GoodsList() { string goodQuery = @"SELECT `ID`, `ProductCategory`, `ProductName`, `ProductFullName` FROM `products`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new Good(rdr)); } } } } } public class GoodCategoryList : ObservableCollection<GoodCategory> { public GoodCategoryList () { string goodQuery = @"SELECT `ID`, `CategoryName` FROM `product_categoryes`;"; using (MySqlConnection conn = ConnectToDatabase.OpenDatabase()) { if (conn != null) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = productQuery; MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Add(new GoodCategory(rdr)); } } } } } So I have two collections which takes data from the database. But I want to use thats collections in the WPF TreeView with HierarchicalDataTemplate. I saw many post's with examples of Hierarlichal Objects, but I steel don't know how to make my objects hierarchicaly. Please help.

    Read the article

  • Multiple CSS Classes: Properties Overlapping based on the order defined.

    - by Jian Lin
    Is there a rule in CSS that determines the cascading order when multiple classes are defined on an element? (class="one two" vs class="two one") Right now, there seems to be no such effect. Example: both divs are orange in color on Firefox <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> .one { border: 6px dashed green } .two { border: 6px dashed orange } </style> </head> <body> <div class="one two"> hello world </div> <div class="two one"> hello world </div>

    Read the article

  • How to use a data type (table) defined in another database in SQL2k8?

    - by Victor Rodrigues
    I have a Table Type defined in a database. It is used as a table-valued parameter in a stored procedure. I would like to call this procedure from another database, and in order to pass the parameter, I need to reference this defined type. But when I do DECLARE @table dbOtherDatabase.dbo.TypeName , it tells me that The type name 'dbOtherDatabase.dbo.TypeName' contains more than the maximum number of prefixes. The maximum is 1. How could I reference this table type?

    Read the article

  • In CSS, how to not float a 300px wide Div to the next line?

    - by Jian Lin
    Say, there is a bar that is styled at the bottom of the viewport, using position: fixed; bottom: 0; left: 0; width: 100%; height 50px; overflow: hidden and then there are 4 Divs inside it, each one floated to the left. Each Div is about 300px wide or can be more (depending on the content) Now, when the window is 1200 pixel wide, and we see all 4 Divs, but when the window is resize to be 1180 pixel wide (just 20 pixels less), then the whole 300px wide Div will disappear, because it is "floated" to the next line. So how can this be made so that, the Div will stay there and showing 280px of itself, rather than totally disappear? By the way, white-space: nowrap won't work as that probably has to do with not wrapping inline content. I was thinking of putting another Div inside this Div, having a fixed width of 1200px or 2000px, so that all Divs will float on the same level in this inner Div, and the outer Div will cut it off with the overflow: hidden. But this seems more like a hack... since the wide of all those Divs can be dynamic, and setting a fixed width of 1200px or 2000px seems like too much of a hack.

    Read the article

  • Strange behaviour with mediaplayer and seekTo

    - by Mathias Lin
    I'm implementing a custom video player because I need custom video controls. I have an app with only one activity, which on startup shall start playing a video right away. Now, the problem I have is: I don't want the video to start from the beginning, but from a later position. Therefore I do a seekTo(16867). Since seekTo is asynchronous, I place the start call of the mediaplayer (player.start()) in the onSeekComplete of the onSeekCompleteListener. The strange behaviour I experience though is that I can see/hear the video playing from the beginning for a few millisecs before it actually plays from/jumps to the position I seeked to. But - on the other hand - the Log output I call before the player.start returns the correct position 16867, where I seeked to. Below is the relevant code section, the complete class is at http://pastebin.com/jqAAFsuX (I'm on Nexus One / 2.2 StageFright) private void playVideo(String url) { try { btnVideoPause.setEnabled(false); if (player==null) { player=new MediaPlayer(); player.setScreenOnWhilePlaying(true); } else { player.stop(); player.reset(); } url = "/sdcard/myapp/main/videos/main.mp4"; // <--- just for test purposes hardcoded here now player.setDataSource(url); player.setDisplay(holder); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setOnCompletionListener(this); player.setOnPreparedListener(this); player.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() { public void onSeekComplete(MediaPlayer mediaPlayer) { Log.d("APP", "current pos... "+ player.getCurrentPosition() ); player.start(); // <------------------ start video on seek completed player.setOnSeekCompleteListener(null); } }); player.prepareAsync(); } catch (Throwable t) { Log.e(TAG, "Exception in btnVideoPause prep", t); } } public void onPrepared(MediaPlayer mediaplayer) { width=player.getVideoWidth(); height=player.getVideoHeight(); if (width!=0 && height!=0) { holder.setFixedSize(width, height); progressBar.setProgress(0); progressBar.setMax(player.getDuration()); player.seekTo(16867); // <------------------ seeking to position } btnVideoPause.setEnabled(true); }

    Read the article

  • file input - prevent selection of certain types of files and size

    - by Victor
    Is there a way to prevent the user from selecting a file that is not a specified file type when they browser for the file on their computer? For example, when a user browseses to upload an image file I would for them to only see images (jpg, png, ect.) that are less than 20mb. Is this something that can be accomplished with asp.net mvc and jquery or do I need to use flash or a java applet?

    Read the article

  • Standard and reliable mouse-reporting with GLUT

    - by Victor
    Hello! I'm trying to use GLUT (freeglut) in my OpenGL application, and I need to register some callbacks for mouse wheel events. I managed to dig out a fairly undocumented function: api documentation But the man page and the API entry for this function both state the same thing: Note: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability of your application. (This feature does work on X, just not reliably.) You are encouraged to use the standard, reliable mouse-button reporting, rather than wheel events. Fair enough, but how do I use this standard, reliable mouse-reporting? And how do I know which is the standard? Do I just use glutMouseFunc() and use button values like 4 and 5 for the scroll up and down values respectively, say if 1, 2 and 3 are the left, middle and right buttons? Is this the reliable method? Bonus question: it seems the `xev' tool is reporting different values for my buttons. My mouse buttons are numbered from 1 to 5 with xev, but glut is reporting buttons from 0 to 4, i.e. an off-by-one. Is this common?

    Read the article

  • In SQL, can we always write an inner join statement as a main query and subquery if we only want to

    - by Jian Lin
    In SQL, can we always write an inner join statement as a main query and subquery or vice versa if we only want to find the intersection? For example, select * from gifts g where g.giftID in (select giftID from sentGifts); can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery. But if all we care is to find the intersection, without caring what is being displayed, then we can always convert one to the other?

    Read the article

  • How to program and calculate multiple subtotal and grandtotal using jquery?

    - by Victor
    I'm stump figuring out how to do this in jquery, I need to do it without any plug-in. Imagine a shopping cart for books, each change of quantity (using select dropdown) will update the total price, grandtotal and then the hidden input value. <table> <tr> <td class="qty"> <select class="item-1"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> ... </select> </td> <td class="product"> Book 1 </td> <td class="price-item-1"> $20 </td> <td class="total-item-1"> $20 </td> </tr> <tr> <td class="qty"> <select class="item-2"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> ... </select> </td> <td class="product"> Book 2 </td> <td class="price-item-2"> $10 </td> <td class="total-item-2"> $10 </td> </tr> ... ... <tr> <td colspan="3" align="right"> <strong>Grand Total:</strong> </td> <td class="grandtotal"> </td> </tr> </table> <input type="hidden" id="qty-item-1" value="0" /> <input type="hidden" id="total-item-1" value="0" /> <input type="hidden" id="qty-item-2" value="0" /> <input type="hidden" id="total-item-2" value="0" />

    Read the article

  • C++ explicit template specialization of templated constructor of templated class

    - by Victor Liu
    I have a class like template <class T> struct A{ template <class U> A(U u); }; I would like to write an explicit specialization of this for a declaration like A<int>::A(float); In the following test code, if I comment out the specialization, it compiles with g++. Otherwise, it says I have the wrong number of template parameters: #include <iostream> template <class T> struct A{ template <class U> A(T t, U *u){ *u += U(t); } }; template <> template <> A<int>::A<int,float>(int t, float *u){ *u += U(2*t); } int main(){ float f = 0; int i = 1; A<int>(i, &f); std::cout << f << std::endl; return 0; }

    Read the article

  • Jetty offline documentation

    - by Victor Sorokin
    Is there any more-or-less comprehensive documentation for Jetty (e.g., similar to Tomcat or, really, in any form)? Theirs online wikis seems to be quite informative, but servers seem to be slow. Maybe, there some way to build docs from Jetty source distribution? I tried mvn site to no avail.

    Read the article

  • What is a SQL statement that can tally up the counts even including the Zeros? (all in 1 statement)

    - by Jian Lin
    A SQL statement can give a list of the most popular gifts that are sent in a Social application, all the way to the ones that are sent 1, or 2 times, but it won't include the Zeros. I think the same goes for getting the list of the most popular Classes that students are registering for, when the registration process for all students is 10 days and now it is the 3rd day. Again, we get the count but the Zeros are not there. Is there a simple SQL statement that can show the whole list, including the zeros?

    Read the article

  • Using Mercurial (hg), how to push just one file or one directory out?

    - by Jian Lin
    Using Mercurial, we can commit one file by using hg commit file.rb or 1 folder hg commit foldername But how can we push just 1 file or 1 folder out? The whole project can be pushed using hg push ssh://[email protected]//project/code/preliminary but there seems to be no way to push out just 1 file or 1 folder? I tried the following and they don't work: hg push ssh://[email protected]//project/code/preliminary app/views/index.html.erb or hg push ssh://[email protected]//project/code/preliminary/app/views/index.html.erb

    Read the article

  • Using jQuery's animate(), if the clicked on element is "<a href="#" ...> </a>", the fucntion should

    - by Jian Lin
    I was reading jQuery's page for animate() http://api.jquery.com/animate/ Its examples don't mention about if using <a href="#" id="clickme">click me</a> ... $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); }) we actually still have to return false like in the old days? $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); return false; }) (but then, those examples didn't use a <a> for the "click me"... but used something else. Otherwise the page will jump back to the beginning of the page? Does jQuery have a more elegant or magical way of doing it?

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >