pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
17,056,545
0
<p>This process is handled by the Android <code>MediaScanner</code>. This is what scans the phone for new media and stores it in the Android media database. I believe the time frame which it runs is device specific. However, you can call it manually:</p> <pre><code> Uri uri = Uri.fromFile(destFileOrFolder); Intent scanFileIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri); sendBroadcast(scanFileIntent); </code></pre>
36,534,762
0
<p>I know the option the <code>(b)</code> you can entirely disable Silex app error handler and after that, your custom error handler should work fine as you defined it.</p> <p>Entirely disabled Silex error handler:</p> <pre><code>$app['exception_handler']-&gt;disable(); </code></pre> <p>So, It will be like:</p> <pre><code>require_once 'Exception.php'; # Load the class $handler = new ErrorHandler(); # Initialize/Register it $app = new \Silex\Application(); $app-&gt;get('/', function () use ($app) { nonexistentfunction(); trigger_error("example"); throw new \Exception("example"); }); $app-&gt;run(); </code></pre>
14,684,312
1
Issue with creating "xlsx" in Python by copying data from csv <p>I am trying to copy all the data in csv to excel "xlsx" file using python. I am using following code to do this:</p> <pre><code>from openpyxl import load_workbook import csv #Open an xlsx for reading wb = load_workbook(filename = "empty_book.xlsx") #Get the current Active Sheet ws = wb.get_active_sheet() #You can also select a particular sheet #based on sheet name #ws = wb.get_sheet_by_name("Sheet1") #Open the csv file with open("Pricing_Updated.csv",'rb') as fin: #read the csv reader = csv.reader(fin) #get the row index for the xlsx #enumerate the rows, so that you can for index,row in enumerate(reader): i=0 for row[i] in row: ws.cell(row=index,column=i).value = row[i] i = i+1 #save the excel file wb.save("empty_book.xlsx") </code></pre> <p>I found this code on <strong>SO</strong> itself and modified it to make it usable for my case. But this code is throwing <code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 0: ordinal not in range(128)</code> error for <code>ws.cell(row=index,column=i).value = row[i]</code> line.</p> <p>Please help me in resolving this issue.</p> <p><strong>Update</strong>: I tried using following code also to resolve the issue but came across <code>UnicodeDecode</code> error again for <code>ws.cell(row=rowx,column=colx).value = row[colx]</code> line:</p> <pre><code>for rowx,row in enumerate(reader): for colx, value in enumerate(row): ws.cell(row=rowx,column=colx).value = row[colx] </code></pre> <p><strong>Update 2</strong>: I tried using <code>xlwt</code> module also to copy the csv into xls (as it doesn't support xlxs) and again came across <code>UnicodeDecode</code> error, code which I used was:</p> <pre><code>import glob, csv, xlwt, os wb = xlwt.Workbook() for filename in glob.glob("Pricing_Updated.csv"): (f_path, f_name) = os.path.split(filename) (f_short_name, f_extension) = os.path.splitext(f_name) ws = wb.add_sheet(f_short_name) spamReader = csv.reader(open(filename, 'rb')) for rowx, row in enumerate(spamReader): for colx, value in enumerate(row): ws.write(rowx, colx, value) wb.save("exceltest7.xls") </code></pre>
19,829,235
0
zbar sdk view third party library error in Xcode 5 <p>I am using z bar SDK in x code 5 when i am archiving its getting following errors </p> <pre><code>Undefined symbols for architecture armv7: "_CMSampleBufferGetImageBuffer", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferIsValid", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferDataIsReady", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferGetNumSamples", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) </code></pre>
16,146,153
0
XML - Schema Element with attribute and sequence of sub-elements <p>I have a XML schema as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt; &lt;xs:element name="labels"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="label" minOccurs="1" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="language" minOccurs="1" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:simpleContent&gt; &lt;xs:extension base="xs:string"&gt; &lt;xs:attribute name="value" type="xs:string" /&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p><code>&lt;labels&gt;</code> can have many <code>&lt;label&gt;</code> elements, and a <code>&lt;label&gt;</code> element can have many <code>&lt;language&gt;</code> elements. Now what i need is for my <code>&lt;label&gt;</code> element to have a unique attribute called 'identifier'.</p> <p>I want to have a XML structure like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;labels xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='labels.xsd'&gt; &lt;label identifier="class_contact"&gt; &lt;language value="english"&gt;Contacts&lt;/language&gt; &lt;language value="afrikaans"&gt;Kontakte&lt;/language&gt; &lt;/label&gt; &lt;/labels&gt; </code></pre> <p>OK i changed it to this, now it allows for the identifier attribute but it does not enforce it to be unique.</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt; &lt;xs:element name="labels"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="label" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="language" minOccurs="1" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:simpleContent&gt; &lt;xs:extension base="xs:string"&gt; &lt;xs:attribute name="value" type="xs:string" /&gt; &lt;/xs:extension&gt; &lt;/xs:simpleContent&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="identifier" type="xs:string" /&gt; &lt;/xs:complexType&gt; &lt;xs:unique name="UniqueLabelLanguage"&gt; &lt;xs:selector xpath="language" /&gt; &lt;xs:field xpath="@value" /&gt; &lt;/xs:unique&gt; &lt;xs:unique name="UniqueLabelIdentifier"&gt; &lt;xs:selector xpath="label" /&gt; &lt;xs:field xpath="@identifier" /&gt; &lt;/xs:unique&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre>
32,910,156
0
<p>Yes, you could do this: </p> <pre><code>&lt;select class="form-control" id="field_cusPro" name="cusPro" ng-model="rentalAgreement.customerProfile" ng-options="cusPro as cusPro.Name+' ('+cusPro.id+')' for cusPro in cuspros track by cusPro.id"&gt; &lt;option value=""&gt;&lt;/option&gt; </code></pre>
15,011,401
0
<p>Try this:</p> <p><a href="http://jsfiddle.net/edz8B/1/" rel="nofollow">DEMO</a></p> <p>JS</p> <pre><code>function setChk(value){ var chk = document.getElementById('check1'); chk.checked = (value != 'null'); } </code></pre> <p>HTML</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="checkbox" name="check1" id="check1"/&gt;Process 1:&lt;/td&gt; &lt;td&gt; &lt;select id="process1" name="process1" onchange="setChk(this.value);"&gt; &lt;option value="null"&gt;--Select Process--&lt;/option&gt; &lt;option value="NameA"&gt;NameA&lt;/option&gt; &lt;option value="NameB"&gt;NameB&lt;/option&gt; &lt;option value="NameC"&gt;NameC&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
20,892,832
0
<p>You can pass in a function to compute the Jacobian as the <code>Dfun</code> argument to the <code>Minimizer.leastsq</code> method: <a href="http://lmfit.github.io/lmfit-py/fitting.html#leastsq" rel="nofollow">http://lmfit.github.io/lmfit-py/fitting.html#leastsq</a></p> <p>By default the function passed in for <code>Dfun</code> should return an array with the same number of rows as parameters, and each row the derivative with respect to each parameter being fitted. Make sure to specify the parameters with a <a href="http://cars9.uchicago.edu/software/python/lmfit/parameters.html#the-parameters-class" rel="nofollow">Parameters</a> object so that the parameters are treated in the correct order. I believe this this necessary IIRC though it might not matter.</p>
19,063,800
0
how to get different hidden field values in multiple form in a page <p>in a page i have 2 forms where both having a hidden field named operation(same name for both form)</p> <pre><code>included jquery.min-1.5.js &amp; jquery-ui.min-1.8.js &lt;script&gt; $(document).ready(function(){ $('#get_val').live('click', function() { alert($('#operation').val()); }); }); &lt;/script&gt; &lt;form id="form_como" name="form_como" action="go.php" method="post"&gt; //some code..... &lt;input type="hidden" name="operation" id="operation" value="first"&gt; &lt;input type="button" name="get_val" id="get_val" value="Get Val"/&gt; &lt;/form&gt; &lt;br /&gt; &lt;form id="form_como2" name="form_como2" action="" method="post"&gt; //some code..... &lt;input type="hidden" name="operation" id="operation" value="second"&gt; &lt;input type="button" name="get_val" id="get_val" value="Get Val"/&gt; &lt;/form&gt; </code></pre> <p>When i click "Get Val" button i always get 'first" (for both cases). but i need the value of the button which one i have clicked.</p>
12,736,412
0
<p>Add c:/PROGRA~1/Java/JDK16~1.0_3\bin\ to Path environment variable</p>
3,908,059
0
How to set a NSView hidden with FadeOut animation in cocoa? <p>I'm hiding a subview from a CustomView element with the following code:</p> <pre> <code> [[[theViewcont subviews] objectAtIndex:0] setHidden:TRUE] </code> </pre> <p>how can i add a fade animation on hiding this NSVIEW?</p>
6,270,084
0
What's the best way to support array column types with external tables in hive? <p>So i have external tables of tab delimited data. A simple table looks like this:</p> <pre><code>create external table if not exists categories (id string, tag string, legid string, image string, parent string, created_date string, time_stamp int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LOCATION 's3n://somewhere/'; </code></pre> <p>Now I'm adding another field to the end, it will be a comma separated list of values. </p> <p>Is there a way to specify this in the same way that I specify a field terminator, or do I have to rely on one of the serdes?</p> <p>eg:</p> <pre><code>...list_of_names ARRAY&lt;String&gt;) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ARRAY ELEMENTS SEPARATED BY ',' ... </code></pre> <p>(I'm assuming I'll need to use a serde for this, but I figured there wasn't any harm in asking)</p>
34,573,787
0
<p>Your second file - <code>captureit.java</code> - cannot be an Activity. An Activity can only be created by calling <code>startActivity()</code> or <code>startActivityForResult()</code> from another activity with an intent. When you call <code>new CaptureIt()</code> the <code>onCreate()</code> method and other activity-specific methods are not called. This means that the activity doesn't have the correct information to do some things - like starting another activity.</p> <p>Basically you're trying to start the camera activity from an activity that doesn't exist to Android, so it's throwing a NullPointerException.</p> <p>I'd recommend moving it back into the same file until you understand how moving between activities works in Android.</p> <p>You could still split the helper methods (<code>getOutputMediaFile()</code>, etc) into another file to keep the main activity file simple. But <em>don't</em> make it an activity and <em>don't</em> call <code>startActivityForResult</code> from it.</p>
8,207,980
0
<p>You can use this code for your same work:</p> <pre><code>UIWebView *web = [[UIWebView alloc] initWithFrame:YOUR_FRAME]; NSString *path = [[NSBundle mainBundle] pathForResource:@"terms and conditions" ofType:@"html"]; NSURL *url = [NSURL fileURLWithPath:path isDirectory:NO]; [web loadRequest:[NSURLRequest requestWithURL:url]]; [YOUR_VIEW addSubview:web]; [web release]; </code></pre> <p>Only you need to bake your <code>HTML</code> file.</p> <p>I hope it be useful for you!</p>
22,197,264
0
<p>I think this is what you are after:</p> <pre><code>Select student_course_modules.module_id from student_course_modules left join student_courses on student_courses.id = student_course_modules.student_course_id where student_courses.course_id="1" And student_courses.student_id="ST_2014_1" And student_course_modules.module_id IN ("'1'")) </code></pre>
28,009,396
0
<p>If you got <code>caffe</code> from git you should find in <code>data/ilsvrc12</code> folder a shell script <code>get_ilsvrc_aux.sh</code>.<br> This script should download several files used for ilsvrc (sub set of imagenet used for the large scale image recognition challenge) training. </p> <p>The most interesting file (for you) that will be downloaded is <code>synset_words.txt</code>, this file has 1000 lines, one line per class identified by the net.<br> The format of the line is</p> <blockquote> <p>nXXXXXXXX description of class</p> </blockquote>
13,450,229
0
<pre><code>jQuery(document).ready(function () { jQuery(".btnshow").click(function () { var pagename, pid; pid=jQuery(this).attr('rel'); pagename="&lt;?php echo JURI::root();?&gt;index.php?option=com_componentname&amp;view=result&amp;Id="+pid; jQuery.get(pagename, function (data) { jQuery('.para1').html(data); }); }); }); &lt;a href="JavaScript:void(0);" rel="&lt;?php echo $id; ?&gt;" title="&lt;?php echo $id; ?&gt;"&gt;&lt;img src="&lt;?php echo $image; ?&gt;" alt="" /&gt;&lt;/a&gt; </code></pre>
20,591,374
0
Transparent frame in windows phone 8 / XAML <p>I have two frames, main.xaml and target.xaml. I navigated to target.xaml from main.xaml. target.xaml has some content in a little square. Now I want that besides this square the rest of the area(of target.xaml frame) should be transparent(It should show main.xaml). I could not found any solution. Please help me. Are "opacity" or something like "isFullScreen" can help ?</p>
1,688,143
0
Finding out where curl was redirected <p>I'm using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually redirected?</p>
4,880,472
0
Printing with the browser in Silverlight 4 <p>I have a Silverlight 4 app which is essentially a canvas filled with user-drawn controls. When I use Print (or Print Preview) in Firefox 3.6, the canvas is not displayed.</p> <p>Every example wrt printing in Silverlight creates a Print button within their Silverlight app. Isn't there a browser event I can hook into (or something) so that the user can print from the browser instead of the application?</p>
14,083,692
0
How to autheticate once in google drive api <p>I have this problem about google drive. This is my application <img src="https://i.stack.imgur.com/bdJre.jpg" alt="enter image description here"></p> <p>As you can see here. I want to browse and upload the file to google drive. But every time I upload a file i need to allow and copy the authentication to my application.. like here</p> <p><img src="https://i.stack.imgur.com/7jLMb.png" alt="enter image description here"> </p> <p>Is it possible to allow access once? Is there any other way to fix this? Can i automatically allow access to the authentication code within my application so that i may not use the browser??</p>
4,191,293
0
<p>StringTokenizer treats consecutive delimiters as a single delimiter. You say the input contains [tab space] as delimiters, but the rest of your code doesn't seem to be expecting spaces so, without more information, I'm going to guess that the input is delimited only with tabs (not [tab space]), and the adjacent delimiters are being ignored, Then the last <code>nextToken()</code> throws an exception which you are ignoring.</p> <p>The answer here is to rewrite this using <code>split()</code>, as recommended in the <a href="http://download.oracle.com/javase/6/docs/api/java/util/StringTokenizer.html" rel="nofollow">Javadoc</a></p> <blockquote> <p>StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.</p> </blockquote> <p>That said, you should look at any of the existing CSV libraries out there (Google for Java CSV).</p>
10,519,284
0
<p>There is a 2GB limit for <em>apps</em> from the App Store but as far as user data goes, you should be able to basically fill the disk. When that happens, your saves will start to fail, I believe with 'NSFileWriteOutOfSpaceError' bubbled up from the PSC.</p> <p>As far as limiting entity space, there's no Core Data support for this - you'd have to handle it programatically. You could extend the validation system to check for certain conditions (free space, number of entities) and fail an insert or update if these didn't match your criteria.</p> <p>If you want to delete old users, just sort the results and delete the first/last one.</p>
30,282,411
0
<p>You should just consider using JButton but to answer the question:</p> <hr> <p><br>Try using MouseListener with BevelBorder for example:</p> <pre><code>yourPanel.addMouseListener(new MouseListener() { Border b = new BevelBorder(BevelBorder.LOWERED); Border originalBorder = null; @Override public void mouseReleased(MouseEvent e) { ((JComponent)e.getComponent()).setBorder(originalBorder); } @Override public void mousePressed(MouseEvent e) { originalBorder = ((JComponent)e.getComponent()).getBorder(); ((JComponent)e.getComponent()).setBorder(b); } ... }); </code></pre> <h1>Examples:</h1> <h2>Not clicked:</h2> <p><img src="https://i.stack.imgur.com/GM2Gw.png" alt="Not clicked"></p> <p><br></p> <h2>Clicked:</h2> <p><img src="https://i.stack.imgur.com/PA9WF.png" alt="Clicked"></p>
30,458,538
0
<p>It seems like a very specialized/unusual use case. It violates LSP. And using exceptions at all is unidiomatic in scala - <code>scala.util.control.Exception</code> is mainly about catching exceptions that library functions might throw and translating them into more idiomatic expressions of potential failures.</p> <p>If you want to do this then write your own code for it - it should be pretty straightforward. I really don't think this is a common enough use case for there to be a standard library function for it.</p>
16,941,640
0
Sed/Awk/Cut GNU transform text lines to single line <p>I have the following type of data:</p> <pre><code>3869|Jennifer Smith 10413 NE 71st Street Vancouver, WA 98662 360-944-9578 [email protected]|1234567890123456|03-2013|123 -- 3875|Joan L Doe 422 1/2 14th Ave E Seattle, WA 98112 206-322-7666 [email protected]|1234-1234-1234-1234|03-2013|123 -- 3862|Dana Doe 24235 NE 7th Pl Sammamish, WA 98074 425 868-2227 [email protected]|1234567890123456|03-2013|123 -- 3890|John Smith 10470 SW 67th Ave Tigard, OR 97223 5032205213 [email protected]|1234567890123456|03-2013|123 </code></pre> <p>I need to transform it to:</p> <pre><code>3869|Jennifer Smith|10413 NE 71st Street|Vancouver, WA|98662|360-944-9578|[email protected]|1234567890123456|03-2013|123 3875|Joan L Doe|422 1/2 14th Ave E|Seattle, WA|98112|206-322-7666|[email protected]|1234-1234-1234-1234|03-2013|123 3862|Dana Doe|24235 NE 7th Pl|Sammamish, WA|98074|425 868-2227|[email protected]|1234567890123456|03-2013|123 3890|John Smith|10470 SW 67th Ave|Tigard, OR|97223|5032205213|[email protected]|1234567890123456|03-2013|123 </code></pre> <p>or better:</p> <pre><code>3869|Jennifer Smith|10413 NE 71st Street|Vancouver|WA|98662|360-944-9578|[email protected]|1234567890123456|03-2013|123 3875|Joan L Doe|422 1/2 14th Ave E|Seattle|WA|98112|206-322-7666|[email protected]|1234-1234-1234-1234|03-2013|123 3862|Dana Doe|24235 NE 7th Pl|Sammamish|WA|98074|425 868-2227|[email protected]|1234567890123456|03-2013|123 3890|John Smith|10470 SW 67th Ave|Tigard|OR|97223|5032205213|[email protected]|1234567890123456|03-2013|123 </code></pre> <p>any idea how to automate this using GNU sed, awk, cu or perl/python whatever... Thank you!</p>
7,505,011
0
Bulk ingest into Redis <p>I'm trying to load a large piece of data into Redis as fast as possible.</p> <p>My data looks like:</p> <pre><code>771240491921 SOME;STRING;ABOUT;THIS;LENGTH 345928354912 SOME;STRING;ABOUT;THIS;LENGTH </code></pre> <p>There is a ~12 digit number on the left and a variable length string on the right. The key is going to be the number on the left and the data is going to be the string on the right.</p> <p>In my Redis instance that I just installed out of the box and with an uncompressed plain text file with this data, I can get about a million records into it a minute. I need to do about 45 million, which would take about 45 minutes. 45 minutes is too long.</p> <p>Are there some standard performance tweaks that exist for me to do this type of optimization? Would I get better performance by sharding across separate instances?</p>
30,767,405
0
<p>Agree with the above, in plain english, your code will be executed like this: </p> <ol> <li>final List studentList = new ArrayList(); </li> <li>ParseQuery query = ParseQuery.getQuery("Student");<br/> ------> 1. query.findInBackground (Popped onto background thread) </li> <li>return studentList (so yes, by the time you get here, studentList will probably be null). </li> </ol> <p>Just remember ".findinbackground" will always go to a background thread.</p>
21,299,032
0
<p>If you want your AJAX request to retrieve and execute code, use <code>dataType: 'script'</code>.</p> <p>Appending script to the DOM isn't going to do anything.</p> <p>See the <a href="http://api.jquery.com/jquery.ajax/" rel="nofollow">documentation</a>:</p> <blockquote> <p><strong>dataType</strong>:<br> ...<br> "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests.<br> ...</p> </blockquote>
15,263,602
0
<p>It will look something like this in your <code>AppDelegate</code>:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; WebViewController *webViewController1 = [[WebViewController alloc] initWithPDFAtURL:@"urlToPDF1"]; WebViewController *webViewController2 = [[WebViewController alloc] initWithPDFAtURL:@"urlToPDF2"]; WebViewController *webViewController3 = [[WebViewController alloc] initWithPDFAtURL:@"urlToPDF3"]; UITabBarController *tabBarController = [[UITabBarController alloc] init]; [tabBarController setViewControllers:[NSArray arrayWithObjects:webViewController1, webViewController2, webViewController3, nil]]; self.window.rootViewController = tabBarController; [self.window makeKeyAndVisible]; return YES; } </code></pre> <p>You will need to have a view controller that holds the <code>UIWebView</code>, and could look something like:</p> <pre><code>// WebViewController.h @interface WebViewController : UIViewController @end // WebViewController.m @interface WebViewController () @property (nonatomic, strong) NSURL *_pdfURL; @end @implementation WebViewController @synthesize _pdfURL; - (id)initWithPDFAtURL:(NSURL *)url { self = [super init]; if (self) { _pdfURL = url; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Load the PDF into a UIWebView } </code></pre>
12,416,880
0
Getting names from ... (dots) <p>In improving an <code>rbind</code> method, I'd like to extract the names of the objects passed to it so that I might generate unique IDs from those.</p> <p>I've tried <code>all.names(match.call())</code> but that just gives me:</p> <pre><code>[1] "rbind" "deparse.level" "..1" "..2" </code></pre> <p>Generic example:</p> <pre><code>rbind.test &lt;- function(...) { dots &lt;- list(...) all.names(match.call()) } t1 &lt;- t2 &lt;- "" class(t1) &lt;- class(t2) &lt;- "test" &gt; rbind(t1,t2) [1] "rbind" "deparse.level" "..1" "..2" </code></pre> <p>Whereas I'd like to be able to retrieve <code>c("t1","t2")</code>.</p> <p>I'm aware that in general one cannot retrieve the names of objects passed to functions, but it seems like with ... it might be possible, as <code>substitute(...)</code> returns <code>t1</code> in the above example.</p>
9,357,680
0
Doctrine 2 Transaction demarcation: implicit vs explicit <p>Im reading the doctrine 2 docs and have a question about transaction demarcation. Is there any difference between the following two snippets of code (other than syntax obviously)? Or is this just two ways of doing the exact same thing (ie implicitly and explicitly). What is the preferred method/best practice (implicit or explicit)?</p> <p>Implicit:</p> <pre><code>// $em instanceof EntityManager $user = new User; $user-&gt;setName('George'); $em-&gt;persist($user); $em-&gt;flush(); </code></pre> <p>Explicit:</p> <pre><code>// $em instanceof EntityManager $em-&gt;transactional(function($em) { $user = new User; $user-&gt;setName('George'); $em-&gt;persist($user); }); </code></pre>
7,860,065
0
Coderush express seems doesn't work <p>I installed Coderush express and I can see that it is installed. (I can see that Camel Case Navigation works). But I can see any other feature works. Based on this page: <a href="http://community.devexpress.com/blogs/markmiller/archive/2009/06/25/coderush-xpress-for-c-and-visual-basic-2008.aspx" rel="nofollow">http://community.devexpress.com/blogs/markmiller/archive/2009/06/25/coderush-xpress-for-c-and-visual-basic-2008.aspx</a></p> <p>I cannot see any of these feature to works:</p> <ol> <li><p>Tab to Next Reference : no effect when I put caret on a variable and press tab ( a tab inserted at the middle of my variable name!)</p></li> <li><p>Highlight All References: pressing ctrl+alt +u add a ascii character to source code.</p></li> <li><p>Quick Navigation: Ctrl +Shift + Q has no effect.</p></li> <li><p>Quick File Navigation : Ctrl +Alt +F brings up F# interactive</p></li> <li><p>Selection Increase and Selection Reduce doesn't work: generate a beep</p></li> <li><p>Declare: ctrl +` has no effect.</p> <p>and ...</p></li> </ol> <p>Any idea why this is happening? I am using VS2010. </p>
14,278,186
0
Appending a html tag to php variable <p>I am newbie to php, just starting learning it, while working with wordpress.</p> <p>I want to add html code to a php variable, a anchor tag link actually. First i splitted the text using <code>substr()</code>, and now i want to append a anchor tag at the end of post.</p> <pre><code>$json['timeline']['date'][$i]['text'] = substr(strip_tags($post-&gt;post_content), 0, 400)+"&lt;a href='#'&gt;Read more..&lt;/"; </code></pre> <p>Well, I believe this is not the right way. Can anyone please guide me?</p>
33,310,972
0
<p>The <strong>HTMLFormElement</strong> object/type has an <strong>checkValidity</strong> method you can use to check that.</p> <p>Check it here: <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement</a></p>
6,344,242
0
Object Comparison using if else | Operator Overloading <p>I have to <code>compare(&gt;,&lt;,==)</code> two <code>class object</code> based upon different criteria, explained below.</p> <pre><code>class Student { int iRollNumber; int iSection; int iMarks; } </code></pre> <ol> <li>I want to do comparison with <code>iRollNumber, iSection, iMarks</code> (Independently).</li> <li>I want to do comparison with <code>iRollNumber, iSection</code> (Combined).</li> <li>I want to do comparison with <code>iMarks, iSection</code> (Combined).</li> <li>..........</li> </ol> <p>Currently I am achieving this with <code>GetMethods()</code> and comparing them using <code>if elseif elseif..</code> structure.</p> <p>This is leading to the messy code everywhere!</p> <p>If I use <code>operator overloading</code> I have to decide on one way of comparison.</p> <p>Please suggest a way to do it with elegant coding. </p> <p>Or</p> <p>Can it be possible to call operator overloading Polymorphically?</p>
21,377,635
0
<pre><code>select Id from ( select Id, Month_Id, Customer_Id, Total_Amount from TableA except select Id, Month_Id, Customer_Id, Total_Amount from TableB ) q </code></pre>
14,335,983
0
<p>I used my apple developer support for this. Here's what the support said : </p> <blockquote> <p>The presence of the Voice I/O will result in the input/output being processed very differently. We don't expect these units to have the same gain levels at all, but the levels shouldn't be drastically off as it seems you indicate.</p> <p>That said, Core Audio engineering indicated that your results may be related to when the voice block is created it is is also affecting the RIO instance. Upon further discussion, Core Audio engineering it was felt that since you say the level difference is very drastic it therefore it would be good if you could file a bug with some recordings to highlight the level difference that you are hearing between voice I/O and remote I/O along with your test code so we can attempt to reproduce in house and see if this is indeed a bug. It would be a good idea to include the results of the singe IO unit tests outlined above as well as further comparative results.</p> <p>There is no API that controls this gain level, everything is internally setup by the OS depending on Audio Session Category (for example VPIO is expected to be used with PlayAndRecord always) and which IO unit has been setup. Generally it is not expected that both will be instantiated simultaneously.</p> </blockquote> <p>Conclusion? I think it's a bug. :/</p>
15,069,928
0
<p>Another version w/o building lists. import xml.etree.ElementTree as ET</p> <pre><code>PATH_IN = "sweep.xml" tree = ET.parse(PATH_IN) def convert(root): for p in root.iter('project'): yield p.get('name') for d in p.iter('design'): yield d.get('name') for e in d.iter('param'): yield [e.attrib['name'], [p.text for p in e]] it = convert(tree.getroot()) import pprint pprint.pprint(list(it)) </code></pre> <p>On OP input gives.</p> <pre><code>['testProj', 'des1', ['mag_d', ['3mm', '1', '5', '1']], ['mag_x', ['3mm', '2', '7', '1']], ['mag_y', ['3mm', '1', '2', '0.1']], 'des2', ['mag_d', ['3mm', '1', '5', '1']], ['mag_x', ['3mm', '2', '7', '1']], ['mag_y', ['3mm', '1', '2', '0.1']]] </code></pre>
22,289,802
0
Spring bean load error using spring-data-mongodb <p>We are using Spring version 3.2.0 and now introducing spring-data-mongodb version 1.4.0 in the codebase. I tried to write a new spring config file (mongo-config.xml) while solely defines mongodb related beans. </p> <p>My Spring config is as follows: </p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.4.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt; &lt;mongo:mongoid="replicaSetMongo"replica-set="localhost:10901,localhost:10902"&gt; &lt;mongo:optionsconnections-per-host="8" ssl="false" /&gt; &lt;/mongo:mongo&gt; &lt;mongo:db-factoryid="xmlLogDbFactory" mongo-ref="replicaSetMongo" dbname="logs" username="logs_owner" password="logs_owner" /&gt; &lt;mongo:mapping-converter&gt; &lt;mongo:custom-converters&gt; &lt;mongo:converter&gt; &lt;beanclass="com.utils.mongodb.dao.impl.SspLogsWriteConver ter"/&gt; &lt;/mongo:converter&gt; &lt;/mongo:custom-converters&gt; &lt;/mongo:mapping-converter&gt; &lt;beanid="xmlLogTemplate"class="org.springframework.data.mongodb.core.MongoTempla te"&gt; &lt;constructor-argname="mongoDbFactory"ref="xmlLogDbFactory"/&gt; &lt;constructor-argname="mongoConverter"ref="mappingConverter"/&gt; &lt;propertyname="writeConcern"&gt; &lt;util:constantstatic-field="com.mongodb.WriteConcern.UNACKNOWLEDGED"/&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>I deployed the application on JBoss. But JBoss given errors on startup as follows. Can someone help me what is going wrong? Is there a mismatch between spring version &amp; spring-mongodb version? I noticed that the exception trace mentions spring-beans-3.2.0 jar even though the issue is with mongo-config.xml</p> <pre><code>Caused by: org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Failed to import bean definitions from relative location [mongo-config.xml] Offending resource: class path resource [spring/commonUtil-config.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from class path resource [spring/mongo-config.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.mongodb.config.MongoNames paceHandler] for namespace [http://www.springframework.org/schema/data/mongo]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationExtension at org.springframework.beans.factory.parsing.FailFast ProblemReporter.error(FailFastProblemReporter.java :68) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:85) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:76) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.importBeanDefinitionResour ce(DefaultBeanDefinitionDocumentReader.java:271) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseDefaultElement(Defaul tBeanDefinitionDocumentReader.java:196) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:181) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.doRegisterBeanDefinitions( DefaultBeanDefinitionDocumentReader.java:140) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:111) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.importBeanDefinitionResour ce(DefaultBeanDefinitionDocumentReader.java:255) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE] ... 36 more </code></pre>
6,521,786
0
not able to get and store screen resolution <p>I am using following code to save screen-resolution in cookie</p> <pre><code>var the_cookie="screen_resolution="+screen.width+"x"+screen.height+";expires="+today.setDate(today.getDate()+1); document.cookie=the_cookie; </code></pre> <p>But some-how, it not working on browsers like IE 7 and 8.</p> <p>Any idea, why it's not working? Is screen.width and screen.height don't retrieve screen-resolution on all browsers, or they have browser dependencies. </p>
25,783,086
0
<p>The function isDigit and others like it all work with char types. Thus one you use it on a doulbe (conunt), you get wrong results.</p>
21,931,723
0
Downloading to download folder in Android <p>I have a webview in my app. One of my pages has a link to a mp3 which I should download directly from my app, so using a downloadlistener like this:</p> <pre><code>mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); </code></pre> <p>is not good for me, because it launches the default browser before actually donwloading the file. </p> <p>Is there any way I can manage the download myself, to the OS download folder, so that it appears when user goes to the "Downloads" option in the Android menu?</p>
33,938,334
0
Weird SQL Server stored procedure behaviour - different results between asp.net and Management Studio <p>We have a stored procedure that’s used to populate a SSRS Report. It’s a bit of a monster – loads of conditional logic (in case statements), casts (sometimes embedded in other casts) from varchar to datetime, and 3 fields that rely on calls to a function that contains some date functions . The report contains financial information for a list of contracts for one organisation.</p> <p>I need to create an asp.net page that shows a subset of the data for one organisation/contract so I cloned the sproc and added a contract parameter. However I noticed the figures for the 3 fields that rely on the function are different on the web page from when the stored procedure is run directly on the database or through the report.</p> <p>To troubleshoot I created a page (quick and dirty using <code>SqlDataSource</code> and <code>DataGrid</code>) that shows the results of the original stored procedure showing all contracts. The query runs fine through Enterprise Manager but the web page crashes with the YSOD and the message </p> <blockquote> <p>The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.</p> </blockquote> <p>I even tried hardcoding the SQL from the stored procedure into the web page but still get the same results</p> <p>On my dev machine the original stored procedure runs and my new stored procedure does return consistent results regardless of whether viewed through the web page or Management Studio. The regional settings etc are same on the dev server and live server. The only different thing I can think of is that the live web server and db server are on separate machines.</p> <p>Has anyone come across anything like this before??</p> <p>Thanks</p>
12,841,916
0
phpFlickr proxy not working call to member function error <p>I have downloaded and setup phpFlickr library but I need to use it from behind a proxy, so I have added the line to the example file and it throws an error. As its all pretty much out of the box, im flumaxed I also dont get the call to member function on a non object error it completely baffles me.</p> <p>The readme paragraph</p> <blockquote> <ol> <li>Some people will need to ues phpFlickr from behind a proxy server. I've implemented a method that will allow you to use an HTTP proxy for all of your traffic. Let's say that you have a proxy server on your local server running at port 8181. This is the code you would use: $f = new phpFlickr("[api key]"); $f->setProxy("localhost", "8181"); After that, all of your calls will be automatically made through your proxy server.</li> </ol> </blockquote> <p>The example.php file with my single modified line</p> <pre><code>require_once("phpFlickr.php"); $f = new phpFlickr("********************"); $f-&gt;setProxy("cache.mysite.org.uk", "80"); $recent = $f-&gt;photos_getRecent(); foreach ($recent['photo'] as $photo) { $owner = $f-&gt;people_getInfo($photo['owner']); echo "&lt;a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'&gt;"; echo $photo['title']; echo "&lt;/a&gt; Owner: "; echo "&lt;a href='http://www.flickr.com/people/" . $photo['owner'] . "/'&gt;"; echo $owner['username']; echo "&lt;/a&gt;&lt;br&gt;"; </code></pre> <p>}</p> <p>Any idea why im getting the following error Call to a member function setProxy() on a non-object in public_html/phpFlickr/phpFlickr.php on line 338</p> <p>That code is</p> <pre><code>#336 function setProxy ($server, $port) { #337 // Sets the proxy for all phpFlickr calls. #338 $this-&gt;req-&gt;setProxy($server, $port); } </code></pre>
1,791,764
0
Variable item height in TreeView gives broken lines <p>Wee.</p> <p>So I finally figured out how the iIntegral member of TVITEMEX works. The MSDN docs didn't think to mention that setting it while inserting an item has no effect, but setting it after the item is inserted works. Yay!</p> <p>However, when using the TVS_HASLINES style with items of variable height, the lines are only drawn for the top part of an item with iIntegral > 1. E.g. if I set TVS_HASLINES and TVS</p> <p><a href="http://i49.tinypic.com/24o8wwk.png" rel="nofollow noreferrer">Here's what it looks like</a> (can't post images WTF?)</p> <p>Should I manually draw more of the lines in response to NM_CUSTOMDRAW or something?</p>
885,474
0
<p>They conceptually organize revisions as changesets which allow you to very easily branch/merge your code. Merging a branch in SVN is an excruciatingly painful experience.</p>
6,869,305
0
<p>Even if static pages are going to be <em>slightly</em> faster than loading every page from the database, with projects such as these you have to take into consideration numerous other factors. It may be appealing to optimize for performance only, but you do not want to be the one to explain to your users why they need to spend 10 minutes in creating a new quiz because "the database runs more efficiently".</p> <p>What you need to focus on is usage. If you're the only one who's going to maintain it, sure, static pages might not be bad. But if you're going to hand off the page to non-technical users or if the pages are going to need frequent changing, well, that's why dynamic pages with an administration interface were made for.</p> <p>If this is a general-use application, I'd "optimize for users" rather than performance. Sure, the latter might take slight hits, but in the end, do not build something you do not want to maintain. Fast changing, multi-user applications - use administration backends.</p>
1,133,816
0
Dump Analysis with Source, using Visual Studio 2008 Express? <p>Is there any way to analyze app-crash minidumps (e.g. created by SetUnhandledExceptionFilter, or minidumpwritedump()) with source, using Visual Studio 2008 Express? </p> <p>I generally do this at work using "real" versions of VS, but when trying to get it to work on my personal projects (using VS 2008 Express) it tells me "There is no source code available for the current location." and refuses to give me anything other than a disassembly window. Symbols for the app in question are loaded by the debugger, the "Debug Source Files" property page includes a pointer to the directory in which my source-code lives, but no dice.</p> <p>Is it even possible to do this via the Express edition of VS 2008? If so, does anyone have any advice as to what else I could try to get this working?</p>
16,252,449
0
<p>A byte is a signed value held in 8 bits and may be in the range -128 to 127.</p> <p>The left most bit is used as the sign bit.</p> <p><code>System.out.println(-20 &amp; 0xFF);</code> has nothing to do with bytes, this is an int operation.</p> <p>The binary representation of -20, as a byte is: 1110_1100</p> <p>1110_1100 &amp; 1111_1111 = 1110_1100</p> <p>If you want unsigned, there's char to play with, but you're not going to be happy. Realistically, Java doesn't have unsigned.</p> <p>Negatives are stored in '2s Complement' form, eg:</p> <p>1111_1111 == -1</p> <p>But why?</p> <p>Under 2s complement to make a negative number, all the bits are flipped (1s complement) and 1 is added (making 2s complement - two operations)</p> <p>So</p> <pre><code> 0000_0000 - Zero -0000_0001 - minus one --------- 1111_1110 - Ones complement - (this would be xor 1111_1111) +0000_0001 - plus one - we're converting to 2s complement, not doing math --------- 1111_1111 - -1 in 2s complement </code></pre>
13,513,078
0
User defined hierarchy in cube (dyslexia) <p>I can make 6 level dimension hierarchy with such relationships:</p> <ol> <li>main -> lvl1</li> <li>lvl1 -> lvl2</li> <li>lvl2 -> lvl3</li> <li>lvl3 -> lvl4</li> <li>lvl4 -> lvl5</li> </ol> <p>Hierarchy looks fine in the dimension browser. All attribute keys are composition keys of each other.</p> <p>When i try to use dimension in cube, with main as key to measures, it will fail citing: 'Attribute key 'main' not found..'</p> <p>In the measures are all members of the dimension hierarchy.</p> <p>is the relationship faulty or what is missing?</p>
4,374,475
0
Regarding Good CSS forum <p>i am looking for good css forum where i can post question an get answer very quickly like <a href="http://stackoverflow.com">http://stackoverflow.com</a>.</p> <p>please provide me few url related with css forum.</p>
30,412,318
0
<p>Check out this implementation</p> <pre><code> void OnChatClick (object sender, EventArgs args) { var pic = new Image { Source = "bubble.png", Aspect = Aspect.Fill }; var textLabel = new Label { Text = "Hello", TextColor = Color.White, VerticalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.WordWrap }; var relativeLayout = new RelativeLayout { BackgroundColor = Color.Navy, // HeightRequest = 1000 }; var absoluteLayout = new AbsoluteLayout { VerticalOptions = LayoutOptions.Center, BackgroundColor = Color.Blue }; var frame = new Frame { BackgroundColor = Color.Red }; absoluteLayout.Children.Add (pic, new Rectangle (0, 0, 1, 1), AbsoluteLayoutFlags.All); absoluteLayout.Children.Add (textLabel, new Rectangle (0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional); // textLabel.SizeChanged += (object label, EventArgs e) =&gt; { // relativeLayout.HeightRequest = textLabel.Height + 30; // absoluteLayout.HeightRequest = textLabel.Height + 30; // }; relativeLayout.Children.Add (frame, heightConstraint: Constraint.RelativeToParent (parent =&gt; parent.Height), widthConstraint: Constraint.RelativeToParent (parent =&gt; parent.Width * 0.3)); relativeLayout.Children.Add (absoluteLayout, xConstraint: Constraint.RelativeToParent (parent =&gt; parent.Width * 0.3), widthConstraint: Constraint.RelativeToParent (parent =&gt; parent.Width * 0.7)); ChatScrollViewStackLayout.Children.Add (relativeLayout); } </code></pre> <p>If you need to auto-adjust height of the chat message for long text uncomment all five commented lines.</p>
40,134,888
0
<pre><code> SELECT ru.whs_code, ru.pdt_code, ru.case_dt_yyyymmdd, ru.fresh_frozen_status, ru.operation, ru.Qty - su.Qty AS Qty_Diff, ru.Wt - su.Wt AS Wt_Diff FROM ( SELECT whs_code, pdt_code, case_dt_yyyymmdd, fresh_frozen_status, operation, SUM(qty_cases_on_hand) AS Qty, SUM(qty_weight_on_hand) AS Wt FROM tbl_inventory_activity_rpt1 WHERE operation ='RU' GROUP BY whs_code,pdt_code,case_dt_yyyymmdd,fresh_frozen_status,operation ) ru, ( SELECT whs_code, pdt_code, case_dt_yyyymmdd, fresh_frozen_status, operation, SUM(qty_cases_on_hand) AS Qty, SUM(qty_weight_on_hand) AS Wt FROM tbl_inventory_activity_rpt1 WHERE operation ='SU' GROUP BY whs_code,pdt_code,case_dt_yyyymmdd,fresh_frozen_status,operation ) su WHERE ru.whs_code = su.whs_code AND ru.pdt_code = su.pdt_code AND ru.case_dt_yyyymmdd = su.case_dt_yyyymmdd AND ru.fresh_frozen_status = su.fresh_frozen_status AND ru.operation = su.operation; </code></pre>
8,817,772
0
<p>This will let the system decide which viewer to use..</p> <pre><code> System::Diagnostics::Process::Start("C:\\MyPdf.pdf"); </code></pre>
12,765,785
0
<p>Your problem is a misunderstanding of how PHP provides your "value" in the foreach construct.</p> <pre><code>foreach($top_level_array as $current_top_level_member) </code></pre> <p>The variable $current_top_level_member is a copy of the value in the array, not a reference to inside the $top_level_array. Therefore all your work happens on the copy and is discarded after the loop completes. (Actually it is in the $current_top_level_member variable, but $top_level_array never sees the changes.)</p> <p>You want a reference instead:</p> <pre><code>foreach($top_level_array as $key =&gt; $value) { $current_top_level_member =&amp; $top_level_array[$key]; </code></pre> <p><strong>EDIT:</strong></p> <p>You can also use the <code>foreach</code> by reference notation (hat tip to air4x) to avoid the extra assignment. Note that if you are working with an array of Objects, they are already passed by reference.</p> <pre><code>foreach($top_level_array as &amp;$current_top_level_member) </code></pre> <p>To answer you question as to why PHP defaults to a copy instead of a reference, it's simply because of the rules of the language. Scalar values and arrays are assigned by value, unless the <code>&amp;</code> prefix is used, and objects are always assigned by reference (<a href="http://www.php.net/manual/en/language.references.whatdo.php" rel="nofollow">as of PHP 5</a>). And that is likely due to a general consensus that it's generally better to work with copies of everything expect objects. BUT--it is not slow like you might expect. PHP uses a lazy copy called copy on write, where it is really a read-only reference. On the first write, the copy is made.</p> <blockquote> <p>PHP uses a lazy-copy mechanism (also called copy-on-write) that does not actually create a copy of a variable until it is modified.</p> <p>Source: <a href="http://www.thedeveloperday.com/php-lazy-copy/" rel="nofollow">http://www.thedeveloperday.com/php-lazy-copy/</a></p> </blockquote>
8,432,834
0
<p>As in the Hayes modem control commands? These are the commands used to gain the *AT*tention of a modem and cause it to interact with the phone system and/or computer (to test, read, set and execute commands). A tutorial can be found here: <a href="http://www.engineersgarage.com/tutorials/at-commands" rel="nofollow">http://www.engineersgarage.com/tutorials/at-commands</a></p>
31,325,860
1
Dynamic Datasets and SQLAlchemy <p>I am refactoring some old SQLite3 SQL statements in Python into SQLAlchemy. In our framework, we have the following SQL statements that takes in a dict with certain known keys and potentially any number of unexpected keys and values (depending what information was provided). </p> <pre><code>import sqlite3 import sys def dict_factory(cursor, row): d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d def Create_DB(db): # Delete the database from os import remove remove(db) # Recreate it and format it as needed with sqlite3.connect(db) as conn: conn.row_factory = dict_factory conn.text_factory = str cursor = conn.cursor() cursor.execute("CREATE TABLE [Listings] ([ID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, [timestamp] REAL NOT NULL DEFAULT(( datetime ( 'now' , 'localtime' ) )), [make] VARCHAR, [model] VARCHAR, [year] INTEGER);") def Add_Record(db, data): with sqlite3.connect(db) as conn: conn.row_factory = dict_factory conn.text_factory = str cursor = conn.cursor() #get column names already in table cursor.execute("SELECT * FROM 'Listings'") col_names = list(map(lambda x: x[0], cursor.description)) #check if column doesn't exist in table, then add it for i in data.keys(): if i not in col_names: cursor.execute("ALTER TABLE 'Listings' ADD COLUMN '{col}' {type}".format(col=i, type='INT' if type(data[i]) is int else 'VARCHAR')) #Insert record into table cursor.execute("INSERT INTO Listings({cols}) VALUES({vals});".format(cols = str(data.keys()).strip('[]'), vals=str([data[i] for i in data]).strip('[]') )) #Database filename db = 'test.db' Create_DB(db) data = {'make': 'Chevy', 'model' : 'Corvette', 'year' : 1964, 'price' : 50000, 'color' : 'blue', 'doors' : 2} Add_Record(db, data) data = {'make': 'Chevy', 'model' : 'Camaro', 'year' : 1967, 'price' : 62500, 'condition' : 'excellent'} Add_Record(db, data) </code></pre> <p>This level of dynamicism is necessary because there's no way we can know what additional information will be provided, but, regardless, it's important that we store all information provided to us. This has never been a problem because in our framework, as we've never expected an unwieldy number of columns in our tables.</p> <p>While the above code works, it's obvious that it's not a clean implementation and thus why I'm trying to refactor it into SQLAlchemy's cleaner, more robust ORM paradigm. I started going through SQLAlchemy's official tutorials and various examples and have arrived at the following code:</p> <pre><code>from sqlalchemy import Column, String, Integer from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker Base = declarative_base() class Listing(Base): __tablename__ = 'Listings' id = Column(Integer, primary_key=True) make = Column(String) model = Column(String) year = Column(Integer) engine = create_engine('sqlite:///') session = sessionmaker() session.configure(bind=engine) Base.metadata.create_all(engine) data = {'make':'Chevy', 'model' : 'Corvette', 'year' : 1964} record = Listing(**data) s = session() s.add(record) s.commit() s.close() </code></pre> <p>and it works beautifully with that data dict. Now, when I add a new keyword, such as</p> <pre><code>data = {'make':'Chevy', 'model' : 'Corvette', 'year' : 1964, 'price' : 50000} </code></pre> <p>I get a <code>TypeError: 'price' is an invalid keyword argument for Listing</code> error. To try and solve the issue, I modified the class to be dynamic, too:</p> <pre><code>class Listing(Base): __tablename__ = 'Listings' id = Column(Integer, primary_key=True) make = Column(String) model = Column(String) year = Column(Integer) def __checker__(self, data): for i in data.keys(): if i not in [a for a in dir(self) if not a.startswith('__')]: if type(i) is int: setattr(self, i, Column(Integer)) else: setattr(self, i, Column(String)) else: self[i] = data[i] </code></pre> <p>But I quickly realized this would not work at all for several reasons, e.g. the class was already initialized, the data dict cannot be fed into the class without reinitializing it, it's a hack more than anything, et al.). The more I think about it, the less obvious the solution using SQLAlchemy seems to me. So, my main question is, <strong>how do I implement this level of dynamicism using SQLAlchemy?</strong></p> <p>I've researched a bit to see if anyone has a similar issue. The closest I've found was <a href="http://stackoverflow.com/questions/2768607/dynamic-class-creation-in-sqlalchemy">Dynamic Class Creation in SQLAlchemy</a> but it only talks about the constant attributes ("<strong>tablename</strong>" et al.). I believe the unanswered <a href="http://stackoverflow.com/questions/29105206/sqlalchemy-dynamic-attribute-change">SQLalchemy dynamic attribute change</a> may be asking the same question. While Python is not my forte, I consider myself a highly skilled programmer (C++ and JavaScript are my strongest languages) in the context scientific/engineering applications, so I may not hitting the correct Python-specific keywords in my searches.</p> <p>I welcome any and all help.</p>
20,426,764
0
<p>Quick suggestion add id as primary key column to users table. Then get that id after new record is inserted and save that id in SharedPreferences, then when ever required you can pull record from users table like using WHERE <code>id</code> = my_id_save. Here is example <a href="http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/" rel="nofollow">http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/</a></p>
29,712,802
0
<p><code>getFileInfoClass</code> returns a class, so <code>getFileInfoClass(f)</code> is a class. When you take a class name and write parentheses after it, you call a constructor. </p> <p>So, <code>[getFileInfoClass(f)(f) for f in fileList]</code> makes a list of <code>FileInfo</code> objects.</p>
35,718,684
0
<p>Exactly like the error states, you are attempting to compare a <a href="https://msdn.microsoft.com/en-us/library/c8f5xwh7.aspx" rel="nofollow"><code>bool</code></a> (<code>xx.Value</code>) with a <a href="https://msdn.microsoft.com/en-us/library/362314fe.aspx" rel="nofollow"><code>string</code></a> (<code>"rcat"</code>) which is not allowed for obvious reasons.</p>
22,794,254
0
<p>i think Template method pattern better suits here. 1. create Hotel interface 2. create 3 Hotel classes(implements Hotel interface) LakeWood,Rosewood and xyzWood</p> <ol> <li><p>now create customer class and it will have series of dates also.</p> <p>here both Customer class and Hotel class both are independent.</p></li> <li><p>now create an interface say LogicInterface which will have a method and this method will be passed customer and List hotels as parameter, and will be returning cheapest hotel. now we will create class implementing LogicInterface.cheap hotel finding logic will be in this class here "Template method pattern" will be used,because later on and cheapest hotel finding logic is changed,we will create new class which will be implementing LogicInterface and just one line change will finish our work,no where any code change will be needed.</p></li> </ol>
17,076,030
0
How can I find int values within a string <p>I have a string, e.g. <code>"ksl13&lt;br&gt;m4n"</code>, and I want to remove all non-digit characters in order to get the int 134.</p> <p><code>Integer.parseInt(s)</code> obviously isn't going to work, but not sure how else to go about it.</p>
12,599,906
0
<p>Note : When an object is cloned, PHP 5 will perform a shallow copy of all of the object's properties. Any properties that are references to other variables, will remain references. </p> <p>Alternative you can use reflection to create a (deep) copy of your object.</p> <pre><code> $productClone = $this-&gt;objectManager-&gt;create('Tx_Theext_Domain_Model_Product'); // $product = source object $productProperties = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($product); foreach ($productProperties as $propertyName =&gt; $propertyValue) { Tx_Extbase_Reflection_ObjectAccess::setProperty($productClone, $propertyName, $propertyValue); } // $productAdditions = ObjectStorage property $productAdditions = $product-&gt;getProductAddition(); $newStorage = $this-&gt;objectManager-&gt;get('Tx_Extbase_Persistence_ObjectStorage'); foreach ($productAdditions as $productAddition) { $productAdditionClone = $this-&gt;objectManager-&gt;create('Tx_Theext_Domain_Model_ProductAddition'); $productAdditionProperties = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($productAddition); foreach ($productAdditionProperties as $propertyName =&gt; $propertyValue) { Tx_Extbase_Reflection_ObjectAccess::setProperty($productAdditionClone, $propertyName, $propertyValue); } $newStorage-&gt;attach($productAdditionClone); } $productClone-&gt;setProductAddition($newStorage); // This have to be repeat for every ObjectStorage property, or write a service. </code></pre>
14,866,171
0
<p>How about something like this -</p> <pre><code>$cal = New-Object -Type PsObject -Prop @{ Year = 2013 Events = @() } $event = New-Object -Type PsObject -Prop @{ Date = [DateTime] "2013-02-14" Name = "Valentines Day" } $cal.Events += $event </code></pre> <p>If you have a predefined calendar objects which doesn't have a property to store events you can use <code>Add-Member</code> to attach a new property and store an array in there.</p>
4,304,264
0
<p>My guess is PHP is evaluating the above as a string, not hex. And Java is doing it as you expect it.</p>
22,943,328
0
Rails app crashes when config.eager_load=true <p>I have a Rails application and an Engine. </p> <p>When i have config.eager_load= true in my environments/production.rb the app crashes giving the following error in the engine </p> <pre><code>FATAL: ActionView::Template::Error(undefined local variable or method `current_user' for #&lt;#&lt;Class:0x00000005812fe0&gt;:0x00000005811e88&gt;) /var/www/rack_apps/manager/shared/vendor_bundle/ruby/2.1.0/gems/authorization_engine-0.1.0.SNAPSHOT.20140407182910/app/views/authorization_engine/authorizations/new.html.haml:26:in `__var_www_rack_apps_manager_shared_vendor_bundle_ruby_______gems_authorization_engine_______________________________app_views_authorization_engine_authorizations_new_html_haml__268041456534634533_46121540' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:143:in `block in render' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:161:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:141:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `block in instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument' vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:47:in `render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:17:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:42:in `render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:23:in `render' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:127:in `_render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/streaming.rb:219:in `_render_template' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:120:in `render_to_body' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/rendering.rb:33:in `render_to_body' vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/renderers.rb:26:in `render_to_body' </code></pre> <p>But the same above seems to work if i set the config.eager_load = false</p> <p>Is this normal ? ... I know you shouldn't be setting eager_load to false in production. Is there a way not to eager load the engine or have i got the entire concept wrong ?</p> <p>I know it says undefined variable current_user but it picks it up perfectly when i run locally . Any suggestions or ideas would be awesome .Thanks</p>
19,926,022
0
<p>You are inserting means adding one row,, but you want to update,, so use <code>UPDATE</code> instead of <code>INSERT</code></p> <pre><code>UPDATE user SET name = 'abc' WHERE id = 1; </code></pre>
11,389,879
0
Saving Data from iphone app to text file in iPhone app <p>I want to save my application data in text file in documents folder I am using following way to store but it store single string i want that my data is in array how may store all the contents of array in text files</p> <pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString*yourString=@"This is working fine"; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"file.txt"]; NSString *stringWithoutSpaces = [yourString stringByReplacingOccurrencesOfString:@" " withString:@""]; [stringWithoutSpaces writeToFile:filePath atomically:TRUE encoding:NSUTF8StringEncoding error:NULL]; </code></pre> <p>My Array is like Following</p> <pre><code> DataController *coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row]; cell.resturantLocationLabel.text=coffeeObj.resturantLocation; cell.foodQualityRatingLabel.text=coffeeObj.foodQualityRating; cell.foodPresentationRatingLabel.text=coffeeObj.foodPresentationRating; cell.waiterRatingLabel.text=coffeeObj.waiterRating; cell.ambienceRatingLabel.text=coffeeObj.ambienceRating; cell.overallRatingLabel.text=coffeeObj.overallRating; cell.commentsLabel.text=coffeeObj.comments; cell.emailAddressLabel.text=coffeeObj.emailAddress; cell.addtoMailingListLabel.text=coffeeObj.addtoMailingList; NSString*test=coffeeObj.comments; </code></pre>
12,458,198
1
merging selenium rc and webdriver <p>I have made most of my automation code using Selenium RC with Python. But, I feel that with the evolution in my product (what I'm testing through selenium RC), my automation needs are changed. I tried Wedriver with python and it works a treat with my product. But, as many features of my new product versions are inherited from the previous versions, I feel that I can make use of my existing Selenium RC code. But, for new features, I want to use Webdriver.</p> <p>Moreover, there are also some things w.r.t the selenium profile that I 'm maintaining. Examples:</p> <ol> <li>For ssl certificates, using selenium RC, I have 2 methods: Selenium profile (where I have saved the acceptance of ssl certificate) and <code>'trustallsslcertificates'</code> parameter while starting selenium rc. Using <code>trustallsslcertificates</code> slows down the automation speed like hell.<br> But, using webdriver, I dont need all such ssl certificates.</li> <li>Using Selenium RC, whenever I need to download a file using my web page, I have used the save option as default and saved it in the same selenium profile. But, using webdriver, I have other options to download a file, rather than maintaining the selenium profile.</li> </ol> <p>I also checked in the existing question: <a href="http://stackoverflow.com/questions/4342088/selenium-web-driver-and-selenium-rc">Selenium Web driver and selenium RC</a>, but, the answer seems to old, many things must have updated by then. </p> <p>Crux of my question is: Can I integrate my existing python code, that I use using selenium RC (Python bindings - selenium.py ), with Webdriver using python ?</p> <p>PS: Currently I am using selenium 2.3.0.jar file</p>
27,961,615
0
Goals with same conversion rate <p>I have a problem with my Google Analytics goals. I'm using Magento as CMS.</p> <p>These are the funnels:</p> <p>Goal 1:</p> <p>Product page: something /product1 Cart: ^/checkout/cart/$ Customer details: ^/checkout/cart/step2/$ Destination: ^/checkout/onepage/success/</p> <p>Goal 2:</p> <p>Product page: something /product2 Cart: ^/checkout/cart/$ Customer details: ^/checkout/cart/step2/$ Destination: ^/checkout/onepage/success/</p> <p>Both Goals have the same conversion rate. But, I can see in the Ecommerce Product Performance section that products in Goal 1 convert in much higher numbers then products in Goal 2. So the conversion rate should be different.</p> <p>Why are the goals showing the same conversion rate? The CMS is Magento.</p>
24,937,783
0
<p>A good usage would be to implement a chunk to translate to-and from-base64 or any unaligned data structure.</p> <pre><code>struct { unsigned int e1:6; unsigned int e2:6; unsigned int e3:6; unsigned int e4:6; } base64enc; //I don't know if declaring a 4-byte array will have the same effect. struct { unsigned char d1; unsigned char d2; unsigned char d3; } base64dec; union base64chunk { struct base64enc enc; struct base64dec dec; }; base64chunk b64c; //you can assign 3 characters to b64c.enc, and get 4 0-63 codes from b64dec instantly. </code></pre> <p>This example is a bit naive, since base64 must also consider null-termination (i.e. a string which has not a length <code>l</code> so that <code>l</code> % 3 is 0). But works as a sample of accessing unaligned data structures.</p> <p>Another example: Using this feature to <strong>break a TCP packet header into its components</strong> (or other network protocol packet header you want to discuss), althought it is a more advanced and less end-user example. In general: this is useful regarding PC internals, SO, drivers, an encoding systems.</p> <p>Another example: analyzing a <code>float</code> number.</p> <pre><code>struct _FP32 { unsigned int sign:1; unsigned int exponent:8; unsigned int mantissa:23; } union FP32_t { _FP32 parts; float number; } </code></pre> <p>(Disclaimer: Don't know the file name / type name where this is applied, but in C this is declared in a header; Don't know how can this be done for 64-bit flaots since the mantissa must have 52bits and -in a 32bit target- ints have 32 bits).</p> <p><strong>Conclusion:</strong> As the concept and these examples show, this is a rarely used feature because it's mostly for internal purposes, and not for day-by-day software.</p>
26,206,942
0
<p>Assuming you are having <code>Post-&gt;hasMany-&gt;Like</code> relationship and you have declared likes relationship as:</p> <pre><code>class Post{ public function likes(){ return $this-&gt;hasMany('Like'); } } </code></pre> <p>create a new function say <code>likeCountRelation</code> as:</p> <pre><code>public function likeCountRelation() { $a = $this-&gt;likes(); return $a-&gt;selectRaw($a-&gt;getForeignKey() . ', count(*) as count')-&gt;groupBy($a-&gt;getForeignKey()); } </code></pre> <p>now you can override <code>__get()</code> function as:</p> <pre><code>public function __get($attribute) { if (array_key_exists($attribute, $this-&gt;attributes)) { return $this-&gt;attributes[$attribute]; } switch ($attribute) { case 'likesCount': return $this-&gt;attributes[$attribute] = $this-&gt;likesCountRelation-&gt;first() ? $this-&gt;likesCountRelation-&gt;first()-&gt;count : 0; break; default: return parent::__get($attribute); } } </code></pre> <p>or you can use getattribute function as :</p> <pre><code>public function getLikesCountAttribute(){ return $this-&gt;likesCountRelation-&gt;first() ? $this-&gt;likesCountRelation-&gt;first()-&gt;count : 0; } </code></pre> <p>and simply access likesCount as <code>$post-&gt;likesCount</code> you can even eager load it like:</p> <pre><code>$posts=Post::with('likesCountRelation')-&gt;get(); foreach($post as $post){ $post-&gt;likesCount; } </code></pre> <p><code>NOTE:</code> Same logic can be used for morph many relationships.</p>
39,016,704
0
Publish live stream using webrtc and wowza <p>I have taken a preview copy for webrtc. On my streaming server I have setup the streamlock and done with configuration in vhost.xml file. I'm unable to publish stream from the html files provided by wowza. </p> <p>I get error: <code>Refused to set unsafe header “Connection”</code>. I have added the hostport for port 443. </p>
11,495,884
0
carousel like with css, overflow-x (horizontal only) <p>I have an <code>overflow-x:scroll</code> and <code>overflow-y:hidden</code>. I have images, but when I'm trying to make it only scroll horizontally, it doesn't work? When I highlight the images and drag the highlight downwards, its scrolls down vertically.</p> <pre><code>#contents { margin:0 auto; text-align:center; width:1200px; clear:both; } #image_contents { float:left; height: 208px; overflow-x:scroll; overflow-y:hidden; margin:0 auto; } .images { float:left; margin:2px; background:#000; overflow:hidden; position:relative; display:inline-block; } &lt;div id="contents"&gt; &lt;div id="image_contents"&gt; &lt;div class="images"&gt; &lt;img src="1.jpg"/&gt; &lt;/div&gt; &lt;div class="images"&gt; &lt;img src="2.jpg"/&gt; &lt;/div&gt; &lt;div class="images"&gt; &lt;img src="3.jpg"/&gt; &lt;/div&gt; &lt;!-- and so forth !-&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
11,022,584
0
<p>Uhm, theoretically, how would you know if it is unicode?</p> <p>This is the real question. Truthfully, you cannot know, but you can make a decent guess.</p> <p>See: <a href="http://stackoverflow.com/questions/499010/java-how-to-determine-the-correct-charset-encoding-of-a-stream">Java : How to determine the correct charset encoding of a stream</a> for more details. :)</p>
24,884,925
0
Observers and Asynchrony in Ember.js <p>I follewed the guide on <a href="http://www.emberjs.com" rel="nofollow">the ember.js homepage</a> and found that code at <a href="http://emberjs.com/guides/object-model/observers/#toc_observers-and-asynchrony" rel="nofollow">this section</a>:</p> <pre><code>Person.reopen({ lastNameChanged: function() { // The observer depends on lastName and so does fullName. Because observers // are synchronous, when this function is called the value of fullName is // not updated yet so this will log the old value of fullName console.log(this.get('fullName')); }.observes('lastName') }); </code></pre> <p>According to the comments the function <code>lastNameChanged</code> should output an old version of the fullName property. But when I ran my slightly modifed code I got the new version of the property:</p> <pre><code>Person = Ember.Object.extend({ firstName: null, lastName: null, fullName: function() { return this.get('firstName') + ' ' + this.get('lastName'); }.property('firstName', 'lastName'), }); Person.reopen({ lastNameChanged: function() { console.log('lastName changed. Name is now: ' + this.get('fullName')); }.observes('lastName') }) max = Person.create({ firstName: 'Max', lastName: 'Lehmann', }); max.set('lastName', 'Mustermann'); console.log(max.get('fullName')); </code></pre> <p>I know that the guide is based on an older version of Emberjs (I suppose 1.3). I tested the code with the current version of Ember (1.6.1). Does the new version explain the change in that behaviour?</p>
38,018,805
0
<p>You should initialize it before using or accessing it's properties. Try this:</p> <pre><code>let mark = TimeMark() let rounded = (mark.rawValue == TimeMark.Current) </code></pre>
18,633,648
0
<pre><code>filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); </code></pre> <p>The rotation property of the BasicImage filter can accept one of four values: 0, 1, 2, or 3 which will rotate the element 0, 90, 180 or 270 degress respectively.</p>
9,843,132
0
<p>Yes, if you really want / need to do it you can use PowerMock. This should be considered a last resort. With PowerMock you can cause it to return a mock from the call to the constructor. Then do the verify on the mock. That said, csturtz's is the "right" answer.</p> <p>Here is the link to <a href="http://code.google.com/p/powermock/wiki/MockConstructor" rel="nofollow">Mock construction of new objects</a></p>
34,732,378
0
Anyway to have programs share Windows Explorer icon overlays? <p>The fact that Windows only allows 15 icon overlays is well worn territory at this point. I understand how to rename the registry entries to get the overlays I absolutely <em>need</em> to be visible. But I wonder if there is a better way. </p> <p>I don't know much about registry editing and I know next to nothing about the inner working of windows and how the overlays actually get requested/delivered. So I'm not sure how these overlays actually work... But the programs I use that have overlays (TortoiseSvn, Box, Google Drive) all do basically the same thing. Generally speaking, they compare the status of a file locally to the status of a file in the cloud or on a server. For this reason it seems like many of these overlays could logically be shared. Why couldn't the BoxSynced, GoogleDriveSynced, and Tortoise1Normal all use the same icon?</p> <p>So my question is: Does anyone know of a way to manipulate the registry to combine some icon overlays? Or is there maybe a some sort of tool or utility out there that can achieve something like a set of "shared overlays"? </p>
37,359,596
0
<p>The <code>00010</code> is octal number, i.e., 8. Remove all the leading zeroes.</p>
38,056,290
0
<pre><code>function isBusinessDay(theDate){ theDay = theDate.getDay(); // Get day returns 0-6, respectively Sunday - Saturday if(theDay == 0 || theDay == 6){ return false; } else { return true; } } </code></pre> <p>Use with zzzzBov's <code>while (!isBusinessDay(date)) { date.setDate(date.getDate() - 1) }</code></p> <p>A more concise way to write it :</p> <pre><code>function isBusinessDay(theDate){ theDay = theDate.getDay(); // Get day returns 0-6, respectively Sunday - Saturday if(theDay == 0 || theDay == 6) return false; return true; } </code></pre>
25,528,895
0
<p>Apart from using a <code>List&lt;object&gt;</code>, it might help to make your interface generic:</p> <pre><code>public interface MyInterface&lt;T&gt; { Dictionary&lt;string, List&lt;T&gt;&gt; FilterLists { get; set; } } </code></pre>
10,859,098
0
why is php trim is not really remove all whitespace and line breaks? <p>I am grabbing input from a file with the following code</p> <pre><code>$jap= str_replace("\n","",addslashes(strtolower(trim(fgets($fh), " \t\n\r")))); </code></pre> <p>i had also previously tried these while troubleshooting</p> <pre><code>$jap= str_replace("\n","",addslashes(strtolower(trim(fgets($fh))))); $jap= addslashes(strtolower(trim(fgets($fh), " \t\n\r"))); </code></pre> <p>and if I echo $jap it looks fine, so later in the code, without any other alterations to $jap it is inserted into the DB, however i noticed a comparison test that checks if this jap is already in the DB returned false when i can plainly see that a seemingly exact same entry of jap is in the DB. So I copy the jap entry that was inserted right from phpmyadmin or from my site where the jap is displayed and paste into a notepad i notice that it paste like this... (this is an exact paste into the below quotes)</p> <p>" </p> <p>バスにのって、うみへ行きました"</p> <p>and obviously i need, it without that white space and breaks or whatever it is.</p> <p>so as far as I can tell the trim is not doing what it says it will do. or im missing something here. if so what is it?</p> <p>UPDATE: with regards to Jacks answer</p> <p>the preg_replace did not help but here is what i did, i used the bin2hex() to determine that the part that "is not the part i want" is efbbbf i did this by taking $jap into str replace and removing the japanese i am expecting to find, and what is left goes into the bin2hex. and the result was the above "efbbbf"</p> <pre><code>echo bin2hex(str_replace("どちらがあなたの本ですか","",$jap)); </code></pre> <p>output of the above was efbbbf but what is it? can i make a str_replace to remove this somehow?</p>
14,561,942
0
<p>You could use sets for that, but a <code>dict</code> can not be added to a set unfortunately. You need to 'cast' the dictionaries to something that a set <em>can</em> handle, e.g. a immutable type such as a sequence of tuples. Combine that with an index to return the referenced <code>dict</code>:</p> <pre><code>def magicFunction(a, b): a = [tuple(sorted(d.items())) for d in a] b = [tuple(sorted(d.items())) for d in b] return [dict(kvs) for kvs in set(a).difference(b)] </code></pre> <p>Result:</p> <pre><code>&gt;&gt;&gt; firstDict = [{'A':1 ,'B':1}, {'A':2 ,'B':2}] &gt;&gt;&gt; secondDict = [{'A':3 ,'B':3}, {'A':2 ,'B':2}] &gt;&gt;&gt; magicFunction(firstDict, secondDict) [{'A': 1, 'B': 1}] &gt;&gt;&gt; magicFunction(secondDict, firstDict) [{'A': 3, 'B': 3}] </code></pre>
27,043,560
0
My TYPO3 extension's plugin is not visible in the backend <p>I am new to TYPO3 , I started by creating my own extension using Extbase , the extension was successfully created and I could include it into the template of my site , now when I try to include its plugin to a page .. it's not there . I tried many times to delete the cache , and nothing changes ..</p> <p>The extension's folder as well as it's mysql table were created without any problem .. but this story of the plugin made me really unconfortable.</p> <p>Does any one know what could be the issue ? and I would also appreciate it if someone could give me a great tutorial on how to build your own TYPO3 extensions .</p> <p>Thank you so much</p> <p>Ps : I'm using TYPO3 6.2 </p>
10,179,303
0
Accessing matrices stored inside of cell arrays using MEX files in MATLAB <p>I am currently writing a MEX function that will have to work with a cell array in MATLAB. The MEX file is written in C. </p> <p>Essentially, the input to my function will be a cell array where each entry is a numeric matrix with real values. A simple example is:</p> <pre><code>C = cell(1,2); C{1} = ones(10,10); C{2} = zeros(10,4); </code></pre> <p>I would like to be able to access the numeric arrays C{1} and C{2} in my MEX file. Ideally, I would like to do this without having to create a second copy of the data in my MEX File (i.e. get pointers for them).</p> <p>Using the previous example, my current approach is as follows:</p> <pre><code>/* declare a pointer variable to the incoming cell array after it is passed to the MEX function */ mxArray C_CELL = (mxArray *) mxGetData(prhs[0]) /* declare a 2 x 1 array of pointers to access the cell array in C */ double *myarray[2] // /* point towards the contents of C_CELL */ myarray[0] = mxGetPr(C_CELL[0]) myarray[1] = mxGetPr(C_CELL[1]) </code></pre> <p>Unfortunately this seems to yield "invalid use of undefined type 'struct mxArray_tag'" errors.</p>
24,168,026
0
Visual Studio C++ Source file accessible despite no #include? <p>I tried searching for similar questions, but I found this difficult to phrase, so I apologize if this is a duplicate.</p> <p>I'm messing around with Visual Studio 2013, writing a pretty simple C++ Console Application. Without going into too much details, I have three files - file1.h, file2.cpp, and main.cpp</p> <ul> <li>file1.h contains the interface for a class</li> <li>file2.cpp includes file1.h and contains the class's member functions </li> <li>main.cpp includes file1.h</li> </ul> <p>So upon executing my program, I was very surprised that main.cpp had access to the functions inside file2.cpp, despite main only including file1.h.</p> <p>I don't think this is the best way to go about organizing the code, but it piqued my curiosity - how is it that I can access functions contained in file2.cpp from main.cpp, despite the fact that only file1.h is included in main.cpp?</p> <p>It would make sense to me if I had file2.cpp included in file1.h, but I don't.</p> <p><strong>I'm just curious how/why this works. Thanks for reading.</strong></p> <p>EDIT: If I've omitted any critical information, I apologize - just let me know and I can clarify.</p>
31,836,477
0
<p>The default Haar cascade trainings are:</p> <ul> <li>haarcascade_eye.xml</li> <li>haarcascade_eye_tree_eyeglasses.xml</li> <li>haarcascade_frontalcatface.xml</li> <li>haarcascade_frontalcatface_extended.xml</li> <li>haarcascade_frontalface_alt.xml</li> <li>haarcascade_frontalface_alt_tree.xml</li> <li>haarcascade_frontalface_alt2.xml</li> <li>haarcascade_frontalface_default.xml</li> <li>haarcascade_fullbody.xml</li> <li>haarcascade_lefteye_2splits.xml</li> <li>haarcascade_licence_plate_rus_16stages.xml</li> <li>haarcascade_lowerbody.xml</li> <li>haarcascade_profileface.xml</li> <li>haarcascade_righteye_2splits.xml</li> <li>haarcascade_russian_plate_number.xml</li> <li>haarcascade_smile.xml</li> <li>haarcascade_upperbody.xml</li> </ul> <p>If you need a custom one, you can train your own following <a href="http://docs.opencv.org/master/dc/d88/tutorial_traincascade.html" rel="nofollow">these instructions</a></p>
4,930,397
0
<p>Maybe mine is not the best answer, but i just trying to help you here.</p> <p>After doing a flash googling i found this site <a href="http://nixboxdesigns.com/demos/jquery-uploadprogress.php" rel="nofollow">http://nixboxdesigns.com/demos/jquery-uploadprogress.php</a> that look like promising to solve your problem. It can handle multiple upload and of course its do ajax upload too.</p> <p>My tips here is just try the demo <a href="http://nixboxdesigns.com/demos/jquery-uploadprogress-demo.php" rel="nofollow">http://nixboxdesigns.com/demos/jquery-uploadprogress-demo.php</a> first using all of your own browser. If the result is fine then work with this plugin maybe resolve your problem on browser compatibility.</p>
13,847,220
0
How can I create virtuals for REST API in Mongoose <p>I have a User model. And there is a follower relationship. </p> <p>What I want is, when client requests for followers of the user, I should return the followers, and append if the follower is followed by the current user. </p> <p>What is the good way to do that?</p>
37,250,670
0
<p>Here is a commented batch code for this task:</p> <pre><code>@echo off setlocal rem Define source and backup path. set "SourcePath=C:\machines\models" set "BackupPath=E:\backup" rem Get current date in format YYYY-MM-DD independent on local date format. for /F "skip=1 tokens=1 delims=." %%T in ('%SystemRoot%\System32\wbem\wmic.exe OS get localdatetime') do set LocalDateTime=%%T set "YearMonthDay=%LocalDateTime:~0,4%-%LocalDateTime:~4,2%-%LocalDateTime:~6,2% rem For each subfolder in source path check if there is a subfolder "defects". rem If subfolder "defects" exists, copy all files and subfolders of "defects" rem to the appropriate backup directory with current date and subfolder name rem in source folder path. Then remove the subfolder "defects" in source rem folder even if being completely empty to avoid processing this folder rem again when not being recreated again in the meantime. for /D %%# in ("%SourcePath%\*") do ( if exist "%%#\defects\*" ( %SystemRoot%\System32\xcopy.exe "%%#\defects\*" "%BackupPath%\%YearMonthDay%\%%~nx#_defects\" /H /I /K /Q /R /S /Y &gt;nul rd /Q /S "%%#\defects" ) ) endlocal </code></pre> <p>Run once in command prompt window <code>wmic OS get localdatetime</code> to see what this command outputs to understand better how the current date is determined in format <code>YYYY-MM-DD</code>. It would be faster to use <code>%DATE%</code>, but the format of date string of <code>%DATE%</code> depends on the country set in Windows region and language settings and therefore requires knowledge of date string format on computer running this batch file.</p> <p>The command <strong>XCOPY</strong> with the used options does not create the subfolder in backup directory if there is a <code>defects</code> subfolder in a <code>models</code> directory, but in entire <code>defects</code> subfolder tree there is not at least 1 file to copy.</p> <p>Alternate code using environment variable <strong>DATE</strong> with expecting that the expanded date string ends with: <code>MM/DD/YYYY</code>, e.g. <code>Tue 05/17/2016</code>, explained in detail in answer on:<br> <a href="http://stackoverflow.com/a/37236739/3074564">What does %date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2% mean?</a></p> <pre><code>@echo off setlocal rem Define source and backup path. set "SourcePath=C:\machines\models" set "BackupPath=E:\backup" rem Get current date in format YYYY-MM-DD depending on local date format. set "YearMonthDay=%DATE:~-4,4%-%DATE:~-10,2%-%DATE:~-7,2%" rem For each subfolder in source path check if there is a subfolder "defects". rem If subfolder "defects" exists, copy all files and subfolders of "defects" rem to the appropriate backup directory with current date and subfolder name rem in source folder path. Then remove the subfolder "defects" in source rem folder even if being completely empty to avoid processing this folder rem again when not being recreated again in the meantime. for /D %%# in ("%SourcePath%\*") do ( if exist "%%#\defects\*" ( %SystemRoot%\System32\xcopy.exe "%%#\defects\*" "%BackupPath%\%YearMonthDay%\%%~nx#_defects\" /H /I /K /Q /R /S /Y &gt;nul rd /Q /S "%%#\defects" ) ) endlocal </code></pre> <p>For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.</p> <ul> <li><code>echo /?</code></li> <li><code>endlocal /?</code></li> <li><code>for /?</code> ... explains also <code>%%~nx#</code> (name (and extension) of models subfolder).</li> <li><code>if /?</code></li> <li><code>rd /?</code></li> <li><code>set /?</code></li> <li><code>setlocal /?</code></li> <li><code>wmic.exe OS get /?</code></li> <li><code>xcopy /?</code></li> </ul> <p>See also the Microsoft article about <a href="https://technet.microsoft.com/en-us/library/bb490982.aspx" rel="nofollow">Using command redirection operators</a> to understand the meaning of <code>&gt;nul</code>.</p> <p>Why <code>%%~nx#</code> and not just <code>%%~n#</code> as a folder does not have a <em>file extension</em>?</p> <p>Windows command processor does not determine if a string is a folder or a file name. Everything after last backslash is interpreted as <em>file name</em> independent on being in real the name of a file or a folder. And everything after last dot after last backslash in string is interpreted as <em>file extension</em> even if this means that the folder or file name referenced with <code>%~n</code> is an empty string because the folder/file name starts with a dot and does not contain one more dot like many "hidden" files on *nix systems have, e.g. <code>.htaccess</code>. Therefore <code>%~nx</code> should be always used if entire name of a folder or file is needed on a command line.</p>
19,935,257
0
<p>On the link that you gave the joins are explained very good. So the problem is that you have several records from table A (no matter that there are no duplicates) is that to 1 record in A there are 2 records in B (in some cases). To avoid this you can use either <code>DISTINCT</code> clause, either <code>GROUP BY</code> clause.</p>
35,542,837
0
<p>You can get the size in bytes of your array using: <code>sizeof(array)</code>.</p>
38,695,098
0
<p>You shoud use <a href="https://github.com/romgar/django-dirtyfields" rel="nofollow">django-dirtyfields</a> and send email immediately or add this job_id to RQ. Full docs <a href="http://django-dirtyfields.readthedocs.io/en/develop/" rel="nofollow">here</a></p> <p>Or update <code>updated_at</code> field only when <code>status</code> changes (again django-dirtyfields) by write own save() method like.</p> <pre><code>def save(self): if self.status = 'aproved' and 'status' in self.get_dirty_fields(): # add to RQ # or set updated_at = datetime.now() # if you dont use on_update=datetime.now super(...).save() </code></pre>
39,893,312
0
<p>Try marking the <code>@ManyToOne</code> field as lazy: </p> <pre><code>@ManyToOne(fetch = FetchType.LAZY) private Account account; </code></pre> <p>And change your query using a <code>JOIN FETCH</code> of the <code>account</code> field to generate only one query with all you need, like this:</p> <pre><code>String sql = "SELECT new com.test.Pojo(acc, SUM(t.value)) " + "FROM Transaction t JOIN FETCH t.account acc GROUP BY acc"; </code></pre> <p><strong>UPDATE:</strong></p> <p>Sorry, you're right, the fetch attribute of <code>@ManyToOne</code> is not required because in Hibernate that is the default value. The <code>JOIN FETCH</code> isn't working, it's causing a <code>QueryException</code>: "Query specified join fetching, but the owner of the fetched association was not present".</p> <p>I have tried with some other approaches, the most simple one that avoids doing n + 1 queries is to remove the creation of the <code>Pojo</code> object from your query and process the result list, manually creating the objects:</p> <pre><code>String hql = "SELECT acc, SUM(t.value)" + " FROM " + Transaction.class.getName() + " t" + " JOIN t.account acc" + " GROUP BY acc"; Query query = getEntityManager().createQuery(hql); List&lt;Pojo&gt; pojoList = new ArrayList&lt;&gt;(); List&lt;Object[]&gt; list = query.getResultList(); for (Object[] result : list) pojoList.add(new Pojo((Account)result[0], (BigDecimal)result[1])); </code></pre>
1,709,440
0
<p>The most efficient way probably is to create a completely random array order and cache that for every user.</p> <p>Except for the MySQL sollution postet above, you may use php in a very similar style: You can use the session id as a start for the random number generator and than shuffle the array using that "random" number. By doing that, every user recieves a differently sorted list, whenever he requests your site (at least as long as the session does not expire).</p> <pre><code>&lt;?php $array = array("Cat", "Dog", "Mouse"); session_start(); $session_id_int = (int)session_id(); srand($session_id_int); echo '&lt;pre&gt;BEFORE:'.PHP_EOL; print_r($array); shuffle($array); echo 'AFTER:'.PHP_EOL; print_r($array); </code></pre>
4,689,977
0
<p>Just assuming: did you put a <code>;</code> at the end of the <code>#define</code> ? Remove that, it will be put where you use <code>MAXZOOM</code>. </p> <p>So instead of</p> <pre><code>#define MAXZOOM 2.0f; </code></pre> <p>make it</p> <pre><code>#define MAXZOOM 2.0f </code></pre>
37,011,075
0
<blockquote> <pre><code>$bucket-&gt;bootstrap(3); </code></pre> </blockquote> <p><a href="http://bandwidth-throttle.github.io/token-bucket/api/class-bandwidthThrottle.tokenBucket.TokenBucket.html#_bootstrap" rel="nofollow"><code>TokenBucket::bootstrap(3)</code></a> puts three initial tokens into the bucket. Those initial tokens can be consumed instantly. You effectively don't throttle the rate for those first calls.</p> <p>If you don't want that initial burst, you did correctly bootstrap without any tokens.</p> <blockquote> <pre><code>03.05.2016 14:33:34.913 03.05.2016 14:33:35.245 03.05.2016 14:33:35.578 03.05.2016 14:33:35.911 </code></pre> <p>but it is still more than 3 per second.</p> </blockquote> <p>I count 3 per second. Please tolerate this observed variance of ±1ms. In the long run you'll get in average 3 per second.</p> <p>This ±1ms comes probably from <a href="https://github.com/bandwidth-throttle/token-bucket/blob/0.4/classes/BlockingConsumer.php#L56" rel="nofollow">this implementation detail</a> of <code>BlockingConsumer</code>:</p> <pre><code>// sleep at least 1 millisecond. usleep(max(1000, $seconds * 1000000)); </code></pre>