2018-10-22         Horace

Swing HTML rendering changing when using BufferedImage

The behaviour of labels containing HTML seems to change when they are first painted to a BufferedImage. In the code that follows, only the first two lines of the text are displayed. The number of lines increases as more <br> breaks are added. It seems to be calculating the number of lines pre-wrapping rather than post-wrapping.If the label is painted directly to the component's graphic (i.e. the commented line) then it works fine.Why would the behaviour change if it's painted to a BufferedImage's graphic rather than a JComponent's.public class HTMLFormatting { publ...

 java                     1 answers                     42 view
 2018-10-22         Horace

twitter-bootstrap js to toggle all collapse for all elements of a common class

I have a bunch of elements (code-blocks) I'd like to be able to collapse using twitter-bootstrap's javascript, such assome text<div class="highlight">code code</div>some more text text <div class="highlight">code code</div>I can add the following javascript to make all of these elements collapse:$('highlight').collapse({ toggle: true})Now I'd like to add a button to toggle the collapse/show for these elements. Any ideas?Solution requirementsI'm looking for a solution that extends but doesn't have to change the original html with the code blocks. F...

 javascript                     1 answers                     98 view
 2018-10-22         Horace

Why does the pop up disappear upon check box click event?

I have used panel inside template field and it disappears when I check a checkbox.I tried fixing it but still disappears. The code works good while debugging but apparently not. Please help if you can. I have spent a lot of time on it already. <asp:TemplateField HeaderText='Finalized ?'> <ItemTemplate> <asp:LinkButton ID="btnFinalizedRecord" OnClick="btnFinalizedRecord_Click" runat="server" Text='<%# Convert.ToBoolean(Eval("IsFinalized")) == true? "Already Finalized": "Finalize" %>' CssClass="" ToolTip="Finalize" Comman...

 c#                     1 answers                     74 view
 2018-10-22         Horace

Multiple timers with different delays > mutliple events on complete?

I use several timers with different delays at once. Unfortunately, the timer class is not documented.What's the best solution, to fire specific events on TimerEvent.TIMER_COMPLETE?var _timer:Object = new Timer(_myVAR*1000,1);_timer.addEventListener(TimerEvent.TIMER_COMPLETE, eventTimerHandler);_timer.start();...private function eventTimerHandler(event:TimerEvent):void{ event.target.removeEventListener(TimerEvent.TIMER_COMPLETE, eventTimerHandler); event.target.reset(); event.target.stop(); // Fire specific event} You can create a custom Timer class by extending Timer...

 actionscript-3                     1 answers                     39 view
 2018-10-22         Horace

Rails 4 not executing $(document).ready(ready); function

SOLUTIONI had both a users.js and users.coffee in my asset pipeline. Apparently users.coffee was preventing users.js from being loaded. Make sure you delete it!I'm trying to implement this -- github repo here. There are two JS files that are required to start chats -- chat.js and users.js. Both include $(document).ready(ready); functions. Only I can only get Rails to execute chat.jsI have confirmed by adding a console.log("confirm"); just inside both functions like so...var ready = function () { console.log("success") ...I've tried both of these...$(document).on("page:load...

 javascript                     1 answers                     1 view
 2018-10-22         Horace

Showing paypal transaction details after payment

After a succesful payment using Paypal in my web site, the browser only shows an alert:// Execute the payment onAuthorize: function (data, actions) { return actions.payment.execute() .then(function () { // Show a confirmation message to the buyer window.alert('Compra realizada con éxito. Recibirá más detalles por email!'); }); }I am using now the sandbox option, but I would know how to give the user more details about the transaction.I see there is a 'data' param in the function, are there the transaction details? If yes, how can I read them to ...

 javascript                     2 answers                     93 view
 2018-10-22         Horace

get a batch file to tell me how many line are in a csv file

I have a batch file that I am using for a toad automation. the batch file should be simple enough but it isn't liking the if statuement for some off reason I even tried the GTR example but sadly nothing all I get on the if statement is that the syntax is incorrect and do not know why. @Echo off Set _File=ExportDiffFile.csv Set /a _Lines=0 For /f %%j in ('Find "" /v /c ^< %_File%') Do Set /a _Lines=%%j REM Echo %_File% has %_Lines% lines. if "%_Lines%"=="1"( Echo %_File% has no new lines. Echo 100. REM exit 100 ) else ( ...

 batch-file                     1 answers                     10 view
 2018-10-22         Horace

Express JWT Error: Not enough or too many segments in socket.io initial auth

During the initial handshake where a token and username are passed, I am catching this strange error-- { handle: 10, type: 'error', className: 'Error', constructorFunction: { ref: 11 }, protoObject: { ref: 12 }, prototypeObject: { ref: 3 }, properties: [ { name: 'stack', attributes: 2, propertyType: 3, ref: 3 }, { name: 'arguments', attributes: 2, propertyType: 1, ref: 3 }, { name: 'type', attributes: 2, propertyType: 1, ref: 3 }, { na...

 javascript                     4 answers                     0 view
 2018-10-22         Horace

Django REST Framework - Social Authentication (Facebook, Twitter, etc.)

I'm building REST APIs for a platform where we have iOS, Android and Web apps as clients. Users can register normally via the Django APIs, so authenticate using their credentials or they can sign in to their Facebook or Twitter account using OAuth.I started using django-rest-framework-social-oauth2 to speed up the development of the social login part.The part that I don't understand is related to the URL callback (or URL redirect) pointing back to the server-side Django app.What URL callback should I provide? Is there already an implemented view out-of-the-box from django-r...

 django                     1 answers                     37 view
 2018-10-22         Horace

Find out if asked for a password when looping over hosts using subprocess.Popen

I am looping over a number of hosts (about 400) to get some information from the systems. most of them have ssh keys so no problem there. Only a handful don't have ssh keys and come back with a password. Now I want to detect when I'm asked for a password, kill the ssh process and continue to the next host.here's the code for the ssh partdef get_os_info(hostname, command, user=None):remote = "%s" % hostname if user is None else "%s@%s" %(user, hostname)ssh = subprocess.Popen(["ssh", remote, command], shell=False, stdout=subprocess....

 python                     1 answers                     83 view
 2018-10-22         Horace

python selenium how to get certain text

Is this possible in selenium, I think it's possible in urllib but I'm not sure.if "@gmail.com" in html:print the string that includes the @gmail ex: it will find @gmail.com, then it will print the string that is >connected too it stackoverflow@gmail.com Yes this is possible. You can request the entire HTML of a page using page_source. Then you can check if @gmail.com is in this page_source.source = driver.page_sourcedomain = '@gmail.com'if domain in source: # Cut off the string behind @gmail.com (the mail is now the last word in the string) sub = source[:source.fi...

 python                     2 answers                     90 view
 2018-10-22         Horace

Jion two tables to new a table

I want to join table-a and table-b create a table-cPlease see the screenshot. My sql is postgresqlHow can I do this? This is a simple join with a coalesce:select a.ID, coalesce(a.email,b.email) as emailfrom tableA ajoin tableB b on b.ID=a.IDThis assumes that the IDs exist in both tables which from your example they do. [XXX]You can use the COALESCE function like so:select a.id, coalesce(a.email, b.email) emailfrom table_a a, table_b bwhere a.id = b.id;Here's a link to a SQL Fiddle with a working example: http://sqlfiddle.com/#!17/14f12d/7 [XXX]

 sql                     2 answers                     53 view
 2018-10-22         Horace

Select specific cells from multiple spreadsheets into SQL using SSIS

I need to loop through a series of spreadsheets (all in the same folder), pulling data from the same cells within the same named range in each, into an existing SQL database, using SSIS (SQL Server 2008 R2).I started by using the information in How to loop through Excel files and load them into a database using SSIS package? as a point of reference.However, because my files don't run in a strict columnar format (i.e. the whole of column C plus the whole of column E, etc.), I am struggling with it.My sheet is as follows:Basically, the area outlined in red (A6:E11) will be th...

 sql-server-2008                     1 answers                     30 view
 2018-10-22         Horace

Python utf8 codec can't decode byte 0x80 in position 103:invalid start byte

Here is my code and sample of my csv file and after I run the code, the error shows up utf8 codec can't decode byte 0x80 in position 103:invalid start byteand if anyone could helpimport csvimport pandas as pdimport numpy as npimport osimport sysh = pd.read_csv('C:/Users/Desktop/Result.csv')sentences = h['Mention']def check_it(sentences): if 'camera' in sentences: return "Camera" if 'Camera' in sentences: return "Camera" if 'display' in sentences: return "Display" if 'Display' in sentences: return "Display" if 'battery' in sentence...

 python                     1 answers                     56 view
 2018-10-22         Horace

Getting datetime data into the correct format arcpy python arcmap

I am using datetime in Arcpy to convert a "Sample Date" field in a feature class to the day of the year. The date in the field is in a month/day/year format and it doesn't include any leading zeros (ex. 7/8/2018 instead of 07/08/2018). Whenever I try running the following line of code,dtm = datetime.datetime.strptime(row, '%Y/%m/%d %H:%M')I get the following error:ValueError: time data '[datetime.datetime(2003, 6, 3, 0, 0)]' does not match format '%Y/%m/%d %H:%M' The sample date field that I am using does not include any time data which I believe is where the two zeros at...

 python                     1 answers                     35 view
 2018-10-22         Horace

Specify pyspark dataframe schema with string longer than 256

I'm reading a source that got descriptions longer then 256 chars. I want to write them to Redshift.According to: https://github.com/databricks/spark-redshift#configuring-the-maximum-size-of-string-columns it is only possible in Scala.According to this: https://github.com/databricks/spark-redshift/issues/137#issuecomment-165904691it should be a workaround to specify the schema when creating the dataframe. I'm not able to get it to work.How can I specify the schema with varchar(max)?df = ...from sourceschema = StructType([ StructField('field1', StringType(), True), Stru...

 apache-spark                     1 answers                     10 view

Page 1 of 145  |  Show More Pages:  Top Prev Next Last