title
stringlengths 10
150
| body
stringlengths 17
64.2k
| label
int64 0
3
|
---|---|---|
How to give a variable path for GetFolder in VBScript? | <p>This script basically goes to a folder and list all the files in that folder and output it in a txt file. Now instead of defining the folder path I want it to use the txt file that contains a bunch of folder paths in it and I want to loop that txt file. How can I do this?</p>
<pre><code>Dim fso
Dim ObjFolder
Dim ObjOutFile
Dim ObjFiles
Dim ObjFile
'Creating File System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Getting the Folder Object
Set ObjFolder = fso.GetFolder("C:\Users\Susan\Desktop\Anime\ova")
'Creating an Output File to write the File Names
Set ObjOutFile = fso.CreateTextFile("C:\Users\Susan\Documents\iMacros\Macros\WindowsFiles.txt")
'Getting the list of Files
Set ObjFiles = ObjFolder.Files
'Writing Name and Path of each File to Output File
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine(ObjFile.Path)
Next
ObjOutFile.Close
</code></pre> | 0 |
Force update of an Android app when a new version is available | <p>I have an app in Google Play Store. When an update version is available, the older version will become unusable – that is, if users do not update the app, they do not enter in the app. How can I force users to update the app when a new version becomes available?</p> | 0 |
How to play Youtube videos using Video.js? | <p>Is there a way to play Youtube videos using video.js? I followed the steps <a href="https://github.com/videojs/video.js/blob/94c07756dc1c3d301f25dd2ca54317335f6d4feb/docs/tech.md" rel="nofollow">here</a>
but can't seem to make it work. Please help! Thanks a lot!</p> | 0 |
Python AssertionError | <p>When I check the ISBN(DIGIT) with my code : check_digit_13(2000003294107)</p>
<pre><code>def check_digit_13(isbn):
assert len(isbn) == 12
sum = 0
for i in range(len(isbn)):
c = int(isbn[i])
if i % 2: w = 3
else: w = 1
sum += w * c
r = 10 - (sum % 10)
if r == 10: return '0'
else: return str(r)
</code></pre>
<p>The Error :</p>
<pre><code>Traceback (most recent call last):
File "parser.py", line 16, in <module>
lk.run(document)
File "/data/www/crons/lk/parser.py", line 33, in run
field = lkmapper.all(row, document)
File "/data/www/crons/mappers/lk.py", line 5, in all
print isbn.check_digit_13(field[0])
File "/data/www/crons/libs/isbn.py", line 13, in check_digit_13
assert len(isbn) == 12
AssertionError
</code></pre> | 0 |
Send two argument using map and lambda functions and return two values | <p>I would like to send two arguments within a function and receive two values as well </p>
<p>I want to modify this code so that I code be able to send two arguments and receive two as well</p>
<pre><code>list_value = [ 1, 2,0,-1,-9,2,3,5,4,6,7,8,9,0,1,50]
hnd = map(lambda (valua): function_f(valua), list_value)
</code></pre>
<p>function_f is a function return one number either 1 or 0.</p>
<p>The above code can do the job when sending one argument but I want to send two instead of.
the first argument of the required function is list_value and the second argument is a model "net model train it using caffe"</p>
<p>so I would like to write a function that can do the same job of the previous function but returning two arguments one is [0 or 1] and the other is a modified model which this function has modified.</p> | 0 |
What will happen to the SharedPreferences on update an Android App? | <p>I've stored user settings in the SharedPreferences in my App. What will happen with the SharedPreferences when I update the App via Google Play Store to a new version of the App?</p>
<p>Will the SharedPrefernces still be there after the update or will they be deleted?</p>
<p>So far I haven't found an answer on the web or Stackoverflow.</p>
<p>Can you point me to some links they describe this process?</p>
<p><strong>Edit:</strong>
Meanwhile I found an other answer as well: <a href="https://stackoverflow.com/questions/7103453/sharedpreferences-update-unisntall">SharedPreferences behaviour on Update/Uninstall</a></p>
<p><strong>Edit 2:</strong>
Time past quite a bit when I first asked this question I recently learned that since Android 6.0 (API 23) it is also possible to use the auto backup functionality to <em>store</em> your shared preferences as described by <a href="https://developer.android.com/guide/topics/data/autobackup.html#EnablingAutoBackup" rel="nofollow noreferrer">Google here</a>.</p>
<p>Just add the <code><application android:allowBackup="true" ... > </code> in your <code>AndroidManifest.xml</code> file.</p> | 0 |
python- constant dictionary? | <p>I simply generate a list of python dictionaries, and then serialize it to json.<br>
Basically my code is a loop where I do something like: </p>
<pre><code>ls.append({..values..})
</code></pre>
<p>I don't change the dictionaries after this. </p>
<p>The question, is there a constant dictionary in python, obviously the point here is memory, since I know dictionary takes more memory than a list. I simply need the structure of <code>{key:value}</code> for json, not the other features of the dictionary.</p>
<p>Just curious if I can optimize my code a bit.</p> | 0 |
In django do models have a default timestamp field? | <p>In django - is there a default timestamp field for all objects? That is, do I have to explicitly declare a 'timestamp' field for 'created on' in my Model - or is there a way to get this automagically?</p> | 0 |
How can I open files externally in Emacs dired mode? | <p>I want to open a pdf with evince instead of DocView mode. Is there a possibility to open a file with a specific command like 'evince'?</p> | 0 |
COLLECT_SET() in Hive, keep duplicates? | <p>Is there a way to keep the duplicates in a collected set in Hive, or simulate the sort of aggregate collection that Hive provides using some other method? I want to aggregate all of the items in a column that have the same key into an array, with duplicates.</p>
<p>I.E.:</p>
<pre><code>hash_id | num_of_cats
=====================
ad3jkfk 4
ad3jkfk 4
ad3jkfk 2
fkjh43f 1
fkjh43f 8
fkjh43f 8
rjkhd93 7
rjkhd93 4
rjkhd93 7
</code></pre>
<p>should return:</p>
<pre><code>hash_agg | cats_aggregate
===========================
ad3jkfk Array<int>(4,4,2)
fkjh43f Array<int>(1,8,8)
rjkhd93 Array<int>(7,4,7)
</code></pre> | 0 |
how to parse json array using Litjson? | <p>I am developing an application in which i am using data came from server in the json format.
However i am able to parse normal json data but failed to parse the json data with arrays,</p>
<p>the json response is given below,</p>
<pre><code>[{"id_user":"80","services":
[{"idservice":"3","title":"dni-e","message":"Texto para el dni-e"},
{"idservice":"4","title":"Tarjeta azul","message":"Texto para la tarjeta azul"}]
}]
</code></pre>
<p>how can i read this json array?</p>
<p><strong>Note</strong>:I am using Litjson for parsing.</p> | 0 |
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'stringi' | <p>When I use</p>
<pre><code>library(Hmisc)
</code></pre>
<p>I get the following error</p>
<pre><code> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'stringi'
Error: package 'ggplot2' could not be loaded
</code></pre>
<p>As well, if I use </p>
<pre><code>library(ggplot2)
</code></pre>
<p>I get the following error</p>
<pre><code> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'stringi'
Error: package or namespace load failed for 'ggplot2'
</code></pre>
<p>I've tryed to install 'stringi'
install.packages("stringi")</p>
<p>But at some point, during the installation, I get the following error message:</p>
<pre><code> configure: error: in `/private/var/folders/pr/wdr5dvjj24bb4wwnjpg1hndc0000gr/T/RtmpeQ5pXk/R.INSTALL10b94a012cab/stringi':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
ERROR: configuration failed for package 'stringi'
* removing '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/stringi'
</code></pre>
<p>I'm using RStudio (Version 0.99.447) and I have R version 3.2.1.</p> | 0 |
How to save image path into database in Laravel? | <p>I want to upload an image and retrieve in from database when i need this.My code is perfectly working to upload image but it's path did not save in database.In database it's showing <code>Null</code>.Here is my code:</p>
<pre><code> if ($request->hasFile('profilePic')) {
$file = array('profilePic' => Input::file('profilePic'));
$destinationPath = 'img/'; // upload path
$extension = Input::file('profilePic')->getClientOriginalExtension();
$fileName = rand(11111,99999).'.'.$extension; // renaming image
Input::file('profilePic')->move($destinationPath, $fileName);
}else{
echo "Please Upload Your Profile Image!";
}
$profile->save();
</code></pre>
<p><strong>My Question:</strong> </p>
<ul>
<li>How to save image path into database? </li>
<li>And how to retrieve image from database?</li>
</ul>
<p><strong>Updated: Profile.php</strong></p>
<pre><code>class Profile extends Model
{
protected $table = "profiles";
public $fillable = ["firstName","lastName","middleName","DOB","gender","featuredProfile","email","phone","summary","profilePic"];
}
</code></pre> | 0 |
jquery change background color user scroll | <p>Is it possible with jquery that when a user scrolls down the page that the background animate from 50% white to 90% white or someting?</p>
<p>So first it is the color <code>rgba(255,255,255,.5)</code> and when a user scroll 210px below the color <code>become rgba(255,255,255,.9)</code>.</p> | 0 |
CSS Text Align Bottom of Container | <p>I have a header which has a large image floated on one side, and a small paragraph of text on the other side. I want the paragraph to start at the bottom of the header div. If there were 5 lines in the paragraph, I want the last line to be at the bottom of the header. I'm having trouble getting the paragraph to align itself down there.</p>
<p>I have something like this:</p>
<pre class="lang-html prettyprint-override"><code><div id='header'>
<img id='logo' />
<p id='quote'></p>
</div>
</code></pre>
<p>And the CSS is:</p>
<pre class="lang-css prettyprint-override"><code>div#header {
height: 200px;
}
div#header img#logo {
float: left;
}
p#quote {
float: left;
}
</code></pre> | 0 |
How create a batch file that opens a 32bit cmd prompt as Admin to run another batch file | <p>I have a batch file that I currently have to do the following to run:</p>
<ol>
<li>Open SYSWOW64\cmd.exe as admininstrator (it's a 32bit application)</li>
<li>cd c:\mybatchfilelocation\</li>
<li>then run my batch file batchfile.bat</li>
</ol>
<p>I'd like to just be able to run one batch as admin that automatically opens the SYSWOW64\cmd.exe as administrator (prompting for admin username and password is ok) and then have that run my batchfile.bat</p>
<p>I've seen where you can do it if you pre-specify the /user:machinename\administor in the batch file before running it and it only prompts for password but this needs to be deployed to customers and I can't rely on them editing the file. I need it to run with prompts when input is required by them.</p>
<p><strong>UPDATE</strong></p>
<p>Thanks to Bill, I no longer need to worry about the SYSWOW64 part. I only need to be able to figure out how to have a batch file open a cmd prompt as an administrator and have that cmd run another batch file in that same directory.</p> | 0 |
restore_best_weights issue keras early stopping | <p>I am using EarlyStopping from Keras for my deep learning project. The documentations <a href="https://keras.io/callbacks/#earlystopping" rel="noreferrer">here</a> mentions a very useful idea of restoring best weights. But somehow I am not able to use it yet. I am using Keras 2.2.2/TF 1.10, installed using Anaconda.
Call is simple as follows. is there any issue? </p>
<pre><code>es = EarlyStopping(monitor='val_acc', min_delta=1e-4, patience=patience_,verbose=1,restore_best_weights=True)
</code></pre>
<blockquote>
<p><code>__init__()</code> got an unexpected keyword argument 'restore_best_weights'</p>
</blockquote> | 0 |
Problems with Chinese Fonts in iText-PDF on Windows Machines | <p>I'm using a Ubuntu-PC to create PDFs with iText which are partly in Chinese. To read them I use Evince. So far there were hardly any problems</p>
<p>On my PC I tried the following three BaseFonts and they worked with success:</p>
<pre><code>bf = BaseFont.createFont("MSungStd-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED);
bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
bf = BaseFont.createFont("MSung-Light","UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED);
</code></pre>
<p>Unfortunately in the moment the final PDF is opened on Windows with the Acrobat-Reader the document can't be displayed correctly any more.</p>
<p>After I googled the Fonts to get a solution I came to that Forum where the problem is explained in an understandable way (Here MSung-Light was used): <a href="http://community.jaspersoft.com/questions/531457/chinese-font-cannot-be-seen" rel="nofollow">http://community.jaspersoft.com/questions/531457/chinese-font-cannot-be-seen</a></p>
<blockquote>
<p>You are using a built-in Chinese font in PDF. I'm not sure about the
ability of this font to support both English and Chinese, or mixed
language anyway.</p>
<p>The advantage of using an Acrobat Reader built-in font is that it
produces smaller PDF files, because it relies on those fonts being
available on the client machine that display the PDF, through the
pre-installed Acribat Asian Font Pack.</p>
<p>However, using the PDF built-in fonts has some disadvantages that were
discovered through testing on different machines, when we investegated
a similar problem related to a built-in Korean font.</p>
</blockquote>
<p>What should I do about it?
It's not so important to be able to copy the Chinese letters. Can iText convert a paragraph to an image? Or are there any better solutions?</p> | 0 |
Binary file in npm package | <p>I try to create an npm package, which can be started as a command from shell. I have <code>package.json</code></p>
<pre><code>{
"name": "myapp",
"version": "0.0.6",
"dependencies": {
"async": "",
"watch": "",
"node-promise": "",
"rmdir": "",
"should": "",
"websocket": ""
},
"bin": "myapp"
}
</code></pre>
<p>and <code>myapp</code></p>
<pre><code>#!/bin/bash
path=`dirname "$0"`
file="/myapp.js"
node $path$file $1 &
</code></pre>
<p>But I get an error:</p>
<pre><code>module.js:340
throw err;
^
Error: Cannot find module '/usr/local/bin/myapp.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
</code></pre>
<p>The problem is that myapp.js is in another directory. How can I get this directory name from my script? Or maybe there is better way to do this?</p> | 0 |
Datatables export buttons not showing, | <p>I want to export the Data from data table, I've tried everything I could, I've read All the questions and answers of stackoverflow and the documentation about those buttons issues till the google's second page, </p>
<p>I'm sure I've referenced all The required javascript's cdn and CSS as required, No error in console, But still The export buttons are not showing, Here is how I initialized DataTable,</p>
<pre><code>table.DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"columnDefs": [{
"defaultContent": "-",
"targets": "_all"
}],
bFilter: false, bInfo: false,
"bDestroy": true
});
</code></pre>
<p>All the functions of Datatable that were required are working fine except the export buttons not showing up, My last hope is left on this question, Please help me.</p> | 0 |
What should I pass for the WWW-Authenticate header on 401s if I'm only using OpenID? | <p>The HTTP spec states:</p>
<blockquote>
<p><strong>10.4.2 401 Unauthorized</strong></p>
<p>The request requires user authentication. The response MUST include a WWW-Authenticate
header field (section 14.47) containing a challenge applicable to the requested resource. </p>
</blockquote>
<p>If the only login scheme I support is OpenID (or CAS, or OAuth tokens, &c.), what should I put in this field? That is, how do I indicate that the client needs to <em>pre-authenticate</em> and create a session rather than try to send credentials along with each request?</p>
<p>Before you answer, "don't send a 401; send a 3xx redirecting to the OpenID login page," what about for non-HTML clients? How, for example, would Stack Overflow do an API that my custom software could interact with?</p> | 0 |
Import DBF files into Sql Server | <p>I need a little help figuring this out because I'm new to stored procedures. I am trying to import a .DBF table into Sql Server 2008 using this store procedure.</p>
<pre><code>CREATE PROCEDURE spImportDB
-- Add the parameters for the stored procedure here
AS
BEGIN
-- Insert statements for procedure here
SELECT * into Products
FROM OPENROWSET('vfpoledb','C:\Users\Admin\Doc\Data\DBF',
'SELECT * FROM MyTable')
END
GO
</code></pre>
<p>I receive this error.
The OLE DB provider "vfpoledb" has not been registered.This isn't true, I've installed it and it works fine in my other application.</p>
<p>I've also tried running it this way with this provider but I receive this error message
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)". </p>
<pre><code>CREATE PROCEDURE spImportDB
-- Add the parameters for the stored procedure here
AS
BEGIN
-- Insert statements for procedure here
SELECT * into Products
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','C:\Users\Admin\Doc\Data\DBF',
'SELECT * FROM MyTable')
END
GO
</code></pre>
<p>What's the easiest way to create this stored procedure? I want it to be a stored procedure not a wizard or program so please don't give me any programs.</p> | 0 |
How do I convert a file's format from Unicode to ASCII using Python? | <p>I use a 3rd party tool that outputs a file in Unicode format. However, I prefer it to be in ASCII. The tool does not have settings to change the file format.</p>
<p>What is the best way to convert the entire file format using Python?</p> | 0 |
Compare object instances for equality by their attributes | <p>I have a class <code>MyClass</code>, which contains two member variables <code>foo</code> and <code>bar</code>:</p>
<pre><code>class MyClass:
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
</code></pre>
<p>I have two instances of this class, each of which has identical values for <code>foo</code> and <code>bar</code>:</p>
<pre><code>x = MyClass('foo', 'bar')
y = MyClass('foo', 'bar')
</code></pre>
<p>However, when I compare them for equality, Python returns <code>False</code>:</p>
<pre><code>>>> x == y
False
</code></pre>
<p>How can I make python consider these two objects equal?</p> | 0 |
Detect in Javascript when HTML5 <video> loop restarts? | <p>I have a looping HTML5 video using <code><video loop="true"></code>, and I want to know when the video loops. The event listener <code>play</code> only fires when the video is started initially, and <code>ended</code> never fires. </p>
<p>The imprecise nature of <code>timeupdate</code> makes me nervous using <code>if ( v.currentTime <= 0 )</code>, but it does seem to work. Is there a better way to detect when the video restarts?</p>
<p>Here's my basic setup:</p>
<pre><code><video autoplay="true" loop="true" muted="true">
<source src="vidoe.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
<source src="video.ogv" type="video/ogg">
</video>
<div id="Video-Time"></div>
<script>
var v = document.getElementsByTagName('video')[0]
var t = document.getElementById('Video-Time');
v.addEventListener('timeupdate',function(event){
t.innerHTML = v.currentTime;
if ( v.currentTime <= 0 ) { console.log("Beginning!"); } // It does trigger when looping, surprisingly
},false);
v.addEventListener('play', function () {
console.log("play!"); // Only triggered when the video initially starts playing, not when the loop restarts
},false);
v.addEventListener('ended', function () {
console.log("ended!"); // Never triggered
},false);
</script>
</code></pre> | 0 |
send JSON to server via HTTP put request in android | <p>How to wrap given json to string and send it to server via Http put request in android?</p>
<p>This is how my json look like. </p>
<pre><code> {
"version": "1.0.0",
"datastreams": [
{
"id": "example",
"current_value": "333"
},
{
"id": "key",
"current_value": "value"
},
{
"id": "datastream",
"current_value": "1337"
}
]
}
</code></pre>
<p>above is my json array.</p>
<p>below is how I wrote the code but, its not working</p>
<pre><code> protected String doInBackground(Void... params) {
String text = null;
try {
JSONObject child1 = new JSONObject();
try{
child1.put("id", "LED");
child1.put("current_value", "0");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONArray jsonArray = new JSONArray();
jsonArray.put(child1);
JSONObject datastreams = new JSONObject();
datastreams.put("datastreams", jsonArray);
JSONObject version = new JSONObject();
version.put("version", "1.0.0");
version.put("version", datastreams);
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPut put = new HttpPut("url");
put.addHeader("X-Apikey","");
StringEntity se = new StringEntity( version.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
put.addHeader("Accept", "application/json");
put.addHeader("Content-type", "application/json");
put.setEntity(se);
try{
HttpResponse response = httpClient.execute(put, localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
}
catch (Exception e) {
return e.getLocalizedMessage();
}
}catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return text;
}
</code></pre>
<p>please help on this </p> | 0 |
Kotlin sequence concatenation | <pre><code>val seq1 = sequenceOf(1, 2, 3)
val seq2 = sequenceOf(5, 6, 7)
sequenceOf(seq1, seq2).flatten().forEach { ... }
</code></pre>
<p>That's how I'm doing sequence concatenation but I'm worrying that it's actually copying elements, whereas all I need is an iterator that uses elements from the iterables (seq1, seq2) I gave it.</p>
<p>Is there such a function?</p> | 0 |
How to use Spring Data JPA Repository to query from 2 tables? | <p>I have 2 tables say Student and Teacher and say Student has a Many-To-One relationship to Teacher and say, teacherId serves as the foreign key.</p>
<p>How can I use spring data JPA repo methods, in a way - <code>findByTeacherName</code>, if I want to query something like below,</p>
<pre><code>select * from Student S, Teacher T
where T.teacherName = 'SACHIN' and S.teacherId = T.teacherId
</code></pre>
<p>Note : Here I wanna query using only <code>StudentRepository</code>, which is created using <code>StudentHibernateMapping</code> class that has a relationship to <code>TeacherHibernateMapping</code> class</p>
<p>Any help will greatly be appreciated.</p> | 0 |
CS0120: An object reference is required | <p>Getting this error when I submit my form to savetext.aspx action file:</p>
<pre><code>Compiler Error Message: CS0120: An object reference is required for the nonstatic field, method, or property 'System.Web.UI.Page.Request.get'
</code></pre>
<p>On this line:</p>
<pre><code>string path = "/txtfiles/" + Request.Form["file_name"];
</code></pre>
<p>Whole code:</p>
<pre><code><%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
class Test
{
public static void Main()
{
string path = "/txtfiles/" + Request.Form["file_name"];
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(request.form["seatsArray"]);
sw.WriteLine("");
}
}
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
}
</script>
</code></pre>
<p>How do I fix it?</p>
<p>Thanks!</p> | 0 |
How to always visible scroller of Tableview in Obj c? | <p>I want to show user there is a more content below but UITableView only shows scroll indicator when we scroll the tableview. There is any way, so I can show scroll indicator always</p> | 0 |
Vertical/Column text select in PyCharm? | <p>Is it possible to select text vertically/in a column in PyCharm? You can do it in Visual Studio and Notepad++ by holding down alt+arrow keys.</p>
<p>The documentation describes how to do it with the mouse, but there's no mention of keyboard options.</p>
<p><a href="http://www.jetbrains.com/pycharm/webhelp/selecting-text-in-the-editor.html#d306531e464" rel="noreferrer">http://www.jetbrains.com/pycharm/webhelp/selecting-text-in-the-editor.html#d306531e464</a></p> | 0 |
Cross Domain Web Worker? | <p>I have <a href="https://domain1.com" rel="nofollow noreferrer">https://domain1.com</a> (domain1) and <a href="https://domain2.com" rel="nofollow noreferrer">https://domain2.com</a> (domain2).</p>
<p>Domain2 serves a page containing javascript with this header:</p>
<pre><code>"Access-Control-Allow-Origin: *"
</code></pre>
<p>Domain1 runs some javascript code that invokes:</p>
<pre><code>new Worker("//domain2.com/script.js")
</code></pre>
<p>Browsers throw security exceptions.</p>
<p>Since starting writing this question, I have got around this problem by ajaxing the script, blobbing it and running it from that, but am I missing something in the original idea?</p> | 0 |
how to get the dynamic column header and result from ajax call in jquery datatable | <p>I want to display the dynamic column header along with the results in datatable.In aaData and aoColumns attributes has to get result data and columns name from ajax call, Please suggest me how to do this or give me some alternate solution to get the dynamic data and column header from ajax call, Here is my code.:</p>
<pre><code>var $table=$('#MSRRes').dataTable( {
"bFilter": false,
"bDestroy": true,
"bDeferRender": false,
"bJQueryUI": true,
"oTableTools": {
"sSwfPath": "swf/copy_cvs_xls_pdf.swf",
},
"sDom": 'TC<"clear">l<"toolbar">frtip',
"ajax" :{
url: 'getResult.php',
type: "POST",
data: {
formData:postData,
}
},
"aaData": results.DATA ,
"aoColumns": [ column_names ]
});
</code></pre>
<p>Here is my ajax call to get the result data and column names to be display:</p>
<pre><code>$result=$afscpMsrMod->getAdvanceSearchResults($colCond,$whereCond,$having);
foreach($cols as $col) {
array_push($colArr, $colnames);
}
$colJson= json_encode($colArr);
$newarray = array(
"draw" => 1,
"recordsTotal" => sizeof($result),
"recordsFiltered" => sizeof($result),
"data" => $result,
"COLUMNS" => $colJson
);
echo json_encode($newarray);
</code></pre> | 0 |
Mysql to select month-wise record even if data not exist | <p>I wrote a query to get month-wise record in user table as follows</p>
<pre><code>SELECT COUNT( `userID` ) AS total, DATE_FORMAT( `userRegistredDate` , '%b' ) AS
MONTH , YEAR( `userRegistredDate` ) AS year
FROM `users`
GROUP BY DATE_FORMAT( FROM_UNIXTIME( `userRegistredDate` , '%b' ) )
</code></pre>
<p>Output:</p>
<pre><code>total MONTH year
---------------------------
3 May 2013
2 Jul 2013
--------------------------
</code></pre>
<p>Expected Output:</p>
<pre><code>total MONTH year
---------------------------
0 Jan 2013
0 Feb 2013
0 Mar 2013
0 Apr 2013
3 May 2013
0 Jun 2013
2 Jul 2013
--------------------------
</code></pre>
<p>I need to show the record even if data not exist. How to do this?</p> | 0 |
Apply Function on DataFrame Index | <p>What is the best way to apply a function over the index of a Pandas <code>DataFrame</code>?
Currently I am using this verbose approach:</p>
<pre><code>pd.DataFrame({"Month": df.reset_index().Date.apply(foo)})
</code></pre>
<p>where <code>Date</code> is the name of the index and <code>foo</code> is the name of the function that I am applying.</p> | 0 |
UIGraphicsGetCurrentContext vs UIGraphicsBeginImageContext/UIGraphicsEndImageContext | <p>I am new to these parts of iOS API and here are some questions that are causing an infinite loop in my mind</p>
<ol>
<li><p>Why does ..BeginImageContext have a size but ..GetCurrentContext does not have a size? If ..GetCurrentContext does not have a size, where does it draw? What are the bounds?</p></li>
<li><p>Why did they have to have two contexts, one for image and one for general graphics? Isn't an image context already a graphic context? What was the reason for the separation (I am trying to know what I don't know)</p></li>
</ol> | 0 |
Javascript call to Swift from UIWebView | <p>I am trying to make a call from a javascript function in a UIWebView to Swift in iOS 10. I have setup a very basic project just to try and get this working, the code is below. </p>
<pre><code>import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = Bundle.main.url(forResource: "products", withExtension: "html")
let request = NSURLRequest(url: url! as URL)
webView.loadRequest(request as URLRequest)
}
@IBAction func closeDocumentViewer() {
displayView.isHidden = true;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
</code></pre>
<p>If I just one to receive a string from a javascript function what would I have to add to the above? </p> | 0 |
How to split data (raw text) into test/train sets with scikit crossvalidation module? | <p>I have a large corpus of opinions (2500) in raw text. I would like to use scikit-learn library to split them into test/train sets. What could be the best aproach to solve this task with scikit-learn?. Could anybody provide me an example of spliting raw text in test/train sets (probably i´ll use tf-idf representation).</p> | 0 |
element not visible: Element is not currently visible and may not be manipulated - Selenium webdriver | <p>Following is the html</p>
<pre><code><div id="form1:customertype" class="ui-selectonemenu ui-widget ui-state-default ui-corner-all ui-state-hover" style="width: 165px;">
<div class="ui-helper-hidden-accessible">
<select id="form1:customertype_input" name="form1:customertype_input" tabindex="-1">
<option value="S">Staff</option>
<option value="C">Customer</option>
<option value="N">New To Bank</option></select></div>
<div class="ui-helper-hidden-accessible"><input id="form1:customertype_focus" name="form1:customertype_focus" type="text" readonly="readonly"></div>
<label id="form1:customertype_label" class="ui-selectonemenu-label ui-inputfield ui-corner-all" style="width: 149px;">Staff</label>
<div class="ui-selectonemenu-trigger ui-state-default ui-corner-right ui-state-hover"><span class="ui-icon ui-icon-triangle-1-s ui-c"></span></div></div>
</code></pre>
<p>The stylesheet of class="ui-helper-hidden-accessible" is</p>
<pre><code>ui-helper-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 0px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 0px;
}
</code></pre>
<p>Following is my code</p>
<pre><code> WebElement customerType = driver.findElement(By.id("form1:customertype_input"));
Select select = new Select(customerType);
select.selectByVisibleText("New To Bank");
</code></pre>
<p>When I try to select "New to Bank" from the dropdown I get exception
element not visible: Element is not currently visible and may not be manipulated - Selenium webdriver</p>
<p>I have tried WebDriverWait technique but of no use, any ideas ?</p> | 0 |
App limit on a single Heroku account | <p>Is there a limit to the number of apps I can host with a single Heroku account?</p>
<p>I currently run multiple apps each using 1 dyno for free. But could I host hundreds (or even thousands) of small applications for free?</p>
<p>I also know there is a 2TB bandwidth soft limit, but is there any other limitation I could encounter?</p> | 0 |
Multipart requests/responses java | <p>I have a task to implement sending of http multipart request and interpreting http multipart response. I decided to start from the response as I just have to receive a response and parse it. I have not that much experience with java and even less with HTTP and that is why I read some articles and other stuff on the topic but I have still some open questions:</p>
<ol>
<li>As far as I understood the content type multipart is used for file upload, sending email attachments, etc. The most posts that I found in google were actully for file upload using multipart/form-data. In what other cases is this content-type used?</li>
<li>I decided to start with the HTTP multipart response, but I realised I have no idea what I have to do in order to receive a response with such a content type. How shall my request look like, what shall I request with this request? I just want to write a simple program in java, which sends an HTTP request to a server and the response that is received is with content-type multipart.</li>
</ol>
<p>It would be nice if someone can clarify these things to me because I think I have misunderstood something.</p>
<p>Thank you in advance!</p> | 0 |
Display image from URL, Swift 4.2 | <p>I am a fairly decent Objective C developer, and I am now learning Swift (of which I am finding quite difficult, not only because of new concepts, such as optionals, but also because Swift is continually evolving, and much of the available tutorials are severely outdated).</p>
<p>Currently I am trying parse a JSON from a url into an NSDictionary and then use one of its value to display an image (which is also a url). Something like this:</p>
<hr>
<p>URL -> NSDictionary -> init UIImage from url -> display UIImage in UIImageView</p>
<hr>
<p>This is quite easy in Objective C (and there may even be a shorter answer):</p>
<pre><code>NSURL *url = [NSURL URLWithString:@"https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"];
NSData *apodData = [NSData dataWithContentsOfURL:url];
NSDictionary *apodDict = [NSJSONSerialization JSONObjectWithData:apodData options:0 error:nil];
</code></pre>
<p>The above code snippet gives me back a standard NSDictionary, in which I can refer to the "url" key to get the address of the image I want to display:</p>
<hr>
<p>"url" : "<a href="https://apod.nasa.gov/apod/image/1811/hillpan_apollo15_4000.jpg" rel="nofollow noreferrer">https://apod.nasa.gov/apod/image/1811/hillpan_apollo15_4000.jpg</a>"</p>
<hr>
<p>This I then convert into a UIImage and give it to a UIImageView:</p>
<pre><code>NSURL *imageURL = [NSURL URLWithString: [apodDict objectForKey:@"url"]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *apodImage = [UIImage imageWithData:imageData];
UIImageView *apodView = [[UIImageView alloc] initWithImage: apodImage];
</code></pre>
<p>Now, I am basically trying to replicate the above Objective C code in Swift but continuously run into walls. I have tried several tutorials (one of which actually did the exact same thing: display a NASA image), as well as find a few stack overflow answers but none could help because they are either outdated or they do things differently than what I need.</p>
<p>So, I would like to ask the community to provide the Swift 4 code for the these problems:</p>
<pre><code>1. Convert data from url into a Dictionary
2. Use key:value pair from dict to get url to display an image
</code></pre>
<p>If it is not too much already, I would also like to ask for detailed descriptions alongside the code because I would like the answer to be the one comprehensive "tutorial" for this task that I believe is currently not available anywhere.</p>
<p>Thank you!</p> | 0 |
Laravel customer API resource with relationships | <blockquote>
<p>Controller function:</p>
</blockquote>
<pre><code>public function index () {
// TESTED
// The getAllActiveSuppliers() function just return Supplier::pagniate(10)
$suppliers = $this -> model -> getAllActiveSuppliers();
return new SupplierResource($suppliers);
}
</code></pre>
<blockquote>
<p>Returned Json:</p>
</blockquote>
<pre><code> {
"current_page": 1,
"data": [
{
"id": 23,
"name": "Test Name",
"description": "Test Description",
"created_by": {
"id": 1,
"name": "Test 1",
"email": "[email protected]",
"email_verified_at": null,
"active": 1,
"created_at": "2018-10-12 14:17:38",
"updated_at": "2018-10-12 14:17:38"
},
"updated_by": {
"id": 1,
"name": "Test 1",
"email": "[email protected]",
"email_verified_at": null,
"active": 1,
"created_at": "2018-10-12 14:17:38",
"updated_at": "2018-10-12 14:17:38"
},
"deleted_at": null,
"created_at": "2018-10-31 01:46:11",
"updated_at": "2018-11-02 22:05:14",
}
],
...
}
</code></pre>
<blockquote>
<p>What I am trying to do:</p>
</blockquote>
<p>In the <strong>created_by and updated_by</strong> I just want to show <code>name, email</code> nothing else.</p>
<blockquote>
<p>What I have tried to do:</p>
</blockquote>
<p>I have tried to create an API resource collection</p>
<p><strong>Supplier.php API Resource Collection :</strong></p>
<pre><code>public function toArray($request)
{
return parent::toArray($request);
}
</code></pre> | 0 |
How should I use ejs to render table vertically? | <p>I have an array like the following:</p>
<pre><code>quotation: [{
"dimension" : 0,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "rx"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "200",
"price": "4",
"factory": "rx"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "rx"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "200",
"price": "5",
"factory": "rx"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "100",
"price": "1.2",
"factory": "hsf"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "200",
"price": "2.4",
"factory": "hsf"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "hsf"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "200",
"price": "4.5",
"factory": "hsf"}]
</code></pre>
<p>How should I use ejs to turn into the following table?</p>
<pre><code><table>
<tr>
<th>Dimension</th><th>Quantity</th><th>Factory: rx</th><th>Factory: hsf</th>
</tr>
<tr>
<td>0</td><td>100</td><td>3</td><td>1.2</td>
</tr>
<tr>
<td>0</td><td>200</td><td>4</td><td>2.4</td>
</tr>
<tr>
<td>1</td><td>100</td><td>3</td><td>3</td>
</tr>
<tr>
<td>1</td><td>200</td><td>5</td><td>4.5</td>
</tr>
</table>
</code></pre>
<p>I have to make sure that the price is from the correct factory. I think this problem is easy if html allows me to define table column by column. But html table only allows me to do it row-wise.</p>
<p>Thank you very much for any help.</p> | 0 |
Can we have multiple <tbody> in same <table>? | <p>Can we have multiple <code><tbody></code> tags in same <code><table></code>? If yes then in what scenarios should we use multiple <code><tbody></code> tags?</p> | 0 |
Using G++ to compile multiple .cpp and .h files | <p>I've just inherited some C++ code that was written poorly with one cpp file which contained the main and a bunch of other functions. There are also <code>.h</code> files that contain classes and their function definitions.</p>
<p>Until now the program was compiled using the command <code>g++ main.cpp</code>. Now that I've separated the classes to <code>.h</code> and <code>.cpp</code> files do I need to use a makefile or can I still use the <code>g++ main.cpp</code> command?</p> | 0 |
How to add data dynamically in JSON object | <p>Sample code</p>
<pre><code>var mydata = [ {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}];
</code></pre>
<p>I have to get output something like above, have to add dynamically columns and its value to mydata.</p>
<p>I am trying to do something like this but its not working for me.</p>
<pre><code>var mydata = [];
for (var r = 0; r < dataTable.getNumberOfRows(); r++) {
var items = "";
var y ="";
for (var c = 0; c < dataTable.getNumberOfColumns(); c++) {
items += '"'+dataTable.getColumnLabel(c)+'":'+dataTable.getValue(r, c)
if(c!=dataTable.getNumberOfColumns()-1){
items += ",";
}
}
y = "{"+items+"}";
mydata.push(y);
}
</code></pre>
<p>above code doesnt works for me. any other way for it</p> | 0 |
How to create a wireless hotspot from 3G connection in iOS | <p>If I wanted to, how would I create an app like <a href="http://intelliborn.com/mywi.html" rel="noreferrer">MyWi</a>, i.e. a wifi tethering app? What are the steps to achieve this functionality? What frameworks/libraries would I need to use? </p>
<p>The goal is not to try to get this app into the app store, but to have it for personal use, and provide it to others.</p>
<p>EDIT:
Nick pointed out the <a href="http://www.youtube.com/watch?v=IlarDCHCyXA" rel="noreferrer">HandyLight app</a>, an app that provided tethering capability disguised as a flashlight. So, it is possible to provide tethering functionality via a third-party app on a non-jailbroken phone. So how is this done?</p>
<p>I have sort of hit a dead end on my research for this :(</p> | 0 |
Showing list empty message at the center of the screen in a FlatList using ListHeaderComponent | <p>I am using React-Native version 0.43.0 which does not support ListEmptyComponent of FlatList. Hence I am using ListHeaderComponent to render a view when the list is empty, </p>
<pre><code>import React, { Component } from 'react';
import { Text, View, StyleSheet,FlatList } from 'react-native';
class App extends Component {
constructor(props) {
super(props);
this.state = {
listData: []
}
}
render() {
return (
<View style={styles.container}>
<FlatList
renderItem={() => null}
data={this.state.listData}
ListHeaderComponent={() => (!this.state.listData.length?
<Text style={styles.emptyMessageStyle}>The list is empty</Text>
: null)
}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:1
},
emptyMessageStyle: {
textAlign: 'center',
//My current hack to center it vertically
//Which does not work as expected
marginTop: '50%',
}
});
</code></pre>
<p><a href="https://i.stack.imgur.com/je2g1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/je2g1.png" alt="enter image description here"></a></p>
<blockquote>
<p>As you can see from the image the text is not centered vertically</p>
</blockquote>
<p>Any idea how to center it vertically in a FlatList?</p>
<p>I have already tried applying justifyContent, alignItems etc but no use.</p>
<p>This is a link to the snack.expo - <a href="https://snack.expo.io/S16dDifZf" rel="noreferrer">https://snack.expo.io/S16dDifZf</a> </p> | 0 |
Host is not allowed to connect to this MySQL server for client-server application | <p>I just exported my tables from one web host to another (AWS).
Thinking everything would go smoothly (yeah right), well, everything that can go wrong has gone wrong.</p>
<p>I get this error when trying to query my database (which I didn't get before):</p>
<p><code>SQLSTATE[HY000] [1130] Host '<my ip address>' is not allowed to connect to this MySQL server</code></p>
<p>This is the same error from this post:</p>
<p><a href="https://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server">Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server</a></p>
<p>The solution in that post seems to revolve around having an administrative user. I am developing a chat application so every user needs to access the server (so I'm sure it's a bad idea to give them all administrative privileges).
The answer by Pascal in that link says, <code>If you are using mysql for a client/server application, prefer a subnet address.</code> but I honestly don't understand what he means by that. And because of the amount of solutions, I'm not exactly sure which one I should follow based on my case.</p>
<p>How do I resolve this?</p> | 0 |
How to retain slf4j MDC logging context in CompletableFuture? | <p>When executing async <code>CompletableFuture</code>, the parent threadcontext and moreover the <code>org.slf4j.MDC</code> context is lost.</p>
<p>This is bad as I'm using some kind of "fish tagging" to track logs from one request among multiple logfiles. </p>
<p><code>MDC.put("fishid", randomId())</code></p>
<p>Question: how can I retain that id during the tasks of <code>CompletableFutures</code> in general?</p>
<pre><code>List<CompletableFuture<UpdateHotelAllotmentsRsp>> futures =
tasks.stream()
.map(task -> CompletableFuture.supplyAsync(
() -> businesslogic(task))
.collect(Collectors.toList());
List results = futures.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList());
public void businesslogic(Task task) {
LOGGER.info("mdc fishtag context is lost here");
}
</code></pre> | 0 |
'GridView1' fired event PageIndexChanging which wasn't handled | <p>I am using a gridview and I want to use paging. I have already set allow paging to true and page size to 5. I can see the numbers at the base of my gridview, but when i click on a number to move to respective page, it throws an error saying:</p>
<p><code>The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.</code></p>
<p>Code:</p>
<pre><code> <asp:GridView ID="GridView1" runat="server" CellPadding="5"
AutoGenerateColumns="False" AllowPaging="True" DataKeyNames="contact_id"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
PageSize="5">
<Columns>
<asp:TemplateField HeaderText="contact_id">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("contact_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="name">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="address">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("address") %>'></asp:Label><br />
<asp:Label ID="Label6" runat="server" Text='<%# Eval("city") %>'></asp:Label><br />
<asp:Label ID="Label7" runat="server" Text='<%# Eval("state") %>'></asp:Label><br />
<asp:Label ID="Label8" runat="server" Text='<%# Eval("pincode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="email">
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Eval("email") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="mobile">
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Eval("mobile") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="context">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Eval("context") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="status">
<ItemTemplate>
<asp:Label ID="Label12" runat="server" Text='<%# Eval("status") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>PENDING</asp:ListItem>
<asp:ListItem>OK</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
&nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemStyle CssClass="button" />
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Left" VerticalAlign="Middle" />
</asp:GridView>
</code></pre> | 0 |
serving gzipped files on Firebase Hosting | <p>I am interested in serving gzipped html/css/js files using Firebase Hosting. I tried setting the Content-Encoding header in firebase.json, but it errors on deploy.</p>
<p>purportedly, the only headers you can set include: Cache-Control,Access-Control-Allow-Origin,X-UA-Compatible,X-Content-Type-Options,X-Frame-Options,X-XSS-Protection</p>
<p>any ideas out there?</p> | 0 |
How to find all assets of a type? | <p>In my Unity project a have several instanced of the class ArmourType (these are assets, scriptable objects). I'm trying to show these in a dropdown list in the inspector, and this works. However, I use </p>
<pre><code>List<ArmourType> armourTypes = Resources.FindObjectsOfTypeAll<ArmourType>();
</code></pre>
<p>to find all these instances. This only finds the objects that are loaded into memory, so occasionally it only finds some of the required assets. This is documented, so isn't a bug, but very annoying at times.</p>
<p>So my question is, is there a different way of getting all these assets that does return those that aren't loaded into memory? Or perhaps is there a way to make Unity load the assets when they are looked for?</p>
<p>Note: I'm using Unity5 and c#.</p> | 0 |
Why my turn server doesn't work? | <p>I can connect in any situation when using <a href="https://appr.tc" rel="noreferrer">appr.tc</a> ice servers (google turn servers). but i can't connect with my own turn server.
I did config my own turn server by <code>coturn project</code>. </p>
<p>I'm using google's <code>libjingle_peerconnection</code> api to create an <code>Android Application</code> that can perform <code>video call</code>.</p>
<p><strong>When i run turn server:</strong></p>
<pre class="lang-html prettyprint-override"><code><pre>
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.5.0.5 'dan Eider'
0:
Max number of open files/sockets allowed for this process: 4096
0:
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 2000 (approximately)
0:
==== Show him the instruments, Practical Frost: ====
0: TLS supported
0: DTLS supported
0: DTLS 1.2 is not supported
0: TURN/STUN ALPN is not supported
0: Third-party authorization (oAuth) supported
0: GCM (AEAD) supported
0: OpenSSL compile-time version: OpenSSL 1.0.1e-fips 11 Feb 2013 (0x1000105f)
0:
0: SQLite is not supported
0: Redis is not supported
0: PostgreSQL is not supported
0: MySQL supported
0: MongoDB is not supported
0:
0: Default Net Engine version: 3 (UDP thread per CPU core)
=====================================================
0: Config file found: /usr/local/etc/turnserver.conf
0: Config file found: /usr/local/etc/turnserver.conf
0: Domain name:
0: Default realm: myserver.com
0:
CONFIGURATION ALERT: you specified long-term user accounts, (-u option)
but you did not specify the long-term credentials option
(-a or --lt-cred-mech option).
I am turning --lt-cred-mech ON for you, but double-check your configuration.
0: WARNING: cannot find certificate file: turn_server_cert.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because certificate file is not set properly
0: WARNING: cannot find private key file: turn_server_pkey.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because private key file is not set properly
0: NO EXPLICIT LISTENER ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering listener addresses: =========
0: Listener address to use: 127.0.0.1
0: Listener address to use: 137.74.35.124
0: Listener address to use: ::1
0: =====================================================
0: Total: 1 'real' addresses discovered
0: =====================================================
0: NO EXPLICIT RELAY ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering relay addresses: =============
0: Relay address to use: 137.74.35.124
0: Relay address to use: ::1
0: =====================================================
0: Total: 2 relay addresses discovered
0: =====================================================
0: pid file created: /var/run/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: Wait for relay ports initialization...
0: relay 137.74.35.124 initialization...
0: relay 137.74.35.124 initialization done
0: relay ::1 initialization...
0: relay ::1 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=1 created
0: IPv4. TCP listener opened on : 127.0.0.1:3478
0: IPv4. TCP listener opened on : 127.0.0.1:3479
0: IPv4. TCP listener opened on : 137.74.35.124:3478
0: IPv4. TCP listener opened on : 137.74.35.124:3479
0: IPv6. TCP listener opened on : ::1:3478
0: IPv6. TCP listener opened on : ::1:3479
0: IPv4. TCP listener opened on : 127.0.0.1:3478
0: IPv4. TCP listener opened on : 127.0.0.1:3479
0: IPv4. TCP listener opened on : 137.74.35.124:3478
0: IPv4. TCP listener opened on : 137.74.35.124:3479
0: IPv6. TCP listener opened on : ::1:3478
0: IPv6. TCP listener opened on : ::1:3479
0: IPv4. UDP listener opened on: 127.0.0.1:3478
0: IPv4. UDP listener opened on: 127.0.0.1:3479
0: IPv4. UDP listener opened on: 137.74.35.124:3478
0: IPv4. UDP listener opened on: 137.74.35.124:3479
0: IPv6. UDP listener opened on: ::1:3478
0: IPv6. UDP listener opened on: ::1:3479
0: Total General servers: 2
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (admin thread): epoll (with changelist)
0: IPv4. CLI listener opened on : 127.0.0.1:5766
</pre>
</code></pre>
<p><strong>When i call from peer A to B :</strong></p>
<p>IP of a peer is 192.68.7.3 !!! Why?</p>
<pre class="lang-html prettyprint-override"><code><pre>
58: IPv4. tcp or tls connected to: 5.112.222.14:1358
58: session 001000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
58: session 001000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
58: IPv4. Local relay addr: 137.74.35.124:51937
58: session 001000000000000001: new, realm=<myserver.com>, username=<heydari>, lifetime=600
58: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
58: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
69: session 001000000000000001: peer 192.168.7.3 lifetime updated: 300
69: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet CREATE_PERMISSION processed, success
69: session 001000000000000001: peer 192.168.7.3 lifetime updated: 300
69: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet CREATE_PERMISSION processed, success
69: session 001000000000000001: peer 109.110.172.36 lifetime updated: 300
69: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet CREATE_PERMISSION processed, success
69: session 001000000000000001: peer 109.110.172.36 lifetime updated: 300
69: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet CREATE_PERMISSION processed, success
186: session 001000000000000001: refreshed, realm=<myserver.com>, username=<heydari>, lifetime=0
186: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet REFRESH processed, success
</pre>
</code></pre>
<p><strong>When i call from peer B to peer A :</strong></p>
<p>I don't see peers after realm lines !! why?</p>
<pre class="lang-html prettyprint-override"><code><pre>
188: handle_udp_packet: New UDP endpoint: local addr 137.74.35.124:3478, remote addr 5.112.222.14:1164
188: session 001000000000000001: realm <myserver.com> user <>: incoming packet BINDING processed, success
188: session 001000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
188: session 001000000000000001: realm <myserver.com> user <>: incoming packet BINDING processed, success
188: session 001000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
188: IPv4. Local relay addr: 137.74.35.124:57827
188: session 001000000000000001: new, realm=<myserver.com>, username=<heydari>, lifetime=600
188: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
188: IPv4. tcp or tls connected to: 5.112.222.14:1496
188: session 000000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
188: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
189: session 000000000000000001: realm <myserver.com> user <>: incoming packet message processed, error 401: Unauthorized
189: IPv4. Local relay addr: 137.74.35.124:52856
189: session 000000000000000001: new, realm=<myserver.com>, username=<heydari>, lifetime=600
189: session 000000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
189: session 000000000000000001: realm <myserver.com> user <heydari>: incoming packet ALLOCATE processed, success
198: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
199: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
209: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
209: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
219: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
219: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
229: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
229: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
239: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
239: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
249: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
249: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
260: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
260: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet BINDING processed, success
267: session 001000000000000001: refreshed, realm=<myserver.com>, username=<heydari>, lifetime=0
267: session 001000000000000001: realm <myserver.com> user <heydari>: incoming packet REFRESH processed, success
267: session 000000000000000001: refreshed, realm=<myserver.com>, username=<heydari>, lifetime=0
267: session 000000000000000001: realm <myserver.com> user <heydari>: incoming packet REFRESH processed, success
</pre>
</code></pre>
<p>I Can't establish successfull connection peers. Where is the problem?</p>
<p>When I use <a href="https://appr.tc" rel="noreferrer">appr.tc</a> turn servers I can call from and to each peers so i think my application is ok.</p> | 0 |
How to update version of Microsoft.NETCore.App SDK in VS 2017 | <p>I have ASP.NET Core API project which was initially developed using VS 2015. I installed VS 2017 and let it convert the project.<br />
Then i goto Project Properties -> Application ->Target framework and change the target framework to .NETCoreApp 1.1.</p>
<p>as soon as i do that i get 2 errors</p>
<blockquote>
<p>Error One or more projects are incompatible with
.NETCoreApp,Version=v1.0.</p>
<p>Error Project Api is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Project Api supports: netcoreapp1.1
(.NETCoreApp,Version=v1.1)</p>
</blockquote>
<p>when i checked <code>Dependencies -> SDK -> Microsoft.NETCore.App -> Properties</code> it shows version <code>1.0.4</code> and <code>SDK Root</code> to <code>C:\Users\username\.nuget\packages\microsoft.netcore.app\1.0.4</code></p>
<p>I have already installed <code>Microsoft.NETCore.App</code> SDK version <code>1.1.2</code> on my machine.</p>
<p>When i goto Nuget Package Manager to update SDK version, it shows its <code>Autoreferenced</code> and update button is disabled.</p>
<p>How do i update project's SDK's version to <code>1.1.2</code>?</p>
<p>Also why VS studio reference SDK from <code>C:\Users\username\.nuget\packages\microsoft.netcore.app</code> instead of from <code>C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2</code></p>
<p><strong>Update 1</strong></p>
<p>Actually <code>1.1.2</code> is not SDK version. <a href="https://www.microsoft.com/net/download/core" rel="noreferrer">As of 7/20/2017</a> the latest SDK version is <code>1.0.4</code> and Runtime version is <code>1.1.2</code> On my machine I have <code>C:\Program Files\dotnet\sdk\1.0.4</code> SDK and <code>C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2</code> runtime installed.</p>
<p>So as i mentioned erlier, when i open converted project in VS 2017, I see Dependencies -> SDK ->Microsoft.NETCore.App - Properties version is <code>1.0.4</code> and SDK Root is <code>C:\Users\username\.nuget\packages\microsoft.netcore.app\1.0.4</code></p>
<p>Now I added new project in the same solution, however new project's Dependencies -> SDK ->Microsoft.NETCore.App -> Properties version is 1.1.2 and SDK root <code>C:\Users\username\.nuget\packages\microsoft.netcore.app\1.1.2</code></p>
<p>I am not sure which is correct here, the SDK version of the converted project or SDK version of the newly added project?</p>
<p>Infact if create a brand new project in VS 2017 i see its Dependencies -> SDK ->Microsoft.NETCore.App -> Properties version is 1.1.2</p>
<p><code>1.1.2</code> SDK not even SDK available. Why VS 2017 shows runtime version as SDK version</p>
<p>is this a bug in VS 2017?</p> | 0 |
How can I *only* get the number of bytes available on a disk in bash? | <p><code>df</code> does a great job for an overview. But what if I want to set a variable in a shell script to the number of bytes available on a disk?</p>
<p>Example:</p>
<pre><code>$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda 1111111111 2222222 33333333 10% /
tmpfs 44444444 555 66666666 1% /dev/shm
</code></pre>
<p>But I just want to return <code>33333333</code> (bytes available on <code>/</code>), not the whole <code>df</code> output.</p> | 0 |
problems after installing java 8 | <p>Android Studio had a popup telling updates was available after i run the SDK manager and started the Android Studio again I got another popoup that toke me to Androids website where it told me that I should upgrade to Java JDK 8 and JRE 8 after I did i got over 235 errors when try to run the debug. I uninstalled version 8 and reinstalled 7u80 JDK and JRE now I'm down to 34 errors. When I type java -version I get 1.8.073
here are all 35 errors.</p>
<pre><code> Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
Error: at java.lang.ClassLoader.defineClass1(Native Method)
Error: at java.lang.ClassLoader.defineClass1(Native Method)
Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
Error: at java.security.AccessController.doPrivileged(Native Method)
Error: at java.security.AccessController.doPrivileged(Native Method)
Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Error:Exception in thread "main"
Error:Exception in thread "main"
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 1
</code></pre>
<p>Here is the Gradel.build</p>
<pre><code>android {
compileSdkVersion 23
buildToolsVersion '24.0.0 rc1'
defaultConfig {
applicationId "com.kim.printer"
minSdkVersion 21
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.code.gson:gson:2.4'
compile "com.android.support:support-v4:23.1.0"
compile "com.android.support:support-v13:23.1.0"
compile "com.android.support:cardview-v7:23.1.0"
compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/StarIOPort3.1.jar')
compile files('libs/StarIO_Extension.jar')
}
</code></pre>
<p>Thanks for any help I have been working on this for 6 hours and I can get it to compile.</p> | 0 |
Adding items to a ComboBox that is added to userform during run time | <p>I am trying to add a combo box to a user form which will be created at run time , the problem I am facing is to add items to the combo box? Not able to figure out where the mistake would be. Thanks.</p>
<pre><code> Function addComboBox(ByRef TempForm As Object, ByVal controlType As String,
ByVal pos As Integer, ByVal strCaption As String, ByVal strValues As String)
Dim NewComboBox As MSforms.ComboBox
Dim arr As Variant
Dim i As Integer
Set NewComboBox = TempForm.Designer.Controls.Add("forms.ComboBox.1")
arr = Split(strValues, ";")
With NewComboBox
.Name = strCaption & "_" & controlType & "_" & pos
.Top = 20 + (12 * pos)
.Left = 100
.Width = 150
.Height = 12
End With
For i = 0 To UBound(arr)
NewComboBox.AddItem arr(i)
Next i
End Function
</code></pre> | 0 |
How to learn Operating System in depth and implement own OS | <p>I am learning Operating Systems, their different perspectives like different scheduling algorithms etc. My question is: Can I make my own OS as a final year project? Please suggest some good resources (i.e video training is appreciated) that helps me understand and mainly gives me the ability to DEVELOP at least a SMALL OS.</p> | 0 |
The space above and below the legend using ggplot2 | <p>If you look at the charts <a href="http://markthegraph.blogspot.com.au/2012/08/credit-aggregates-july-2012.html">here</a>! you can see there is a lot of white space above and below the legend. I wish to reduce the amount of space.</p>
<p>Example code:</p>
<pre><code>library(ggplot2)
library(gridExtra)
library(reshape)
library(plyr)
library(scales)
theme_set(theme_bw())
rows <- 1:nrow(faithful)
data <- cbind(faithful, rows)
molten <- melt(data, id.vars='rows', measure.vars=c('eruptions', 'waiting'))
p <- ggplot() +
geom_line(data=molten,
mapping=aes(x=rows, y=value, group=variable, colour=variable), size=0.8) +
scale_colour_manual(values=c('red','blue')) +
opts(title='Title') +
xlab(NULL) + ylab('Meaningless Numbers') +
opts(
legend.position='bottom',
legend.direction='horizontal',
legend.title=theme_blank(),
legend.key=theme_blank(),
legend.text=theme_text(size=9),
legend.margin = unit(0, "line"),
legend.key.height=unit(0.6,"line"),
legend.background = theme_rect(colour='white', size=0)
)
ggsave(p, width=8, height=4, filename='crap.png', dpi=125)
</code></pre> | 0 |
Ways to extend Array object in javascript | <p>i try to extend Array object in javascript with some user friendly methods like Array.Add() instead Array.push() etc...</p>
<p>i implement 3 ways to do this.
unfortunetly the 3rd way is not working and i want to ask why? and how to do it work.</p>
<pre><code>//------------- 1st way
Array.prototype.Add=function(element){
this.push(element);
};
var list1 = new Array();
list1.Add("Hello world");
alert(list1[0]);
//------------- 2nd way
function Array2 () {
//some other properties and methods
};
Array2.prototype = new Array;
Array2.prototype.Add = function(element){
this.push(element);
};
var list2 = new Array2;
list2.Add(123);
alert(list2[0]);
//------------- 3rd way
function Array3 () {
this.prototype = new Array;
this.Add = function(element){
this.push(element);
};
};
var list3 = new Array3;
list3.Add(456); //push is not a function
alert(list3[0]); // undefined
</code></pre>
<p>in 3rd way i want to extend the Array object internally Array3 class.
How to do this so not to get "push is not a function" and "undefined"?</p>
<p>Here i add a 4th way.</p>
<pre><code>//------------- 4th way
function Array4 () {
//some other properties and methods
this.Add = function(element){
this.push(element);
};
};
Array4.prototype = new Array();
var list4 = new Array4();
list4.Add(789);
alert(list4[0]);
</code></pre>
<p>Here again i have to use prototype.
I hoped to avoid to use extra lines outside class constructor as Array4.prototype.
I wanted to have a compact defined class with all pieces in one place.
But i think i cant do it otherwise.</p> | 0 |
Javascript/jQuery encoding for special characters when using val() | <p>I have a problem with special characters like &, ä, etc. and their corresponding HTML encoded writing like <code>&amp;</code>, <code>&auml;</code> etc.</p>
<ul>
<li><p>When they are used in the value tag of input fields, the browser decodes it automatically, no problem at all.</p></li>
<li><p>When using jQuerys val() function, the browser has no chance to evaluate the content correctly</p>
<pre><code>$("button").click(function(){
$("#test").val("&amp;");
});
</code></pre></li>
</ul>
<p>Any idea?</p> | 0 |
Converting hours in decimal format | <p>I've tried mutliple solutions to this problem but I can't seem to get it.</p>
<p>I have time in decimal format, which is in hours. I want to make it much cleaner by changing it into a DD:HH:MM:SS format.</p>
<h2>Example:</h2>
<p><strike>10.89 hours == 10 hours, 53 minutes, 40 seconds</strike></p>
<p><strong>EDIT</strong>: 10.894945454545455 == 10 hours, 53 minutes, 40 seconds</p>
<h2>What I've tried:</h2>
<pre><code>int hours = (int) ((finalBuildTime) % 1);
int minutes = (int) ((finalBuildTime * (60*60)) % 60);
int seconds = (int) ((finalBuildTime * 3600) % 60);
return String.format("%s(h) %s(m) %s(s)", hours, minutes, seconds);
</code></pre>
<p>Which returned: <code>0(h) 41(m) 41(s)</code></p>
<p>Any suggestions?</p> | 0 |
How to create EditText with cross(x) button at end of it? | <p>Is there any widget like <code>EditText</code> which contains a cross button, or is there any property for <code>EditText</code> by which it is created automatically? I want the cross button to delete whatever text written in <code>EditText</code>.</p> | 0 |
Selection of First L Items of ArrayList of size N > L and Insertion to Another ArrayList in Java | <p>I have an ArrayList l1 of size N and another l2 of size L < N. I want to put the L first items of l1 to l2. I thought to use the for loop of type for(Object obj : l1) to scan my list of size N and then use l2.add(obj) to add elements on l2, but I am not sure if when I reach the max size of l2 (i.e. L) stops inserting items or continues.</p>
<p>Could somebody suggest me a way to do that? Thanx</p> | 0 |
Null Pointer Exception when setting LayoutParams | <p>I created button in activity programmaticaly, not in xml file. Then I wanted to set it LayoutParams like in this link: <a href="https://stackoverflow.com/questions/4638832/how-to-programmatically-set-the-layout-align-parent-right-attribute-of-a-button">How to programmatically set the layout_align_parent_right attribute of a Button in Relative Layout?</a></p>
<p>But when I tried to launch, I had an exception.</p>
<p>Here is my code:</p>
<pre><code>RelativeLayout ll2 = new RelativeLayout(this);
//ll2.setOrientation(LinearLayout.HORIZONTAL);
ImageButton go = new ImageButton(this);
go.setId(cursor.getInt(cursor.getColumnIndex("_id")));
go.setClickable(true);
go.setBackgroundResource(R.drawable.go);
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)go.getLayoutParams();
params1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // LogCat said I have Null Pointer Exception in this line
go.setLayoutParams(params1);
go.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i3 = new Intent(RecipesActivity.this, MedicineActivity.class);
i3.putExtra(ShowRecipe, v.getId());
i3.putExtra("Activity", "RecipesActivity");
RecipesActivity.this.startActivity(i3);
}
});
ll2.addView(go);
</code></pre>
<p>Why my app throws an exception? Thanks.</p> | 0 |
Setting cookie for different domain from javascript | <p>I am trying to set cookie to domain same as src of js file.</p>
<p>Scenario:
In <strong>www.xyz.com</strong> html, I have included js file from qwe.com as below</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code><script type="application/javascript" src="http://qwe.com/b.js"></script></code></pre>
</div>
</div>
</p>
<p>From this b.js, i want to create cookie with domain set to .qwe.com. I am setting cookie with following function</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name+"="+value+expires+";domain=.qwe.com"+"; path=/;";
}</code></pre>
</div>
</div>
</p>
<p>With above code I am unable to set cookie.
Example: www.flipkart.com-> Check cookies in resources tab of developer console-> .scorecardresearch.com and .doubleclick.net are able to set cookie</p>
<p>I want to do same. Can someone please share solution for this? Real working solution. I have tried multiple solutions by doing Google search. It didn't work.</p> | 0 |
Rad grid custom filtering | <p>How can I activate custom filtering for my radgrid?(I googled but I didn't get any proper response regarding this)
I have a property like AllowCustomSorting but I don't have any property regarding filtering.
Can any one provide the way how to implement custom filtering?
If possbile give me a sample page then I will understand.
Thanks in advance. </p> | 0 |
Passing a parameter to an sql stored procedure in c# | <pre><code> string commandGetIslemIdleri = ("EXEC GetIslemIdleri");
cmd = new SqlCommand(commandGetIslemIdleri, sqlConn);
cmd.Parameters.Add(new SqlParameter("@CARIID", 110));
using (var reader = cmd.ExecuteReader()) //error occurs here
{
while (reader.Read())
{
islemidleri.Add(reader.GetInt32(0));
}
}
</code></pre>
<p>Above is the code i am trying to write to call the below stored procedure with a parameter <code>CARIID</code> which is an integer. when i run the code an error occurs and says <code>"Procedure or function 'GetIslemIdleri' expects parameter '@CARIID', which was not supplied."</code>
but as much as i understand from the examples i read from <a href="http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx" rel="noreferrer">here</a> i am sending the parameter with this code <code>cmd.Parameters.Add(new SqlParameter("@CARIID", 110));</code> i need help, thank you in advance.</p>
<pre><code>ALTER PROCEDURE [dbo].[GetIslemIdleri]
@CARIID int
AS
BEGIN
SET NOCOUNT ON;
SELECT ID
FROM TBLP1ISLEM
WHERE TBLP1ISLEM.CARI_ID=@CARIID
END
</code></pre> | 0 |
NGINX Multiple Site Setup | <p>Basically, my NGINX setup is working fine for 2 of my sites but adding a third redirects to the second one. </p>
<pre><code>server {
listen 80;
root /var/www/html/link.com/public/;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.link.com link.com;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
</code></pre>
<p>My other 3 sites have the same config but editted accordingly. I also have a default section. </p>
<p>All 4 sites have a symbolic link in sites-enabled. I also havent editted the nginx.conf I dont think.</p>
<p>What could be the issue here?</p> | 0 |
Implementing a slider (SeekBar) in Android | <p>I want to implement a slider, which is basically two lines, one vertical and one horizontal, crossing where the screen is touched. I have managed to make one but I have to issues:</p>
<ol>
<li>The slider is not very smooth, there is a slight delay when I'm moving the finger</li>
<li>If I place two sliders it is not multitouch, and I'd like to use both of them simultaneously</li>
</ol>
<p>Here is the code: </p>
<pre><code>public class Slider extends View {
private Controller controller = new Controller();
private boolean initialisedSlider;
private int sliderWidth, sliderHeight;
private Point pointStart;
private Paint white;
private int mode;
final static int VERTICAL = 0, HORIZONTAL = 1, BOTH = 2;
public Slider(Context context) {
super(context);
setFocusable(true);
// TODO Auto-generated constructor stub
}
public Slider(Context context, AttributeSet attrs) {
super(context, attrs);
setFocusable(true);
pointStart = new Point();
initialisedSlider = false;
mode = Slider.BOTH;
}
@Override
protected void onDraw(Canvas canvas) {
if(!initialisedSlider) {
initialisedSlider = true;
sliderWidth = getMeasuredWidth();
sliderHeight = getMeasuredHeight();
pointStart.x = (int)(sliderWidth/2.0);
pointStart.y = (int)(sliderHeight/2.0);
controller = new Controller(pointStart, 3);
white = new Paint();
white.setColor(0xFFFFFFFF);
}
canvas.drawLine(controller.getCoordX(),0,
controller.getCoordX(),sliderHeight,
white);
canvas.drawLine(0, controller.getCoordY(),
sliderWidth, controller.getCoordY(),
white);
}
public boolean onTouchEvent(MotionEvent event) {
int eventaction = event.getAction();
int X = (int)event.getX();
int Y = (int)event.getY();
switch (eventaction) {
case MotionEvent.ACTION_DOWN:
if(isInBounds(X,Y)) {
updateController(X, Y);
}
break;
case MotionEvent.ACTION_MOVE:
if(isInBounds(X,Y)) {
updateController(X, Y);
}
break;
case MotionEvent.ACTION_UP:
if(isInBounds(X,Y)) {
updateController(X, Y);
}
break;
}
invalidate();
return true;
}
private boolean isInBounds(int x, int y) {
return ((x<=(sliderWidth)) && (x>=(0))
&& (y<=(sliderHeight)) && (y>=(0)));
}
private void updateController(int x, int y) {
switch(mode) {
case Slider.HORIZONTAL:
controller.setCoordX(x);
break;
case Slider.VERTICAL:
controller.setCoordY(y);
break;
case Slider.BOTH:
controller.setCoordX(x);
controller.setCoordY(y);
break;
}
}
private class Controller {
private int coordX, coordY;
Controller() {
}
Controller(Point point, int width) {
setCoordX(point.x);
setCoordY(point.y);
}
public void setCoordX(int coordX) {
this.coordX = coordX;
}
public int getCoordX() {
return coordX;
}
public void setCoordY(int coordY) {
this.coordY = coordY;
}
public int getCoordY() {
return coordY;
}
}
}
</code></pre>
<p>And the XML file: </p>
<pre><code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<com.android.lasttest.Slider
android:id="@+id/slider"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
<com.android.lasttest.Slider
android:id="@+id/slider"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
<com.android.lasttest.Slider
android:id="@+id/slider"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
</LinearLayout>
</code></pre> | 0 |
bytes/hexa to human readable value? | <p>I want to learn packet decoder processing using <a href="http://www.code.google.com/p/dpkt" rel="nofollow">dpkt</a>. On the site, I saw the following example code:</p>
<pre><code>>>> from dpkt.ip import IP
>>> from dpkt.icmp import ICMP
>>> ip = IP(src='\x01\x02\x03\x04', dst='\x05\x06\x07\x08', p=1)
>>> ip.v4
>>> ip.src
'\x01\x02\x03\x04'
>>> ip.data
''
>>>
>>> icmp = ICMP(type=8, data=ICMP.Echo(id=123, seq=1, data='foobar'))
>>> icmp
ICMP(type=8, data=Echo(id=123, seq=1, data='foobar'))
>>> len(icmp)
14
>>> ip.data = icmp
>>> ip.len += len(ip.data)
>>> ip
IP(src='\x01\x02\x03\x04', dst='\x05\x06\x07\x08', len=34, p=1, data=ICMP(type=8, data=Echo(id=123, seq=1, data='foobar')))
>>> pkt = str(ip)
>>> pkt
'E\x00\x00"\x00\x00\x00\x00@\x01j\xc8\x01\x02\x03\x04\x05\x06\x07\x08\x08\x00\xc0?\x00{\x00\x01foobar'
>>> IP(pkt)
IP(src='\x01\x02\x03\x04', dst='\x05\x06\x07\x08', sum=27336, len=34, p=1, data=ICMP(sum=49215, type=8, data=Echo(id=123, seq=1, data='foobar')))
</code></pre>
<p>I'm confused with lines that are using hexa such as:</p>
<pre><code>ip = IP(src='\x01\x02\x03\x04', dst='\x05\x06\x07\x08', p=1)
</code></pre>
<p>What is the meaning of "\x01\x02\x03\x04" and "\x05\x06\x07\x08"? Is it possible to convert strings like these to something more human-readable?</p> | 0 |
How to take values of only selected checkbox in Action class in Struts 2 and JSP | <p>I am displaying 24 checkboxes. I want to get all the values of checked checkboxes in action class and insert it as a new record inside database.Inserting will be done once I succeed in getting the values of checked checkboxes on button click.</p>
<p>I referred <a href="https://stackoverflow.com/questions/6800008/how-to-retrieve-checkbox-values-in-struts-2-action-class">this</a> link in which I followed the answer answered by steven sir but with help of that I can display only boolean values but here I want text values of checkboxes selected.</p>
<p>So below is my JSP page.</p>
<pre class="lang-jsp prettyprint-override"><code><%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<s:form action="eventInsertAction">
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="contetpanel">
<div>
<div class="crevtbl">
<div class="crevtblRow">
<div class="crevtblCell">Event Name</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.eventName" class="formtextfield" type="text"><s:fielderror fieldName="event.eventName"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Company Name</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.companyName" class="formtextfield" type="text" ><s:fielderror fieldName="event.companyName"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Contact Person Name</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.contactPerson" class="formtextfield" type="text" ><s:fielderror fieldName="event.contactPerson"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Contact</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.contactNumber" class="formtextfield" type="text" ><s:fielderror fieldName="event.contactNumber"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Email</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.emailId" class="formtextfield" type="text" ><s:fielderror fieldName="event.emailId"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Event Venue</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.eventVenue" class="formtextfield" type="text" ><s:fielderror fieldName="event.eventVenue"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Event Date</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2">From : <input name="event.fromDate" class="formtextfield1" type="text" placeholder="YYYY/MM/DD"> &nbsp; &nbsp; &nbsp; &nbsp; To : <input name="event.toDate" class="formtextfield1" type="text" placeholder="YYYY/MM/DD"></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">Event Time</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2"><input name="event.eventTime" class="formtextfield1" type="text" placeholder="HH:MM AM/PM" ><s:fielderror fieldName="event.eventTime"/></div>
</div>
<div class="crevtblRow">
<div class="crevtblCell">License Required</div>
<div class="crevtblCell1">:</div>
<div class="crevtblCell2">
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Rangabhoomi</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Fire NOC</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Fire Engine</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Premises &amp; NOC</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Performance</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">PWD</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Local Police</span><br />
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Collector</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">PPL</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">IPRS</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Traffic</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Liquor License</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Ticket Selling License</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">BMC Parking</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Parking</span><br />
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Port Trust</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Novex</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Foreign Artist</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">DCP Office</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Fire Marshal</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Sale Tax NOC</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Other</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Extra</span>
<input name="event.licenserequired" type="checkbox" class="formcheckbox" value=""><span class="formcheckbox_content">Commission</span>
</div>
</div>
<div class="crevtblRow">
<div class="crevtblCell"></div>
<div class="crevtblCell1"></div>
<div class="crevtblCell2"><button type="submit" class="btn btn-primary">Create Event</button></div>
</div>
</div>
</div>
</div>
</div>
</section>
</s:form>
</body>
</html>
</code></pre>
<p><strong>Below is my setters and getters class</strong></p>
<pre class="lang-java prettyprint-override"><code>package com.ca.pojo;
public class Event {
public Event() {
// TODO Auto-generated constructor stub
}
private String eventName;
private String companyName;
private String contactPerson;
private String contactNumber;
private String emailId;
private String eventVenue;
private String fromDate;
private String toDate;
private String eventTime;
private String licenserequired;
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getContactPerson() {
return contactPerson;
}
public void setContactPerson(String contactPerson) {
this.contactPerson = contactPerson;
}
public String getContactNumber() {
return contactNumber;
}
public void setContactNumber(String contactNumber) {
this.contactNumber = contactNumber;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public String getEventVenue() {
return eventVenue;
}
public void setEventVenue(String eventVenue) {
this.eventVenue = eventVenue;
}
public String getFromDate() {
return fromDate;
}
public void setFromDate(String fromDate) {
this.fromDate = fromDate;
}
public String getToDate() {
return toDate;
}
public void setToDate(String toDate) {
this.toDate = toDate;
}
public String getEventTime() {
return eventTime;
}
public void setEventTime(String eventTime) {
this.eventTime = eventTime;
}
public String getLicenserequired() {
return licenserequired;
}
public void setLicenserequired(String licenserequired) {
this.licenserequired = licenserequired;
}
}
</code></pre>
<p><strong>Below is my Action class</strong></p>
<pre class="lang-java prettyprint-override"><code>package com.ca.actions;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.ca.database.Database;
import com.ca.pojo.Event;
import com.opensymphony.xwork2.ActionSupport;
public class EventInsertAction extends ActionSupport {
private String eventId;
Event event;
String name;
public EventInsertAction() {
// TODO Auto-generated constructor stub
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public Event getEvent() {
return event;
}
public void setEvent(Event event) {
this.event = event;
}
@Override
public String execute() throws Exception {
System.out.println("Event"+event.getLicenserequired());
// TODO Auto-generated method stub
System.out.println("Hi Mahi"+name);
List<Integer> ints = new ArrayList<Integer>();
int i = 0;
for (int i1 = 0; i1 < 10000; i1++) {
ints.add(i1);
}
// Collections.shuffle(ints);
String Id = String.valueOf(ints.get(i++));
eventId = event.getEventName() + Id;
System.out.println(eventId);
try {
Database database = new Database();
Connection con = database.Get_Connection();
System.out.println("Driver Loaded");
PreparedStatement st = con
.prepareStatement("insert into event(EVENT_ID,EVENT_NAME,COMPANY_NAME,CONTACT_PERSON,CONTACT_NO,EMAIL_ID,EVENT_VENUE,FROM_DATE,TO_DATE,EVENT_TIME)"
+ "values(?,?,?,?,?,?,?,?,?,?)");
st.setString(1, eventId);
st.setString(2, event.getEventName());
st.setString(3, event.getCompanyName());
st.setString(4, event.getContactPerson());
st.setString(5, event.getContactNumber());
st.setString(6, event.getEmailId());
st.setString(7, event.getEventVenue());
st.setString(8, event.getFromDate());
st.setString(9, event.getToDate());
st.setString(10, event.getEventTime());
st.executeUpdate();
System.out.println("success");
con.close();
} catch (Exception e) {
System.out.println(e);
}
return "success";
}
@Override
public void validate() {
// TODO Auto-generated method stub
super.validate();
if (event.getEventName().isEmpty()) {
System.out.println("Event Name");
addFieldError("event.eventName", "Please Enter Event Name ..");
}
if (event.getCompanyName().isEmpty()) {
addFieldError("event.companyName", "Please Enter Company Name.. ");
}
if (event.getContactNumber().isEmpty()) {
addFieldError("event.contactNumber",
"Please Enter Contact Number..");
} else {
String expression = "^\\+?[0-9\\-]+\\*?$";
CharSequence inputStr = event.getContactNumber();
Pattern pattern = Pattern.compile(expression,
Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (!matcher.matches())
addFieldError("event.contactNumber", "Invalid Contact Number..");
}
if (event.getContactPerson().isEmpty()) {
addFieldError("event.contactPerson",
"Please Enter Contact Person Name..");
}
if (event.getEmailId().isEmpty()) {
addFieldError("event.emailId", "Please Enter Email ID..");
} else {
String expression = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
CharSequence inputStr = event.getEmailId();
Pattern pattern = Pattern.compile(expression,
Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (!matcher.matches())
addFieldError("event.emailId", "Invalid Email Address..");
}
if (event.getEventVenue().isEmpty()) {
addFieldError("event.eventVenue", "Please Enter Event Venue..");
}
if (event.getFromDate().isEmpty()) {
addFieldError("event.fromDate", "Please Enter Date..");
}
if (event.getToDate().isEmpty()) {
addFieldError("event.toDate", "Please Enter To Date..");
}
if (event.getEventTime().isEmpty()) {
addFieldError("event.eventTime", "Please Enter Event Time..");
}
}
}
</code></pre> | 0 |
How can I insert a newline into a TextBlock without XAML? | <p>I have created a WPF <code>TextBlock</code> inside a <code>Label</code> <strong>in code</strong> (XAML is not possible in my case) as follows:</p>
<pre><code>Label l = new Label();
TextBlock tb = new TextBlock();
l.Content = tb;
</code></pre>
<p>I then come to a situation where I need to set the <code>.Text</code> property of <code>TextBlock</code> containing a new line, such as:</p>
<pre><code>tb.Text = "Hello\nWould you please just work?";
</code></pre>
<p>I have tried numerous encodings (HTML encoding, ASCII encoding, etc.) of various newline combinations (carriage return, linefeed, carriage return plus linefeed, linefeed plus carriage return, double linefeed, double carriage return, etc... ad nauseum). </p>
<ul>
<li>Answers should contain <em>absolutely no XAML</em>.</li>
<li>Answers should assume that the original objects were created using C# code and <strong>not</strong> XAML.</li>
<li>Answers should not refer to <em>binding</em> of WPF properties. No binding is being used. The "Text" property of the "TextBlock" object is being <strong>set</strong>. The newline <em>must</em> be inserted <em>there</em>.</li>
</ul>
<p>If this is impossible, please let me know how I can programmatically add newlines by dynamically replacing each newline in an arbitrary input <code>String</code> into a <code>LineBreak</code> object (or whatever is needed to get this working). The input <code>String</code> will have arbitrary (readable text) contents that I am unable to anticipate in advance because the text itself is dynamic (user-defined); the source strings will have the linefeed character (aka LF, aka <code>\n</code>) but I can easily replace that with whatever is needed.</p>
<p>Also, if it is easier to do this with a <code>Label</code> directly rather than a <code>TextBlock</code> in a <code>Label</code>, that is good too -- I can use that. I just need a control with automatic plain text line wrapping.</p> | 0 |
how can I used the “pefile.py” to get file(.exe) version | <p>I want to used python to get the executed file version, and i know the <a href="http://code.google.com/p/pefile/" rel="nofollow noreferrer">pefile.py</a></p>
<p>how to used it to do this?</p>
<p>notes: the executed file may be not completely.</p> | 0 |
Load external JS from bookmarklet? | <p>How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner.</p> | 0 |
When to use ref and when it is not necessary in C# | <p>I have a object that is my in memory state of the program and also have some other worker functions that I pass the object to to modify the state. I have been passing it by ref to the worker functions. However I came across the following function.</p>
<pre><code>byte[] received_s = new byte[2048];
IPEndPoint tmpIpEndPoint = new IPEndPoint(IPAddress.Any, UdpPort_msg);
EndPoint remoteEP = (tmpIpEndPoint);
int sz = soUdp_msg.ReceiveFrom(received_s, ref remoteEP);
</code></pre>
<p>It confuses me because both <code>received_s</code> and <code>remoteEP</code> are returning stuff from the function. Why does <code>remoteEP</code> need a <code>ref</code> and <code>received_s</code> does not?</p>
<p>I am also a c programmer so I am having a problem getting pointers out of my head.</p>
<p>Edit:
It looks like that objects in C# are pointers to the object under the hood. So when you pass an object to a function you can then modify the object contents through the pointer and the only thing passed to the function is the pointer to the object so the object itself is not being copied. You use ref or out if you want to be able to switch out or create a new object in the function which is like a double pointer. </p> | 0 |
Wrap a delegate in an IEqualityComparer | <p>Several Linq.Enumerable functions take an <code>IEqualityComparer<T></code>. Is there a convenient wrapper class that adapts a <code>delegate(T,T)=>bool</code> to implement <code>IEqualityComparer<T></code>? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but I'd like to know if there is an out-of-the-box solution.</p>
<p>Specifically, I want to do set operations on <code>Dictionary</code>s, using only the Keys to define membership (while retaining the values according to different rules).</p> | 0 |
iOS RTMP streaming library - LFLiveKit vs VideoCore lib vs alternative | <p>We're using VideoCore lib for a live streaming app and started to reach certain limits e.g. project maintenance, saving the stream, portrait-oriented video formatting, external camera sources, etc.</p>
<p>Looking for an alternative iOS RTMP streaming library, one that is more up to date. Any tested suggestions? Thank you!</p> | 0 |
Android mobile user agent? | <p>I'm currently making an android application for a forum, basically it just loads the website in a webview and that works fine and all, but I'm trying to add an option to view the full site or the mobile site. </p>
<p>I got it working by just making a boolean BrowserType which when set to true, loads the mobile site in the webview, and when set to false, loads the full page. I already have it working and everything, the full site loads and I jsut have the user agent as "Chrome", and I set the mobile user agent to "Mobile", but that doesn't work, what am I supposed to use as the user agent for mobile? Just for reference, this is the method I'm using:</p>
<pre><code>myWebView.getSettings().setUserAgentString("Chrome");
</code></pre>
<p>Then for the mobile one instead of "Chrome", I used "Mobile". What is the correct user agent for mobile?</p> | 0 |
Sql Function Issue "The last statement included within a function must be a return statement" | <p>In the below SQL function I have to return value based on condition but it throws a error.</p>
<blockquote>
<p>"The last statement included within a function must be a return
statement."</p>
</blockquote>
<p>Pls help me to overcome this issue.</p>
<pre><code>ALTER FUNCTION [dbo].[GetBatchReleaseQuantity]
(
@i_LocationID VARCHAR(50),
@i_ProductID INT,
@i_StartDate VARCHAR(50),
@i_EndDate VARCHAR(50),
@i_ProductInFlow int
)
RETURNS numeric(18,3)
--WITH ENCRYPTION
AS
BEGIN
IF (@i_ProductInFlow ='2')
BEGIN
RETURN (SElECT ISNULL( SUM( BatchReleaseQuantity),0.00) From BatchReleaseDetails BRD
LEFT OUTER JOIN BatchRelease BR ON BR.BatchReleaseID=BRD.BatchReleaseID
Where ProductId=@i_ProductID AND LocationID=@i_LocationID AND BRD.CreatedOn>=convert(datetime,@i_StartDate+' 00:00:00') AND BRD.CreatedOn<=convert(datetime,@i_EndDate+' 23:59:59'))
END
ELSE
BEGIN
RETURN(SElECT ISNULL( SUM( AcceptedQuantity),0.00) From GoodsReceivedNoteDetail GRND
LEFT OUTER JOIN GoodsReceivedNote GRN ON GRN.LocationID=@i_LocationID
Where ProductId=@i_ProductID AND GRN.LocationID=@i_LocationID AND GRND.CreatedOn>=convert(datetime,@i_StartDate+' 00:00:00') AND GRND.CreatedOn<=convert(datetime,@i_EndDate+' 23:59:59'))
END
END
</code></pre> | 0 |
jQuery post a serialized form then inserting into mysql via php? | <p>I'm trying to post a serialized form to a sumbit.php file, in turn, will then insert into a MySQL database; however, the last input which is hidden, is not getting inserted into the database, though the rest are.</p>
<p>Here's some snippet examples of what I've got thus far which is not working: </p>
<p><strong>HTML</strong></p>
<pre><code> <form method="post" action="" >
<label for="name" class="overlay"><span>Name...</span></label>
<input class="input-text" type="text" name="name" id="name" />
<label for="email" class="overlay"><span>Email...</span></label>
<input type="text" class="input-text" name="email" id="email"/>
<label for="website" class="overlay"><span>Website...</span></label>
<input type="text" class="input-text" name="website" id="website"/>
<label id="body-label" for="body" class="overlay"><span>Comment it up...</span></label>
<textarea class="input-text" name="body" id="body" cols="20" rows="5"></textarea>
<input type="hidden" name="parentid" id="parentid" value="0" />
<input type="submit" value="Comment" name="submit" id="comment-submit" />
</span>
</form>
</code></pre>
<p><strong>Javascript</strong> </p>
<pre><code>$('form.').submit(function(event) {
$.post('submit.php',$(this).serialize(),function(msg){
// form inputs consist of 5 values total: name, email, website, text, and a hidden input that has the value of an integer
}
});
</code></pre>
<p><strong>PHP (submit.php)</strong></p>
<pre><code>$arr = array();
mysql_query(" INSERT INTO comments(name,email,website,body,parentid)
VALUES (
'".$arr['name']."',
'".$arr['email']."',
'".$arr['website']."',
'".$arr['body']."',
'".$arr['parentid']."'
)");
</code></pre> | 0 |
How to conclude your merge of a file? | <p>After I merged a file in Git I tried to pull the repository but error came up:</p>
<blockquote>
<p>You have not concluded your merge. (MERGE_HEAD exists)</p>
</blockquote>
<p>How does one conclude a merge?</p> | 0 |
Tee does not show output or write to file | <p>I wrote a python script to monitor the statuses of some network resources, an infinite pinger if you will. It pings the same 3 nodes forever until it receives a keyboard interrupt. I tried using tee to redirect the output of the program to a file, but it does not work:</p>
<pre><code>λ sudo ./pingster.py
15:43:33 node1 SUCESS | node2 SUCESS | node3 SUCESS
15:43:35 node1 SUCESS | node2 SUCESS | node3 SUCESS
15:43:36 node1 SUCESS | node2 SUCESS | node3 SUCESS
15:43:37 node1 SUCESS | node2 SUCESS | node3 SUCESS
15:43:38 node1 SUCESS | node2 SUCESS | node3 SUCESS
^CTraceback (most recent call last):
File "./pingster.py", line 42, in <module>
main()
File "./pingster.py", line 39, in main
sleep(1)
KeyboardInterrupt
λ sudo ./pingster.py | tee ping.log
# wait a few seconds
^CTraceback (most recent call last):
File "./pingster.py", line 42, in <module>
main()
File "./pingster.py", line 39, in main
sleep(1)
KeyboardInterrupt
λ file ping.log
ping.log: empty
</code></pre>
<p>I am using <a href="https://pypi.python.org/pypi/colorama" rel="noreferrer">colorama</a> for my output, I thought that perhaps could be causing the issue, but I tried printing something before I even imported colorama, and the file is still empty. What am I doing wrong here?</p>
<p>Edit: Here is the python file I'm using</p>
<pre><code>#!/home/nate/py-env/ping/bin/python
from __future__ import print_function
from datetime import datetime
from collections import OrderedDict
from time import sleep
import ping
import colorama
def main():
d = {
'node1': '10.0.0.51',
'node2': '10.0.0.50',
'node3': '10.0.0.52',
}
addresses = OrderedDict(sorted(d.items(), key=lambda t: t[0]))
colorama.init()
while True:
status = []
time = datetime.now().time().strftime('%H:%M:%S')
print(time, end='\t')
for location, ip_address in addresses.items():
loss, max_time, avg_time = ping.quiet_ping(ip_address, timeout=0.5)
if loss < 50:
status.append('{0} SUCESS'.format(location))
else:
status.append(
'{}{} FAIL{}'.format(
colorama.Fore.RED,
location,
colorama.Fore.RESET,
)
)
print(' | '.join(status))
sleep(1)
if __name__ == '__main__':
main()
</code></pre> | 0 |
Icon specified in info.plist not found under the top level app wrapper | <p>I'm trying to upload my binary to iTunes Connect using Applicaton Loader. When I select the file and hit send, it sends for about a second and then this error pops up,</p>
<blockquote>
<p>Icon specified in the info.plist not found under the top level app wrapper: Default -Landscape@2x~ipad.png </p>
</blockquote>
<p>What does this mean? How do I fix it?</p> | 0 |
JPQL: convert varchar to number | <p>How can i convert varchar to number in JPQL ???</p>
<p>I managed to do that in sql (Oracle) with this query:</p>
<pre><code>SELECT Decode(Upper(column_name), Lower(column_name), To_Number(column_name), -1)
FROM table
</code></pre>
<p>I want to do this conversion with JPQL.</p>
<p>Thanks for your help </p> | 0 |
linking one jsp page to another jsp page | <p>This is a very simple question, but as I am a newbie...</p>
<p>I have two files: login.jsp and report.jsp
they are both within the same WebContent folder. </p>
<p>I want a link on report.jsp that when clicked, will take me to login.jsp </p>
<p>The jsp part of the page looks like: </p>
<pre><code>Connection conn = (Connection)session.getAttribute("conn"); //retrieves the connection from the session
String lot_id = request.getParameter("lotnum");
session.setAttribute("lot_id",lot_id);
out.print("Report on Lot Number: ");
out.print(request.getParameter("lotnum")+"<br>");
//<a href="login.jsp">Click here to go to login page</a>
// this is supposed to be an anchor tag linking this page to login.jsp, and where I am getting my error...
Statement sql = conn.createStatement(); //create statement using the connection
//... ... code for the rest of the page goes here...
</code></pre>
<p>thank you,</p>
<p>much appreciated</p> | 0 |
dynamically changing height of #container div in flexslider | <p>I'm working with flexslider and the container div has a background image that acts like a border set to the bottom of it. What I need to do is get the container div to be responsive like the actual flexslider div. So when you shrink the window from right to left, the height of the container div should change height, if that makes sense. Dimensions of the images are 1680x748. And currently the height of the container div is 805px and the width is set to 100%. So the width doesn't matter. Just need to change the height.</p> | 0 |
Python: How can add words to a list? | <p>Okay, the Title is a bit vague, but what I'm trying to do is download data online, parse it and then put the parsed 'data' into an excel file. </p>
<p>I'm getting stuck in trying to put the data into a vector or list. Note that, the data can be either words or numbers. Also, I the length of the data is unknown. I tried the code below:</p>
<pre><code>class MyHTMLParser(HTMLParser):
def handle_data(self, data):
d=[]
d=d.append(data)
parser = MyHTMLParser()
parser.feed('<html><head><title>Test</title></head>'
'<body><h1>Parse me!</h1></body></html>')
d
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
d
NameError: name 'd' is not defined
</code></pre>
<p>I looked around the forum for an answer, but didn't seem to encounter anything. I am a beginner, so may I'm missing something basic? Thanks, for the help...</p> | 0 |
How do you convert a string into base64 in .net framework 4 | <p>So I've been going around the internet looking for a way to convert regular text(string) into base64 string and found many solutions. I'm trying to use:</p>
<pre><code>Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text)
TextBox2.Text = convert.ToBase64String(byt)
</code></pre>
<p>but it end up with an error saying</p>
<blockquote>
<p>'ToBase64String' is not a member of 'System.Windows.Forms.Timer'. </p>
</blockquote>
<p>What do I do to fix this? Or if there's a better way to code it please help.</p> | 0 |
Swiper.js - Uncaught TypeError: Cannot read property 'params' of null | <p>I'm using swiper.js and once swiper1.destroy(); run, rebuild, slide to a certain slide and click.</p>
<p>I got error of <strong>swiper.js:438 Uncaught TypeError: Cannot read property 'params' of null</strong></p>
<p>Here's the code. I appreciate all helps. Thank you very much.</p>
<pre><code>$('.call').click(function(e){
e.preventDefault()
$("#menu").addClass("hide");
$("#slider").removeClass("hide");
selector.push("address");
var swiper1 = new Swiper('.swiper1', {
pagination: '.one',
paginationClickable: true,
hashnav: true,
loop:true,
initialSlide:0
});
getLocation();
$('.noclick').click(function(e){
e.preventDefault()
swiper1.unlockSwipes(); // <-- This seems to be causing the problem
swiper1.slidePrev(); // <-- This seems to be causing the problem
player.seekTo(0);
})
$('.yes').click(function(e){
e.preventDefault()
swiper1.unlockSwipes(); // <-- This seems to be causing the problem
swiper1.slideNext(); // <-- This seems to be causing the problem
})
$('.overlay').click(function(e){
swiper1.unlockSwipes();
console.log("overlay");
e.preventDefault()
$("#menu").removeClass("hide");
$("#slider").addClass("hide");
swiper1.destroy();
})
swiper1.on('slideChangeStart', function () {
var dataindex = $(".swiper-slide-active").data('index');
console.log(dataindex);
if(dataindex == 8){
onPlayerReady();
swiper1.lockSwipes();
setTimeout(function(){
//var state = player.getPlayerState();
//console.log(state);
//if (state == 0){
//alert("This should work");
swiper1.unlockSwipes();
swiper1.slideTo(9);
//}
},4000);
}else if(dataindex == 9) {
swiper1.lockSwipes();
}else if(dataindex == 10){
swiper1.lockSwipes();
}else{
stopVideo();
}
});
})
</code></pre> | 0 |
%D field in Apache access logs - first or last byte? | <p>The Apache Httpd manual has a section on <a href="http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats" rel="noreferrer">custom access log formats</a>. One of these options is the <code>%D</code> field, which is documented as</p>
<blockquote>
<p>The time taken to serve the request, in microseconds.</p>
</blockquote>
<p>Can anyone tell me what exactly this is measuring? Is it time-to-first-byte, or time-to-last-byte, for example, or something more complex than that? </p>
<p>I need this is demonstrate compliance to performance requirements, and I want to know exactly what's being measured here.</p> | 0 |
How to put a UITextField inside of a UITableViewCell (grouped)? | <p>How to put a UITextField inside of a UITableViewCell (grouped)? I want a user to be able to edit it.</p> | 0 |
WPF Databinding With A Collection Object | <p>I have a simple class as defined below:</p>
<pre><code>public class Person
{
int _id;
string _name;
public Person()
{ }
public int ID
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
</code></pre>
<p>that is stored in a database, and thru a bit more code I put it into an ObservableCollection object to attempt to databind in WPF later on:</p>
<pre><code> public class People : ObservableCollection<Person>
{
public People() : base() { }
public void Add(List<Person> pListOfPeople)
{
foreach (Person p in pListOfPeople) this.Add(p);
}
}
</code></pre>
<p>In XAML, I have myself a ListView that I would like to populate a ListViewItem (consisting of a textblock) for each item in the "People" object as it gets updated from the database. I would also like that textblock to bind to the "Name" property of the Person object.</p>
<p>I thought at first that I could do this:</p>
<pre><code>lstPeople.DataContext = objPeople;
</code></pre>
<p>where lstPeople is my ListView control in my XAML, but that of course does nothing. I've found TONS of examples online where people through XAML create an object and then bind to it through their XAML; but not one where we bind to an instantiated object and re-draw accordingly.</p>
<p>Could someone please give me a few pointers on:</p>
<p>A) How to bind a ListView control to my instantiated "People" collection object?</p>
<p>B) How might I apply a template to my ListView to format it for the objects in the collection?</p>
<p>Even links to a decent example (not one operating on an object declared in XAML please) would be appreciated.</p> | 0 |
What's the observable equivalent to `Promise.reject` | <p>I had this code</p>
<pre><code> return this.http.get(this.pushUrl)
.toPromise()
.then(response => response.json().data as PushResult[])
.catch(this.handleError);
</code></pre>
<p>I wanted to use <code>observable</code> instead of <code>Promise</code></p>
<p>how can i return the error to the calling method?</p>
<p>What's the equivalent to <code>Promise.reject</code> ?</p>
<pre><code> doSomeGet() {
console.info("sending get request");
this.http.get(this.pushUrl)
.forEach(function (response) { console.info(response.json()); })
.catch(this.handleError);
}
private handleError(error: any) {
console.error('An error occurred', error);
// return Promise.reject(error.message || error);
}
}
</code></pre>
<p>the calling method was:</p>
<pre><code>getHeroes() {
this.pushService
.doSomeGet();
// .then(pushResult => this.pushResult = pushResult)
// .catch(error => this.error = error);
}
</code></pre> | 0 |
Add tags when creating product in Magento? | <p>The "Product Tags" tab would only appear after a product has been created. Even then, there doesn't seem a way to add tags to a product - it only displays them when you are editing the product and I see only "Reset Filter" and "Search" buttons.</p>
<p>So the tags are only for customers? Not administrators?</p>
<p>Is there any way to add tags to products when creating them? Just like you can specify tags when you are creating blog posts in WordPress. It's an intuitive feature that helps classify the item (product or blog post) even better than categories and attributes (you can't use too many attributes or it won't be user friendly).</p>
<p>If this can't be done from control panel. Is there any way I can do this programmatically by Magento API?</p> | 0 |
VisualStudio Code PHP executablePath in docker | <p>I try to configure VSCode to use our php executable inside a docker container. Firstly i tried it on a macintosh and everything works as expected. At work we use windows pc´s and i cant get it to work.</p>
<p><strong>Workspace Settings</strong></p>
<pre><code>"php.suggest.basic": false,
"php.executablePath": "C:\\Source\\stack\\.bin\\php.bat",
"php.validate.executablePath": "C:\\Source\\stack\\.bin\\php.bat",
"php.validate.run": "onSave",
"php.validate.enable": true
</code></pre>
<p>I tried to set a <code>.sh</code>, <code>.exe</code> or <code>.bat</code> file but none of them seemed to work.</p>
<p><strong>php.bat</strong></p>
<pre><code>@echo off
docker run -i stack_php php %*
</code></pre>
<p><strong>php.sh</strong></p>
<pre><code>#!/bin/sh
docker run stack_php php "$@"
return $?
</code></pre>
<p>Anybody of you can help me get this to work? We would like to change our IDE from PHPStorm to VSCode but we arent able to so because everything a developer needs is stored in docker containers.</p> | 0 |
How to install php yaml on CentOs? | <p>On the start I was getting this error:</p>
<pre><code>Call to undefined function yaml_parse_file()
</code></pre>
<p>I have tried everything what I have found over google:</p>
<pre><code>yum install libyaml
yum install yaml
yum install perl-yaml
</code></pre>
<p>and etc.</p>
<p>Now I'm getting:</p>
<pre><code>PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/extensions/no-debug-non-zts-20100525/yaml.so' - /usr/lib64/extensions/no-debug-non-zts-20100525/yaml.so: cannot open shared object file: No such file or directory in Unknown on line 0
Exception: Extension yaml does not exist
</code></pre>
<p>Already added </p>
<pre><code>extension=yaml.so
</code></pre>
<p>in php.ini file</p>
<p>Details:</p>
<pre><code>CentOS release 6.7 (Final)
PHP 5.4.45
</code></pre>
<p>SS after I ran upper install commands:
<a href="https://i.stack.imgur.com/eieVQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eieVQ.png" alt="enter image description here"></a></p>
<p>What is the proper way to install yaml support in php?</p> | 0 |
ReactNative PanResponder limit X position | <p>I'm building a Music Player and I'm focusing on the progress bar.
I was able to react to swipe gestures, but I cant limit how far that gesture goes.</p>
<p>This is what I've done so far. I've reduced everything to the minumal:</p>
<pre class="lang-js prettyprint-override"><code>constructor(props) {
super(props);
this.state = {
pan: new Animated.ValueXY()
};
}
componentWillMount() {
this._panResponder = PanResponder.create({
onMoveShouldSetResponderCapture: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderGrant: (e, gestureState) => {
// Set the initial value to the current state
let x = (this.state.pan.x._value < 0) ? 0 : this.state.pan.x._value;
this.state.pan.setOffset({ x, y: 0 });
this.state.pan.setValue({ x: 0, y: 0 });
},
onPanResponderMove: Animated.event([
null, { dx: this.state.pan.x, dy: 0 },
]),
onPanResponderRelease: (e, { vx, vy }) => {
this.state.pan.flattenOffset();
}
});
}
render() {
let { pan } = this.state;
// Calculate the x and y transform from the pan value
let [translateX, translateY] = [pan.x, pan.y];
// Calculate the transform property and set it as a value for our style which we add below to the Animated.View component
let imageStyle = { transform: [{ translateX }, { translateY }] };
return (
<View style={styles.container}>
<Animated.View style={{imageStyle}} {...this._panResponder.panHandlers} />
</View>
);
}
</code></pre>
<p>Here there is an image showing what the problem is.</p>
<h2>Initial position:</h2>
<p><a href="https://i.stack.imgur.com/VxwoF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VxwoF.png" alt="Initial position"></a></p>
<h2>Wrong Position, limit exceeded:</h2>
<p><a href="https://i.stack.imgur.com/UZJuB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UZJuB.png" alt="Wrong position"></a></p>
<p>So the idea is to stop keeping moving once the limit (left as well as right) is reached. I tried checking if <code>_value < 0</code>, but it didn't work since It seems to be an offset, not a position.</p>
<p>Well any help will be appreciated.</p> | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.