input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Matplotlib axis not displayed <p>The python code (python 2.7) running on windows 7 shown below results in the following inconsistent behaviour with respect to the display of axis which I do not understand:</p>
<p>1 - a window is opened and a plot without an axis is displayed showing a point
2 - on closing the window, another window is opened and a plot is displayed showing the same point but this time with an axis. </p>
<pre><code>from osgeo import ogr
import pylab
from ospybook.vectorplotter import VectorPlotter
vp = VectorPlotter(False)
myLoc = ogr.Geometry(ogr.wkbPoint)
myLoc.AddPoint(59.5,13)
vp.plot(myLoc,'rs')
pylab.show() ## the plot is displayed --without-- axes displayed
myLoc.AddPoint(59.5,13)
vp.plot(myLoc,'rs')
pylab.show() ## the plot is displayed with axes displayed
</code></pre>
<p>Please note that in my environment, if the vector plotter interactive mode is set to True, pylab.show() opens window but no plot is displayed.</p>
| <p>try </p>
<pre><code>vp = VectorPlotter(interactive=False, ticks=True)
</code></pre>
|
Localization in 2D world <p>I am struggling with the following code for the localization of robot on 2D world of red and green grid cells. I am basically getting the error which states that list index out of range.</p>
<p><a href="https://i.stack.imgur.com/vZfh9.png" rel="nofollow"><img src="https://i.stack.imgur.com/vZfh9.png" alt="enter image description here"></a></p>
<pre><code>p=[.2,.2,.2,.2,.2]# Initial cell probability
w=[['R','G','G','R','R'],
['R','R','G','R','R'],
['R','R','G','G','R'],
['R','R','R','R','R']]# World
meas = ['G','G','G','G','G'] # measurements
mov = [[0,0],[0,1],[1,0],[1,0],[0,1]] # motion
phit = .6 # Probability to measure: R->0.6
pmiss = .2 # Probability to measure: R->0.2
pExact = .8 # Prob. exact motion
pOver = .1 # Prob. overshoot
pUnder = .1 # Prob. undershoot
def entropy (p):
s = [p[i]*log(p[i]) for i in range(len(p))]
return round(-sum(s), 2)
def sense(p, z):
q = []
for i in range(len(p)):
hit = w[i]==z
q.append( p[i]*(phit*hit + pmiss*(1-hit)) )
s = sum(q)
q = [i/s for i in q]
return q
#Moving u cells
def move(p, u):
q = []
for i in range(len(p)):
motion = pExact * p[(i-u)%len(p)]
motion += pOver * p[(i-u-1)%len(p)]
motion += pUnder * p[(i-u+1)%len(p)]
q.append(motion)
return q
for i in range(len(meas)):
p = sense(p, meas[i])
r = [format(j,'.3f') for j in p]
print "Sense %i:"%(i),
print r, entropy(p)
p = move(p, mov[i])
r = [format(j,'.3f') for j in p]
print "Move %i:"%(i),
print r, entropy(p)
print
</code></pre>
| <p>In routine sense() your program tries to access the 5th element of list <strong>w</strong> (index 4 in the list), unfortunately <strong>w</strong> only has 4 elements (only indices 0, 1, 2, 3 are valid)</p>
<p><strong>range(len(p))</strong> returns [0, 1, 2, 3, 4]</p>
<p>Also <strong>w[i]==z</strong> will never be true: indeed <strong>w[i]</strong> is a list of characters, <strong>z</strong> is a single character</p>
<p>sense() is probably not doing what you intended to originally.</p>
|
Error installing angular-cli with NPM on a fresh ubuntu install <p>I just can't understand how to fix these peer dependencies.</p>
<p>I tried to install angular-cli with NPM globally but always results in:</p>
<pre><code>npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "-f" "angular-cli"
npm ERR! node v4.6.0
npm ERR! npm v2.15.9
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package @angular/compiler@2.1.0 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/compiler-cli@0.6.4 wants @angular/compiler@2.0.2
npm ERR! peerinvalid Peer @angular/platform-server@2.1.0 wants @angular/compiler@2.1.0
</code></pre>
<p>I was thinking NPM was taking care of such version differences.. what's going on?</p>
<p>I tried what I found online: clearing cache, installing with --force, but nothing changes this. I feel like I'm missing something basic here.</p>
| <p>i got the same error when i was installing the angular-cli with npm.
but for me version was updated.
1)node v6.6.0</p>
<p>2)npm v3.10.3.</p>
<p>Then after i followed the following steps and the error was solved for me.
Try this,it may help.</p>
<p>1.npm uninstall -g angular-cli</p>
<p>2.npm cache clean</p>
<p>3.npm install -g node-gyp</p>
<p>4.npm install -g node-pre-gyp</p>
<p>5.npm install -g angular-cli</p>
|
$sce.trustAsHtml not working <p>I'm getting post content from my REST api.
The content I'm getting: "<code>&lt;p&gt;test post body&lt;&#x2F;p&gt;</code>"</p>
<p>first, I'm parsing plain text</p>
<pre><code>data[i].postBody = $sce.trustAsHtml(data[i].postBody);
</code></pre>
<p>after I'm doing this and trying to display with ng-bind-html</p>
<pre><code><span ng-bind-html="value.postBody"></span>
</code></pre>
<p>and continues displaying as html.</p>
<p>output:</p>
<pre><code><p>test post body</p>
</code></pre>
<p>I'm not able to show the text without html tags</p>
<p>Please, help me! </p>
| <p>Have used htmlDecode function to escape HTML entities first</p>
<p>HTML :</p>
<pre><code><div ng-bind-html="value.postBody"></div>
</code></pre>
<p>JS :</p>
<pre><code>angular.module('ngApp', ['ngSanitize'])
.controller('controller1', ['$scope','$sce', function($scope, $sce) {
// Some Code ...
...
...
function htmlDecode(input) {
var e = document.createElement('div');
e.innerHTML = input;
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}
data[i].postBody = $sce.trustAsHtml(htmlDecode(data[i].postBody));
...
...
// Some Code ...
}]);
</code></pre>
<p>Fiddle Link : <a href="http://jsfiddle.net/3J25M/771/" rel="nofollow">http://jsfiddle.net/3J25M/771/</a></p>
|
How to use intrinsics to elementwise multiply two char arrays and sum up the multiplications into int? <p>I am not familiar with x86_64 intrinsics, I'd like to have the following operations using 256bit vector registers.
I was using _mm256_maddubs_epi16(a, b); however, it seems that this instruction has overflow issue since char*char can exceeds 16-bit maximum value. I have issue understanding _mm256_unpackhi_epi32 and related instructions. </p>
<p>Can anyone elaborate me and show me the light to the destination? Thank you!</p>
<pre><code>int sumup_char_arrays(char *A, char *B, int size) {
assert (size % 32 == 0);
int sum = 0;
for (int i = 0; i < size; i++) {
sum += A[i]*B[i];
}
return sum;
}
</code></pre>
| <p>I've figured out the solution, any idea to improve it, especially the final stage of reduction.</p>
<pre><code>int sumup_char_arrays(char *A, char *B, int size) {
assert (size % 32 == 0);
int sum = 0;
__m256i sum_tmp;
for (int i = 0; i < size; i += 32) {
__m256i ma_l = _mm256_cvtepi8_epi16(_mm_load_si128((__m128i*)A));
__m256i ma_h = _mm256_cvtepi8_epi16(_mm_load_si128((__m128i*)(A+16)));
__m256i mb_l = _mm256_cvtepi8_epi16(_mm_load_si128((__m128i*)B));
__m256i mb_h = _mm256_cvtepi8_epi16(_mm_load_si128((__m128i*)(B+16)));
__m256i mc = _mm256_madd_epi16(ma_l, mb_l);
mc = _mm256_add_epi32(mc, _mm256_madd_epi16(ma_h, mb_h));
sum_tmp = _mm256_add_epi32(mc, sum_tmp);
//sum += A[i]*B[i];
}
sum_tmp = _mm256_add_epi32(sum_tmp, _mm256_permute2x128_si256(sum_tmp, sum_tmp, 0x81));
sum_tmp = _mm256_add_epi32(sum_tmp, _mm256_srli_si256(sum_tmp, 8));
sum_tmp = _mm256_add_epi32(sum_tmp, _mm256_srli_si256(sum_tmp, 4));
sum = _mm256_extract_epi32(sum_tmp, 0);
return sum;
}
</code></pre>
|
ORA-00947: not enough values when creating object in Oracle <p>I created a new TYPE in Oracle in order to have parity between my table and a local c++ object (I am using OCCI interface for C++).</p>
<p>In the code I use</p>
<pre><code>void insertRowInTable ()
{
string sqlStmt = "INSERT INTO MY_TABLE_T VALUES (:x)";
try{
stmt = con->createStatement (sqlStmt);
ObjectDefinition *o = new ObjectDefinition ();
o->setA(0);
o->setB(1);
o->setC(2);
stmt->setObject (1, o);
stmt->executeUpdate ();
cout << "Insert - Success" << endl;
delete (o);
}catch(SQLException ex)
{
//exception code
}
</code></pre>
<p>The code compiles, connects to db but throws the following exception</p>
<blockquote>
<p>Exception thrown for insertRow Error number: 947 ORA-00947: not enough
values</p>
</blockquote>
<p>Do I have a problematic "sqlStmt"? Is something wrong with the syntax or the binding?</p>
<p>Of course I have already setup an environment and connection</p>
<pre><code> env = Environment::createEnvironment (Environment::OBJECT);
occiobjm (env);
con = env->createConnection (user, passwd, db);
</code></pre>
| <p>How many columns are in the table? The error message indicates that you didn't provide enough values in the insert statement. If you only provide a VALUES clause, all columns in the table must be provided. Otherwise you need to list each of the columns you're providing values for:</p>
<pre><code>string sqlStmt = "INSERT INTO MY_TABLE_T (x_col) VALUES (:x)";
</code></pre>
<p>Edit:
The VALUES clause is listing placeholder arguments. I think you need to list one for each value passed, e.g.:</p>
<pre><code>string sqlStmt = "INSERT INTO MY_TABLE_T (GAME_ID, VERSION) VALUES (:x1,:x2)"
</code></pre>
<p>Have a look at <a href="https://docs.oracle.com/cd/B10501_01/appdev.920/a96583/cciaadem.htm" rel="nofollow">occidml.cpp</a> in the Oracle OCCI docs for an example.</p>
|
Match XPath produce Error loading stylesheet: Parsing an XSLT stylesheet failed <p>I'm getting this error while I try to put XPath into match.
What do I do wrong?
This is my XML example</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<ROOT>
<DOCUMENT name="HLSSD">
<TAG1 name="t1">
text0
<ELEM1 id="el1">
text1
</ELEM1>
<MYELEMENT/>
<ELEM2 id="el2">
text2
<ELEM2 id="el3">
text3
</ELEM2>
<MYELEMENT/>
<ELEM1 id="el4">
text4
</ELEM1>
<MYELEMENT/>
text4.5
<ELEM1 id="el5">
text5
</ELEM1>
<TAG3 name="t2"/>
text5.6
<ELEM2 id="el6">
text6
</ELEM2>
</ELEM2>
</TAG1>
<TAG1 name="t3">
<ELEM1 id="el7">
text7
</ELEM1>
<ELEM2 id="el8">
text3
</ELEM2>
<MYELEMENT/>
<ELEM1 id="el9">
text4
</ELEM1>
<MYELEMENT/>
text4.5
<ELEM1 id="el10">
text5
</ELEM1>
<TAG3 name="t4"/>
text5.6
<ELEM2 id="el11">
text6
</ELEM2>
</TAG1>
<TAG2 name="t4">
</TAG2>
<TAG2 name="t5">
</TAG2>
<TAG1 name="t6">
</TAG1>
</DOCUMENT>
</ROOT>
</code></pre>
<p>Here is my XSL code:</p>
<pre><code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><xsl:apply-templates/></body>
</html>
</xsl:template>
<xsl:template match="DOCUMENT">
<div>
<h1><xsl:value-of select="@name" /></h1>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="TAG1|TAG2|TAG3">
<div>
<h1><xsl:value-of select="name()" /></h1>
<p><xsl:value-of select="@name" /></p>
<pre><xsl:apply-templates/></pre>
</div>
</xsl:template>
<xsl:template match="ELEM1|ELEM2">
<p>(<xsl:apply-templates/>)</p>
</xsl:template>
<xsl:template match="MYELEMENT/following-sibling::*[count(.|(TAG1|TAG2|TAG3|MYELEMENT)/preceding-sibling::*)=count((TAG1|TAG2|TAG3|MYELEMENT)/preceding-sibling::*)]">
<div>
<h1><xsl:value-of select="name()" /></h1>
<p><xsl:apply-templates/></p>
</div>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>What I want is to find MYELEMENT and everything after at same level until first (one) of TAG1 or TAG2 or TAG3 or MYELEMENT or to be concrete I want to wrap with div tag every elements from MYELEMENT to first of TAG1 or TAG2 or TAG3 or MYELEMENT at same level or the end of parent element.</p>
<p>Output should be this:</p>
<pre><code><html>
<body>
<div>
<h1>DocName</h1>
<div>
<h1>TAG1</h1>
<p>t1</p>
<pre>
text0
<p>(
text1
)</p>
**<DIV>**
**<H1>MYELEMENT</H1>**
<p>(
text2
<p>(
text3
)</p>
**<DIV>**
**<H1>MYELEMENT</H1>**
<p>(
text4
)</p>
**</DIV>**
**<DIV>**
<H1>MYELEMENT</H1>
text4.5
<p>(
text5
)</p>
**</DIV>**
<div>
<h1>TAG3</h1>
<p>t2</p>
<pre></pre>
</div>
text5.6
<p>(
text6
)</p>
)</p>
**</DIV>**
</pre>
</div>
<div>
<h1>TAG1</h1>
<p>t3</p>
<pre>
<p>(
text7
)</p>
<p>(
text3
)</p>
**<DIV>**
**<H1>MYELEMENT</H1>**
<p>(
text4
)</p>
**</DIV>**
**<DIV>**
**<H1>MYELEMENT</H1>**
text4.5
<p>(
text5
)</p>
**</DIV>**
<div>
<h1>TAG3</h1>
<p>t4</p>
<pre></pre>
</div>
text5.6
<p>(
text6
)</p>
</pre>
</div>
<div>
<h1>TAG2</h1>
<p>t5</p>
<pre>
</pre>
</div>
<div>
<h1>TAG2</h1>
<p>t6</p>
<pre>
</pre>
</div>
<div>
<h1>TAG1</h1>
<p>t7</p>
<pre>
</pre>
</div>
</div>
</body>
</html>
</code></pre>
| <p>You can change your <code>match</code> path to a valid path with the same semantic meaning like this:</p>
<pre><code><xsl:template match="*[preceding-sibling::MYELEMENT and
count(.|(TAG1|TAG2|TAG3|MYELEMENT)/preceding-sibling::*) =
count((TAG1|TAG2|TAG3|MYELEMENT)/preceding-sibling::*)]">
</code></pre>
|
How to get previous value of <select> in React? <p>An example.</p>
<p><code>red</code> is selected from the very start.</p>
<p>Then I select <code>green</code>. That is, from <code>red</code> to <code>green</code>.</p>
<p>I can get new value <code>green</code> in <code>event.currentTarget.value</code>. But how do I get previous <code>red</code>?</p>
<pre><code><select className="foo" onChange={this.onSectChange} value="red">
<option value="no color">No Color</option>
<option value="red">Red</option> // this one is selected
<option value="green">Green</option> // this one I will select
<option value="blue">Blue</option>
</select>
onSectChange = (event) => {
let prevVal = event.??? // How to get a previous value, that is Red
let newVal = event.currentTarget.value; // Green - is a new value just selected, not previous
}
</code></pre>
<p>I mean, does React provide this functionality out-of-the-box along with their <code>SyntheticEvent</code> creation? Or do I still have to hack to get it?</p>
| <p><code>currentTarget</code> is a property supported by <em>browsers</em> and it doesn't have anything to do with React, in itself.</p>
<p><code>SyntheticEvent</code> is just a wrapper around the browser's native event, which exposes certain browser events.</p>
<p>The closest thing to what you're trying to do that comes to mind is <a href="https://developer.mozilla.org/en-US/docs/Web/API/Event/originalTarget" rel="nofollow"><code>Event.originalTarget</code></a>, but it's an experimental feature only implemented in Mozilla.</p>
<p>So, to answer your question: no, React doesn't provide that functionality out of the box. And I wouldn't say you need a <em>hack</em> to get the previous value of your dropdown menu.</p>
<p>For instance, you could use <code>componentWillReceiveProps</code> and compare <code>nextProps</code> with <code>this.props</code>.</p>
<p>Please provide more details, if I misunderstood your question.</p>
|
Child item created two times in ExpandableListView Android <pre><code>public class ExpandableListAdapters extends BaseExpandableListAdapter {
private Context _context;
List<String> group_data;
List<String> child_data;
public ExpandableListAdapters(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
this._context = context;
Log.e("HEADER SIZE", "" + listDataHeader.size() + "..." + listChildData.size());
}
public ExpandableListAdapters(ServicesFragment servicesFragment, List<String> service_names,List<String> service_desc) {
this._context = servicesFragment.getActivity();
this.group_data = service_names;
this.child_data=service_desc;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return child_data.get(groupPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
Log.e("SERVICE LIST","...."+child_data.get(groupPosition));
String description = child_data.get(groupPosition);
//final Double price = data.get(groupPosition).getProducts().get(childPosition).getPrice();
Log.e("ADAPTER", "........" + description);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
if(!description.equals(null)){
txtListChild.setText(description);/*+ " : Rs." + price);*/
}
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return child_data.size();
}
@Override
public Object getGroup(int groupPosition) {
return group_data.get(groupPosition);
}
@Override
public int getGroupCount() {
return group_data.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = group_data.get(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
</code></pre>
<p>The above is my code.
Child item is created two times under each group item.
In my group and child list there are two elements. Actually the expected result for my above code is :</p>
<blockquote>
<p>Group1 child1 Group2 child2</p>
</blockquote>
<p>I can't find out the mistake. Please help me anyone.</p>
| <p>Replace this getChild method to :</p>
<pre><code>@Override
public Object getChild(int groupPosition, int childPosititon) {
return child_data.get(groupPosition);
}
</code></pre>
<p>Correct one :</p>
<pre><code>@Override
public Object getChild(int groupPosition, int childPosititon) {
return child_data.get(group_data.get(groupPosition))
.get(childPosititon);
}
</code></pre>
<p>As well,</p>
<pre><code> @Override
public int getChildrenCount(int groupPosition) {
return child_data.get(group_data.get(groupPosition))
.size();
}
</code></pre>
|
Libgdx Stencil & ShapeRenderer <p>I am trying to accomplish something like this:</p>
<p><a href="https://i.stack.imgur.com/CkdSO.jpg" rel="nofollow">sample image</a></p>
<p>The whole screen will be black, then the insides of the triangle shape are the parts that will only appear.</p>
<p>I tried using SCISSOR but it is rectangle in shape.</p>
<p>*Original Image Source: <a href="https://www.html5rocks.com/static/images/screenshots/casestudies/onslaught/controls_tutorial.png" rel="nofollow">https://www.html5rocks.com/static/images/screenshots/casestudies/onslaught/controls_tutorial.png</a></p>
| <p>There are a few different ways that you can render a masked image. One possible way is to use the depth buffer. I've written a small method that shows the process of setting up the buffer using a ShapeRenderer to define a triangular region of the image to render and mask out the remainder. The triangle mask could be replaced by any other shape that the ShapeRenderer is capable of rendering.</p>
<pre><code>// For a 2D image use an OrthographicCamera
OrthographicCamera cam = new OrthographicCamera();
ShapeRenderer shapes = new ShapeRenderer();
cam.setToOrtho(true, screenWidth, screenHeight);
shapes.setProjectionMatrix(cam.combined);
private void renderStencilImage(float runTime){
// Clear the buffer
Gdx.gl.glClearDepthf(1.0f);
Gdx.gl.glClear(GL30.GL_DEPTH_BUFFER_BIT);
// Disable writing to frame buffer and
// Set up the depth test
Gdx.gl.glColorMask(false, false, false, false);
Gdx.gl.glDepthFunc(GL20.GL_LESS);
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
Gdx.gl.glDepthMask(true);
//Here add your mask shape rendering code i.e. rectangle
//triangle, or other polygonal shape mask
shapes.begin(ShapeRenderer.ShapeType.Filled);
shapes.setColor(1f, 1f, 1f, 0.5f);
shapes.triangle(x1,y1,x2,y2,x3,y3);
shapes.end();
// Enable writing to the FrameBuffer
// and set up the texture to render with the mask
// applied
Gdx.gl.glColorMask(true, true, true, true);
Gdx.gl.glDepthMask(true);
Gdx.gl.glDepthFunc(GL20.GL_EQUAL);
// Here add your texture rendering code
batcher.begin();
renderFrame(runTime);
batcher.end();
// Ensure depth test is disabled so that depth
// testing is not run on other rendering code.
Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
}
</code></pre>
<p>Before you call the method, you must first create a ShapeRenderer and set the projection matrix. You must also set the depth buffer option in the android config in the onCreate method like this:</p>
<pre><code>protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.depth = 15;
initialize(new game(), config);
}
</code></pre>
<p>The options for glDepthFunc define how the mask is applied to the texture. Check out the <a href="https://www.opengl.org/wiki/Depth_Test" rel="nofollow">OpenGL wiki</a> to see the arguments that can be passed to the function.</p>
|
need to create a configureable timer task in java via XML <p>I have a multi threaded socket server application. My requirement is to update a table every X min which i do now by running a parallel thread. The duration(in minutes) is stored in a XML file. but the parallel running thread is taking too much space on the heap memory, ultimately causing an OutOfMemoryError.
Below is the code for the updation.</p>
<pre><code>public class MyThread extends Thread
{
public void run()
{
while(true)
{
int TOmin=0;
int timeout=0;
try {
TOmin=Integer.parseInt(DatabaseManager.getSMSTimeout().trim()); //the method reads from a XML file.
timeout=TOmin*60*1000;
Thread.sleep(timeout);
DataManager.callstoredprocedure();
} catch (NumberFormatException e) {
e.printStackTrace();
LogManager.logException(Arrays.toString(e.getStackTrace()));
} catch (InterruptedException e) {
e.printStackTrace();
LogManager.logException(Arrays.toString(e.getStackTrace()));
}
}
}
}
</code></pre>
<p>I looked into the <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html" rel="nofollow">Scheduled Executor Service</a> but unable to configure the delay prameters from a XML file. Please suggest a way to do the task without causing leaks in memory.</p>
<p><strong>EDIT-1</strong>- using spring core is not an option and i have to work it with threads only. Any suggestions.</p>
| <p>Go with Spring core and use:</p>
<pre><code> @Scheduled(<Options>)
</code></pre>
<p>its to much easy you can make a jar and run it will run perfect. so no need to work with thread , thread always makes to difficult to manage</p>
<p><a href="http://howtodoinjava.com/spring/spring-core/4-ways-to-schedule-tasks-in-spring-3-scheduled-example/" rel="nofollow">http://howtodoinjava.com/spring/spring-core/4-ways-to-schedule-tasks-in-spring-3-scheduled-example/</a></p>
|
Why are the indices of a sparse non-diagonal array inversed? <p>I have a sparse matrix file, which contains 820 lines. Sample of few lines of the file are as follows:</p>
<pre><code>0 547 1
1 547 1
2 539 0.500000
2 540 0.500000
3 512 0.333333
3 515 0.333333
</code></pre>
<p>I want to import this sparse matrix file into Matlab. The full matrix contained in the file has 1184 rows and an equal numbers of columns. To convert this file into sparse matrix, I use the following commands:</p>
<pre><code>T = reshape(T,3,entries)';
disp('Array is: ');
A = (sparse(T(:,1)+1, T(:,2)+1, T(:,3), rows , cols));
</code></pre>
<p>Firstly and before add +1 to index, an error is displayed, which is:</p>
<blockquote>
<p>"??? Error using ==> sparse Index into matrix must be positive.</p>
</blockquote>
<p>It was due to Matlab begins at index 1, not at index 0.</p>
<p>After adding +1, the problem is resolved.
But now, iwhenI run this code </p>
<pre><code> A = (sparse(T(:,1)+1, T(:,2)+1, T(:,3), rows , cols));
</code></pre>
<p>For a diagonal matrix, the output is excellent, and the problem with the positive index is resolved. But when I try it for a nondiagonal matrix the result is that it inverses the output. I mean that instead of having (1, 500) = 3,67 it gives me (500,1) = 3,67. Why does Matlab do that?</p>
| <p>You are probably following row-major (e.g. your matrix was created in C) and MATLAB is column-major. To convert from one to the other, just swap the coordinates!</p>
<p><code>A = (sparse(T(:,2)+1, T(:,1)+1, T(:,3), cols, rows));</code></p>
<hr>
<p>Example that it works:</p>
<pre><code>T=[0 547 1;
1 547 1;
2 539 0.500000;
2 540 0.500000;
3 512 0.333333;
3 515 0.333333];
% choosen randombly 4x600 because I dont have the full matrix.
% Just use rows and cols in your case
A = sparse(T(:,1)+1, T(:,2)+1, T(:,3), 4 , 600); % this one is as in C
B = sparse(T(:,2)+1, T(:,1)+1, T(:,3), 600 , 4); % this one is my suggestion
isequal(A',B) %the transpose of A is equal to B
</code></pre>
|
PDFBox omits form fields when page is cloned <p>I'm trying to create a multi-page document using PDFBox and Groovy.
I have a template document which contains some form text fields and everytime a new document should be created, the program uses this template.</p>
<p>My problem is that whenever I try to create a new document, some form fields in the new doc are missing. I work with Foxit PhantomPDF and, Visually, I can't see the missing fields. The other ones which I do see are fine.</p>
<p>Here is my code:</p>
<pre><code>static void initiatePdf() {
// Initiate a new PDF Box object and get the acro form from it
File file = new File(Constants.EMPTY_DOC)
PDDocument tempDoc
Evaluator evaluator = new Evaluator()
int numPages = evaluator.getNumOfPagesRequired(objects)
for(int i = 0; i < numPages; i++) {
tempDoc = new PDDocument().load(file)
PDDocumentCatalog docCatalog = tempDoc.getDocumentCatalog()
PDAcroForm acroForm = docCatalog.acroForm
PDPage page = (PDPage) docCatalog.getPages().get(0)
document.addPage(page)
}
document.save(Constants.RESULT_FILE)
document.close()
}
</code></pre>
<p>Here are an images that will help depict my problem. This is the template:</p>
<p><img src="https://i.gyazo.com/eb500f9ebba4707459ad52c05c12f53a.png" alt=""></p>
<p>This is the new pdf file</p>
<p><img src="https://i.gyazo.com/351b03cba1d3211ef768da73cd427a50.png" alt=""></p>
| <p>I managed to resolve this problem with the help of Tilman Hausherr. Here is the code located after the for loop.</p>
<pre><code>PDAcroForm acroForm = new PDAcroForm(document, acroFormDict);
acroForm.setFields(fields)
acroForm.setDefaultResources(res);
PDDocumentCatalog catalog = document.getDocumentCatalog();
catalog.setAcroForm(acroForm);
</code></pre>
|
Bootstrap navbar background color rules not working <p>When I try to change my navbar background color it becomes grayed out in <code>Google Chrome</code> inspector. Can't find a working solution on google.</p>
<p>It does change when I removing navbar-default but then I don't get the toggle icon on smaller screens.</p>
<p>I've also tried to apply the rules to navbar-default but same results. the background-color doesn't change.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
font-family: "Courier New" ;
}
.ttposter{
color:black;
height:400px;
width:250px;
}
.navbar-custom {
background-color:#e74c3c;
color:#ffffff;
border-radius:0;
margin-bottom: 0;
}
.navbar-custom .navbar-nav > li > a {
color:#fff;
}
.navbar-custom .navbar-nav > .active > a, .navbar-nav > .active > a:hover, .navbar-nav > .active > a:focus {
color: #ffffff;
background-color:transparent;
}
.navbar-custom .navbar-brand {
color:#eeeeee;
}
.headerImgText{
color:white;
margin: 10%;
}
body,html {
height: 100%;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!--Custom css-->
<link rel="stylesheet" type="text/css" href="CSS/styles.css">
<!--Javascript-->
<script type="text/javascript" src="scripts/movies.js"></script>
<title>Homepage</title>
</head>
<body onload="loadFeaturedMovies()">
<header>
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapsed" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Notflix</a>
</div>
<!-- LINKS -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="index.html">HOME</a></li>
<li><a href="movies.html">MOVIES</a></li>
<li><a href="users.html">USERS</a></li>
<li><a href="login.html">ACCOUNT</a></li>
</ul>
<!-- LOGIN -->
<form class="navbar-form navbar-right">
<div class="form-group">
<input type="text" id="loginUsername" class="form-control" placeholder="username">
<input type="password" id="loginPassword" class="form-control" placeholder="password">
</div>
<button type="submit" onclick="login()" class="btn btn-default">Login</button>
</form>
</div>
</div>
</nav>
</header></code></pre>
</div>
</div>
</p>
| <p>try below code, u just need to remove background image</p>
<pre><code>.navbar-custom {
background-image: none;
}
</code></pre>
<p>see <a href="https://jsfiddle.net/DTcHh/26314/" rel="nofollow">fiddle</a> here</p>
|
How to check if LLDB loaded debug symbols from shared libraries? <p>On Linux I use</p>
<pre><code>(gdb) i shared
</code></pre>
<p>in gdb and gdb prints a list of libraries either with a star <code>*</code> if no debug symbols are loaded or without it if loaded, e.g:</p>
<pre><code>0x0000000100c18660 0x0000000100c489a0 Yes (*) /Users/anon/work/software/webrtc-audio-processing-0.1/build_darwin/../bin/darwin/lib/libwebrtc_audio_processing.0.dylib
0x0000000100c57ca0 0x0000000100c76978 Yes /Users/anon/work/software/speex/speex/speex-1.2rc2/build_darwin/../bin/darwin/lib/libspeex.1.dylib
</code></pre>
<p>I found that in LLDB I should use</p>
<p><code>(lldb) image list</code></p>
<p>to do the same. But I get a list of libraries which says nothing to me on whether debug symbols are loaded for the lib or not, e.g:</p>
<pre><code>[181] 19269C1D-EB29-384A-83F3-7DDDEB7D9DAD 0x00007fff8d2d3000 /System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi
[182] 8D7BA9BA-EB36-307A-9119-0B3D9732C953 0x00007fff879ee000 /System/Library/Frameworks/CoreBluetooth.framework/Versions/A/CoreBluetooth
[183] 6F03761D-7C3A-3C80-8031-AA1C1AD7C706 0x00007fff92e52000 /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
</code></pre>
<p>So how do I check if debug symbols are loaded by LLDB?</p>
<p>UPDATE: I just decided to post output of <code>(lldb) image lookup -vn <function></code> (thanks Jim) for others to know what it looks like:</p>
<pre><code>image lookup -vn Herqq::Upnp::HSsdp::init
2 matches found in libHUpnp.2.dylib:
Address: libHUpnp.2.dylib[0x00000000000283f0] (libHUpnp.2.dylib.__TEXT.__text + 150384)
Summary: libHUpnp.2.dylib`Herqq::Upnp::HSsdp::init() at hssdp.cpp:804
Module: file = "libHUpnp.2.dylib", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp", language = "c89"
Function: id = {0xa0002401f}, name = "init", range = [0x00000000000283f0-0x0000000000028511)
FuncType: id = {0xa0002401f}, decl = hssdp.h:304, clang_type = "_Bool (void)"
Blocks: id = {0xa0002401f}, range = [0x000283f0-0x00028511)
LineEntry: [0x00000000000283f0-0x00000000000283ff): /Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp:804
Symbol: id = {0x00000c9b}, range = [0x00000000000283f0-0x0000000000028520), name="Herqq::Upnp::HSsdp::init()", mangled="_ZN5Herqq4Upnp5HSsdp4initEv"
Variable: id = {0xa0002403a}, name = "this", type= "Herqq::Upnp::HSsdp *", location = DW_OP_fbreg(-16), decl =
Variable: id = {0xa00024047}, name = "herqqLog__", type= "HLogger", location = DW_OP_fbreg(-32), decl = hssdp.cpp:805
Variable: id = {0xa00024056}, name = "ha", type= "QHostAddress", location = DW_OP_fbreg(-56), decl = hssdp.cpp:812
Address: libHUpnp.2.dylib[0x0000000000028550] (libHUpnp.2.dylib.__TEXT.__text + 150736)
Summary: libHUpnp.2.dylib`Herqq::Upnp::HSsdp::init(QHostAddress const&) at hssdp.cpp:817
Module: file = "libHUpnp.2.dylib", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp", language = "ISO C++:1998"
Function: id = {0xa0002408f}, name = "init", range = [0x0000000000028550-0x000000000002862d)
FuncType: id = {0xa0002408f}, decl = hssdp.h:321, clang_type = "_Bool (const class QHostAddress &)"
Blocks: id = {0xa0002408f}, range = [0x00028550-0x0002862d)
LineEntry: [0x0000000000028550-0x0000000000028564): /Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp:817
Symbol: id = {0x00000ca3}, range = [0x0000000000028550-0x0000000000028630), name="Herqq::Upnp::HSsdp::init(QHostAddress const&)", mangled="_ZN5Herqq4Upnp5HSsdp4initERK12QHostAddress"
Variable: id = {0xa000240aa}, name = "this", type= "Herqq::Upnp::HSsdp *", location = DW_OP_fbreg(-16), decl =
Variable: id = {0xa000240b7}, name = "unicastAddress", type= "const QHostAddress &", location = DW_OP_fbreg(-24), decl = hssdp.cpp:816
Variable: id = {0xa000240c6}, name = "herqqLog__", type= "HLogger", location = DW_OP_fbreg(-40), decl = hssdp.cpp:818
</code></pre>
| <p>If your binary was built with a dSYM, then the dSYM will show up on the line after the binary's listing in image list.</p>
<p>There isn't an easy way to do this if the binary is using the "leave the debug information in the .o file" style which is the default for the Debug configuration in Xcode. I filed a bug to make that easier to see. </p>
<p>One fairly simple way to do it is:</p>
<pre><code>(lldb) image lookup -vn <SomeFunctionNameThatShouldHaveDebugInfo>
</code></pre>
<p>If the output of that command includes a CompileUnit, then the .o file containing that function has debug information, otherwise, not.</p>
|
Error in sql query Incorrect syntax near <p>I newbie in Microsoft Visual Studio 2008. I have a SQL query, which shows a time that had been spendeed on solving each request by every employee. Data base is Microsoft SQL Server on Windows Server 2008. </p>
<p>I want to find a number of requests that had been solved in a 6 hours and below in percentage terms and also a sum of all solved requests of every employee</p>
<p>below and above 6 hours. </p>
<p>This is my SQL query but while it works it produces an error: </p>
<blockquote>
<p>Incorrect syntax near '>' Incorrect syntax near 'tmp_table.'</p>
</blockquote>
<p>SQL Query:</p>
<pre><code>SELECT id, fio, date_s, tline
, ( cast ( tline as int) > 6 ) as 'tv'
, count (distinct id) as 'cid'
FROM(SELECT id, fio, date_s
, dbo.get_work_time(date_s, date_f, '12345', '09:00', '18:00', '0')/60 AS 'tline'
FROM Zno_speed WHERE (date_f > @date)
GROUP BY fio
) tmp_table
GROUP BY id, fio, date_s, tline, ( cast ( tline as int) > 6 )
</code></pre>
| <p>SQL Server does not have a real boolean data type and thus does not support boolean expressions like <code>cast ( tline as int) > 6</code></p>
<p>You need to rewrite that into a case statement:</p>
<pre><code>case when cast ( tline as int) > 6 then 1 else 0 end as tv
</code></pre>
|
Is it possible to create multiple data source objects under the same database executing a single xmla script? <p>I want to create multiple data source objects under the same database executing the single XMLA script only once.I have tried the below script but it did not work.If I define only a single node, the script executes successfully.But when I add the another same node it gives error. I am newer to this.Please guide.</p>
<pre><code><Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ParentObject>
<DatabaseID>Test Database</DatabaseID>
</ParentObject>
<ObjectDefinition>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource1</ID>
<Name>Test Datasource1</Name>
<Description>A test datasource1.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource2</ID>
<Name>Test Datasource2</Name>
<Description>A test datasource2.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
</ObjectDefinition>
</Create>
</code></pre>
| <p>Is there a batch element wrapper you can use? </p>
|
read/write to the same file (getting gmon.out) <p>My homework asks that I use a single file to output data to, send calculations to that file, and read the results from that file.
The data is a series of input ages from 1-100, controlled by a decrement counter based off of a variable cin by user: totalAges.</p>
<p>The problem I'm having is that the file is not being created as variable.txt
it is gmon.out.</p>
<p>i've looked at a bunch of tutorials tried to troubleshoot myself, tried to use fstream/ofstream/ifstream etc... I can't figure it out. How can I get it to first write the data to a file, then read FROM that file?</p>
<p>The error i'm mostly getting is:</p>
<pre><code>data>>age;
No match for 'operator>>'.
</code></pre>
<p>AND</p>
<pre><code>132 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64- mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setbase)
</code></pre>
<p>^^ that happens a bunch which i'm thinking is trying to use ofstream with
ios::in.</p>
<p>I'm not sure how to accomplish this task.</p>
<pre><code>#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <fstream>
using namespace std;
int totalAges;
int age;
string str_fileIn;
int average = 0;
cout<<"Enter a filename.\n";
cin>>str_fileIn;
ofstream data;
data.open //this may be the problem but i'm not sure why exactly.
((str_fileIn+".txt").c_str(), ios::in | ios::out);
counter = totalAges;
for (counter; counter>=1; --counter)
{
cout<<"Enter an age value 1-100. ";
cin>>age;
average = average + age;
}
average = average /totalAges;
highest = age;
lowest = age;
while(data.is_open())
{
if (age > highest)
{highest = age;}
if (age < lowest)
{lowest = age;}
data>>age; //this operator will not work here!
counter++;
if (counter==totalAges)
data.close();
}
</code></pre>
<p>Sorry If i missed something crucial I tried to include as much info as possible while not being a textbook.</p>
<p>Thank you.</p>
<p>Error List:</p>
<pre><code> D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In function 'int main()':
104 6 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Error] no match for 'operator>>' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int')
104 6 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] candidates are:
53 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\string In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/string
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\locale_classes.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/locale_classes.h
41 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\ios_base.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/ios_base.h
42 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ios from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/ios
38 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/ostream
39 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
996 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\basic_string.tcc [Note] template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)
996 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\basic_string.tcc [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
879 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/istream
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
955 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
</code></pre>
<p>955 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template argument deduction/substitution failed:</p>
<pre><code>104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
879 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/istream
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
923 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
923 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
727 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
727 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
732 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
732 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
774 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
774 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
779 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
779 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
71 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Resetiosflags)
71 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
101 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setiosflags)
101 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
132 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setbase)
132 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
170 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setfill<_CharT>)
170 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
200 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setprecision)
</code></pre>
<p>200 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:</p>
<pre><code>104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
230 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setw)
230 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
104 8 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
122 9 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Error] no match for 'operator>>' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int')
122 9 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] candidates are:
53 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\string In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/string
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\locale_classes.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/locale_classes.h
41 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\ios_base.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/ios_base.h
42 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ios from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/ios
38 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/ostream
39 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
996 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\basic_string.tcc [Note] template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)
996 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\basic_string.tcc [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
879 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/istream
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
955 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
955 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
879 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/istream
40 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
923 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
923 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\istream.tcc [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
727 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
727 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
732 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
732 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
774 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
774 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
40 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
22 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
779 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
779 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\istream [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<char, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
71 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Resetiosflags)
71 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
101 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setiosflags)
101 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
132 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setbase)
132 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
170 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setfill<_CharT>)
170 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64- mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
</code></pre>
<p>122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream}' is not derived from 'std::basic_istream<_CharT, _Traits>'</p>
<pre><code> 23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
200 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setprecision)
200 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
23 0 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp In file included from D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp
230 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setw)
230 5 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iomanip [Note] template argument deduction/substitution failed:
122 11 D:\Fall16_CIT133\HW5\COPY5001198106L_Chisholm_HW5_Q3.cpp [Note] 'std::ofstream {aka std::basic_ofstream<char>}' is not derived from 'std::basic_istream<_CharT, _Traits>'
</code></pre>
<p>edit 1: added #include -- and compiler error list</p>
| <p>When you do</p>
<pre><code>data>>age;
</code></pre>
<p>you are trying to read from the <em>output</em> stream. You should be using <code><<</code> to write instead:</p>
<pre><code>data<<age;
</code></pre>
<p>Before that though, you need to check if the file actually is open, or any writing to it will not work. You also need to make sure the file is created where you <em>think</em> it is created. It might not where you expect it to be, so search for it.</p>
|
Using external class methods inside the imported module <p>My python application consists of various <em>separate</em> processing algorithms/modules combined within a single (Py)Qt GUI for ease of access. </p>
<p>Every processing algorithm sits within its own module and all the communication with GUI elements is implemented within a single class in the main module.
In particular, this GUI class has a progressbar (<a href="http://pyqt.sourceforge.net/Docs/PyQt4/qprogressbar.html" rel="nofollow">QProgressBar</a>) object designed to represent the current processing progress of a chosen algorithm.
This object has <code>.setValue()</code> method (<code>self.dlg.progressBar.setValue(int)</code>).</p>
<p>The problem is that since <code>self.dlg.progressBar.setValue()</code> is a class method I cannot use it inside my imported processing modules <em>to report their progress state within their own code</em>. </p>
<p>The only workaround I found is to add <code>progressbar</code> variable to definition of each processing module, pass there <code>self.dlg.progressBar</code> inside the main module and then blindly call <code>progressbar.setValue(%some_processing_var%)</code> inside the processing module. </p>
<p>Is this the only way to use outer class methods inside imported modules or are there better ways? </p>
| <p>No. I think this approach somewhat breaks software engineering principles (e.g. <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle" rel="nofollow">single responsibility</a>). In single responsibility principle, each module is only in charge of its assigned task and nothing else. If we consider UI a separate layer, so your processing modules shouldn't have anything to do with the UI layer.</p>
<p>In this case, your modules should have a method called <code>publish_progress(callback)</code> which <code>callback</code> is a function to be called for each progress step (<a href="https://en.wikipedia.org/wiki/Callback_(computer_programming)" rel="nofollow">more info</a>). Then, in your UI layer define a function which is given an integer (between 0 to 100) and updates the progress bar. Once you've defined it, you should register it with <code>publish_progress</code> method of your modules.</p>
<pre><code>def progress_callback(prg):
self.dlg.progressBar.setValue(prg)
</code></pre>
<p>Registering it:</p>
<pre><code>my_module.publish_progress(progress_callback)
</code></pre>
<p>Calling the callback in your module:</p>
<pre><code>progress_callback(0)
...
# do something
...
progress_callback(20)
...
# do something
...
progress_callback(100)
</code></pre>
|
Selenium/Ruby writing code to check Web Element by of way Xpath <p>I am writing in ruby code using <code>selenium webdriver</code> and I simply want to check to see if an element is properly displayed on a webpage. I am doing this by way of <code>xpath</code>. </p>
<pre><code>@driver.find_element(:xpath, ' ')
</code></pre>
<p>I am not sure what to do beyond that. I have added displayed? into the code but it thru back a no such element error. Any example would be appreciated. For example, verifying the the Google image logo is properly displayed by its xpath.
Please advise</p>
| <blockquote>
<p>I simply want to check to see if an element is properly displayed on a webpage</p>
</blockquote>
<p>Actually <code>find_element</code> returns either <code>WebElement</code> of throws <code>NoSuchElementException</code>, So you can write your own method which uses try catch block and return true when there is no exception and false when there is an exception.</p>
<p>I would suggest, you should try using <code>find_elements</code> which would return either list of <code>WebElement</code> with matching locator or empty list, So determine whether element exist or not, just check that list is empty and visible or not as below :-</p>
<pre><code>list = @driver.find_elements(:xpath, ' ')
if(!list.empty? && list[0].displayed?)
return list[0]
end
</code></pre>
|
Java vararg pass lamda and values <p>I'm trying to unite lambdas and simple values in varag.</p>
<pre><code>public static void Log(String format, Object ... args) {
final Object[] fmt = new Object[ args.length ];
for(int i = 0; i < args.length; i++)
fmt[i] = args[i] instanceof Supplier ?
( (Supplier) args[i] ).get() :
args[i];
final String s = String.format( format, fmt );
System.err.println( s );
}
final Supplier
s = () -> "aaa",
d = () -> 111;
Log( "%s %d %s %d", "bbb", 222, s, d ); // OK, OUTPUT: bbb 222 aaa 111
Log( "%s %d %s %d", "bbb", 222, () -> "aaa", () -> 111 ); // COMPILE FAIL
</code></pre>
<p>ERROR: method Log cannot be applied to given types; REQUIERED String,Object[] found: String,String,int,()->"aaa",()->111 REASON: varargs mismatch; Object is not a functional interface</p>
<p>Is it possible to pass both lambdas and values to vararg?
Thank you.</p>
| <p>The problem is in the error message</p>
<blockquote>
<p>Object is not a functional interface</p>
</blockquote>
<p>You can only create a lambda for a functional interfaces (one with exactly one abstract method) Object is not an interface and it doesn't have any abstract methods so you can't create a lambda of this type. What you can do is</p>
<pre><code>Log( "%s %d %s %d", "bbb", 222, (Supplier) () -> "aaa", (Supplier) () -> 111 );
</code></pre>
<p>This way the compiler knows what sort of lambda you intended to implement.</p>
<p>By comparison you could write the following and this would behave differently in your method.</p>
<pre><code>Log( "%s %d %s %d", "bbb", 222, (Callable) () -> "aaa", (Callable) () -> 111 );
</code></pre>
|
Android - Scan ip with send pings <p>I want to send pings between 192.168.1.0 and 192.168.2.255 due to detect machines in my network (wifi).. Is there a any function which make this? Thank you.</p>
| <p>Add loop 0-254 for Ip and inside this you can check IP is reachable or not using following code </p>
<pre><code>InetAddress.getByName(ip).isReachable(timeout);
</code></pre>
|
when I am adding Long Press Gesture on uiimageview in Table View Cell .Uiimageview Is not showing With correct Image <p>I am Using the Long Press Gesture code on uiimageview the Problem is Profile Picture is not showing Correct.I have 50 values in Table View and after 5 to 6 images Further Cell image is going to be Nil.and Profile Picture is coming from Web Service.and if i will not add long press all 50 rows will display with their correct Image.
this is my code::</p>
<pre><code>#pragma mark - UITableView
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
return arrResultData.count;
}
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"FishCell" forIndexPath:indexPath];
// getting the imag which is in prototype cell in storyboard
UIImageView *cellimg=(UIImageView*)[cell viewWithTag:101];
cellimg.tag=indexPath.row;
cellimg.userInteractionEnabled = YES;
UILongPressGestureRecognizer *gestureRecognizer = [[UILongPressGestureRecognizer alloc] init];
gestureRecognizer.delegate = self;
gestureRecognizer.minimumPressDuration = 0.5;
[cellimg addGestureRecognizer: gestureRecognizer];
[gestureRecognizer addTarget:self action:@selector(imgLongPressed:)];
- (void)imgLongPressed:(UILongPressGestureRecognizer*)sender
{
// UIImageView *view_ =(UIImageView*) sender.view;
NSLog(@"view tag %ld",sender.view.tag);
// CGPoint point = [sender locationInView:view_.superview];
//
if (sender.state == UIGestureRecognizerStateBegan){
Profile_PopUP_Vc *Profile_PopUPVc = [self.storyboard instantiateViewControllerWithIdentifier:@"Profile_PopUP_Vc"];
Profile_PopUPVc.ImageUrl=[[arrResultData valueForKey:@"picture"]objectAtIndex:sender.view.tag];
Profile_PopUPVc.strUsername=[[arrResultData valueForKey:@"username"]objectAtIndex:sender.view.tag];
Profile_PopUPVc.delegate = self;
[self presentPopupViewController:Profile_PopUPVc animationType:MJPopupViewAnimationFade];
}
else if (sender.state == UIGestureRecognizerStateEnded){
[self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade];
}
}
}
</code></pre>
| <p>The error is in those lines:</p>
<pre><code>UIImageView *cellimg=(UIImageView*)[cell viewWithTag:101];
cellimg.tag=indexPath.row;
</code></pre>
<p>You are changing the image view tag, and then, when cell is being reused, it doesn't have a view with tag 101, so your <code>cellimg</code> is <code>nil</code>. </p>
|
what is the difference between left join and left outer join? <p>I have created 2 tables as</p>
<pre><code>CREATE TABLE table1(customerName VARCHAR(20),custid NUMBER ,order_id NUMBER ,price NUMBER );
CREATE TABLE table2(id NUMBER ,salary NUMBER );
</code></pre>
<p>Now, I tried to use the queries </p>
<pre><code>SELECT t1.customername,t1.custid,t2.salary FROM table1 t1 left join table2 t2 ON t1.custid = t2.id;
SELECT t1.customername,t1.custid,t2.salary FROM table1 t1 left outer join table2 t2 ON t1.custid = t2.id;
</code></pre>
<p>But I get the same output. Is there any difference between them internally in their working ? or are both same!?</p>
| <p>The <code>OUTER</code> keyword is optional across most popular SQL distributions, which means there is absolutely no difference between a <code>LEFT JOIN</code> and a <code>LEFT OUTER JOIN</code></p>
|
symfony: load many services in one service? <p>In a futur webapp, I need to retreive datas from differents API (Soap/Rest/Custom...), and sometime mix results from 2, 3, or all API at the same time.</p>
<p>For each API, i will perform the sames actions, ex: getLastDatas, setOneData, putDatas2externalDB, etc...</p>
<p>In a controller, I could to something like:</p>
<pre><code>$someFreshResults = $this->get('app.products')->getFreshResults($para1, $para2, $arrayOfAPI);
</code></pre>
<p>with $arrayOfAPI a list of 1, 2, or all API name.</p>
<p>As all API are different (and sometime not trivial), i think it could be revelant to declare a service by API, but a very bad and ugly idea to inject all those services inside the app.products services and loop for them with something like :</p>
<pre><code>public function getFreshResults($para1, $para2, $API) {
foreach($API as $oneApi) {
oneResult = $this->get($oneAPI)->getLastDatas($para1);
... work with oneResult ...
}
}
</code></pre>
<p>What is the proper way to do this in a symfony app ? </p>
| <p>I would suggest to write separate services (but implementing a shared interface) for each API you want to consume, and then write a service that aggregates these individual API clients. Your aggregation service could have an API like this:</p>
<pre><code><?php
class MyAggregrator
{
/** @var ApiClientInterface[] */
private $clients = [];
public function registerClient(string $name, ApiClientInterface $client)
{
$this->clients[$name] = $client;
}
public function getProducts()
{
foreach ($this->clients as $name => $client) {
...
}
}
}
</code></pre>
<p>Registering your aggregation service in the container could look something like this:</p>
<pre><code>services:
my_aggregator:
class: MyAggregrator
calls:
- [registerClient, ["foo", "@api1"]]
- [registerClient, ["bar", "@api2"]]
</code></pre>
<p>You could even simplify this configuration a bit by tagging your API clients, and then write a compiler pass that fetches every tagged service and registers them in the aggregation service. For more info about tagged services, see <a href="http://symfony.com/doc/current/service_container/tags.html" rel="nofollow">http://symfony.com/doc/current/service_container/tags.html</a></p>
|
How to make the HTML renders before the alert is triggered? <p>The question is actually quite simple. How do I make the div's content change before the alert shows up?</p>
<p>JSFiddle: </p>
<p><a href="https://jsfiddle.net/n2n5drL2/1/" rel="nofollow">https://jsfiddle.net/n2n5drL2/1/</a></p>
<p>HTML:</p>
<pre><code><div id="test">
Some Text
</div>
<button id="change">
change
</button>
</code></pre>
<p>JavaScript:</p>
<pre><code>$('#change').click(function(){
$('#test').text('new content');
alert('how to make this alert shows after the div changes its content?')
})
</code></pre>
| <p>You need to defer execution of the blocking <code>alert</code> so the browser can re-render the changed DOM. You can do this <a href="http://stackoverflow.com/questions/779379/why-is-settimeoutfn-0-sometimes-useful">with <code>setTimeout</code> and a 0ms timeout</a>:</p>
<pre><code>$('#change').click(function(){
$('#test').text('new content');
setTimeout(function() {
alert('how to make this alert shows after the div changes its content?')
},0);
})
</code></pre>
<hr>
<p>It is worth noting, however, that <a href="http://w3c.github.io/html/webappapis.html#dom-window-alert" rel="nofollow">the specification for <code>alert</code></a> says to only</p>
<blockquote>
<p>Optionally, pause while waiting for the user to acknowledge the message.</p>
</blockquote>
<p>So while I've personally never seen a user-agent treat it as non-blocking, the specification does allow for it.</p>
|
How to rewrite below code so that I get expected output <p>The objective is to read list of known files from amazon s3 and create a single file in s3 at some output path. Each file is tab separated. I have to extract first element from each line and and assign it a numeric value in increasing order. Numeric value and element should be tab separated in the new file which would be created. I am using spark with scala to perform operations on RDDs.</p>
<h2>Expected output</h2>
<p>1 qwerty<br>
2 asdf<br>
...<br>
...<br>
67892341 ghjk</p>
<h2>Current output</h2>
<p>1 qwerty<br>
2 asdf<br>
...<br>
...<br>
456721 tyui<br>
1 sdfg<br>
2 swerr<br>
...<br>
...<br>
263523 gkfk<br>
...<br>
...<br>
512346 ghjk</p>
<p>So, basically as the computation is happening on distributed cluster, the global variable <code>counter</code> is getting initiated on each machine. How can I rewrite the code so that I get the desired output. Below is the code snippet. </p>
<pre><code> def getReqCol() = {
val myRDD = sc.textFile("s3://mybucket/fileFormatregex")
var counter = 0
val mbLuidCol = myRDD.map(x => x.split("\t")).map(col =>col(0)).map(row => {
def inc(acc : Int) = {
counter = acc + 1
}
inc(counter)
counter + "\t" + row
})
row.repartition(1).saveAsTextFile("s3://mybucket/outputPath")
}
</code></pre>
| <p>Looks like all you need is <a href="https://spark.apache.org/docs/2.0.1/api/scala/index.html#org.apache.spark.rdd.RDD@zipWithIndex():org.apache.spark.rdd.RDD[(T,Long)]" rel="nofollow"><code>RDD.zipWithIndex()</code></a>:</p>
<pre><code>val myRDD =
sc
.textFile("s3://mybucket/fileFormatregex")
.map(col => col(0))
.zipWithIndex()
.map(_.swap)
.sortByKey(true)
.repartition(1)
.saveAsTextFile("s3://mybucket/outputPath")
</code></pre>
|
how to retrieve parent's value based on child <p>I am trying to retrieve the user's key based on the child's email, which is student@memail.com in this case. I have tried many ways but could not get a way to retrieve the key of the record. I want to retrieve the value KKTxEMxrAYVSdtr0K1NH , below is the snapshot of the database</p>
<p><a href="https://i.stack.imgur.com/6UgbF.png" rel="nofollow"><img src="https://i.stack.imgur.com/6UgbF.png" alt="database"></a></p>
<p>Currently, <code>if((childSnap.val().role) == "student") {</code> returns me student and snap.key() returns me "User". How do I retrieve KTxEMxrAYVSdtr0K1NH ?</p>
| <p>What method are you using to retrieve the node? If you are using on "child_added" then you can use: <strong>childSnap.key</strong></p>
<p>If you are using on "value" then your references is the keys in the response object. So you can use:</p>
<pre><code>for (var key in childSnap.val()) {
console.log(key)
}
</code></pre>
<p>or</p>
<pre><code>childSnap.forEach(...)
</code></pre>
<p>Here is an example to clearify (check the console):
<a href="https://jsfiddle.net/qrLvbok4/1/" rel="nofollow">https://jsfiddle.net/qrLvbok4/1/</a></p>
<p>There is a difference between value and child_added, check the list for child events section: <a href="https://firebase.google.com/docs/database/web/lists-of-data" rel="nofollow">https://firebase.google.com/docs/database/web/lists-of-data</a></p>
|
Update table based on Dates in SQL Server? <p>I got below 2 tables:</p>
<pre><code>if object_id('tempdb..#t1') is not null
drop table #t1
create table #t1
(
ID int,
opendate datetime,
closedate datetime,
[ADDRESS] varchar(50)
)
insert into #t1 (ID, opendate, closedate)
values (111, '1930-05-01 00:00:00.000', '2004-10-23 00:00:00.000'),
(111, '2004-10-23 00:00:00.000', '2006-03-26 00:00:00.000'),
(111, '2006-10-23 00:00:00.000', '2009-03-26 00:00:00.000'),
(111, '2009-03-26 00:00:00.000', '2013-05-21 00:00:00.000'),
(111, '2013-05-21 00:00:00.000', '2013-06-18 00:00:00.000'),
(111, '2013-06-18 00:00:00.000', '2016-04-11 00:00:00.000'),
(111, '2016-04-11 00:00:00.000', '2016-06-16 00:00:00.000'),
(111, '2016-06-16 00:00:00.000', '2016-06-21 00:00:00.000'),
(111, '2016-06-21 00:00:00.000', NULL)
select
*
from
#t1
if object_id('tempdb..#t2') is not null
drop table #t2
create table #t2
(
ID int,
opendate datetime,
closedate datetime,
[ADDRESS] varchar(50)
)
insert into #t2 (ID, opendate, closedate, [ADDRESS])
values
(111,'1930-05-01 00:00:00.000','2004-10-23 00:00:00.000','1 AVENUE' )
,(111,'2004-10-23 00:00:00.000','2009-03-26 00:00:00.000','2 AVENUE' )
,(111,'2009-03-26 00:00:00.000','2013-05-21 00:00:00.000','3 AVENUE' )
,(111,'2013-05-21 00:00:00.000' ,NULL ,'5 AVENUE' )
,(111,'2016-04-11 00:00:00.000' ,'2016-06-16 00:00:00.000','6 AVENUE' )
,(111,'2016-06-16 00:00:00.000' ,NULL ,'7 AVENUE' )
,(111,'2016-06-21 00:00:00.000' ,NULL ,'8 AVENUE' )
select
*
from
#t2
</code></pre>
<p>I want update first table like below:</p>
<pre><code>111 1930-05-01 00:00:00.000 2004-10-23 00:00:00.000 '1 AVENUE'
111 2004-10-23 00:00:00.000 2006-03-26 00:00:00.000 '2 AVENUE'
111 2006-03-26 00:00:00.000 2009-03-26 00:00:00.000 '2 AVENUE'
111 2009-03-26 00:00:00.000 2013-05-21 00:00:00.000 '3 AVENUE'
111 2013-05-21 00:00:00.000 2013-06-18 00:00:00.000 '5 AVENUE'
111 2013-06-18 00:00:00.000 2016-04-11 00:00:00.000 '5 AVENUE'
111 2016-04-11 00:00:00.000 2016-06-16 00:00:00.000 '6 AVENUE'
111 2016-06-16 00:00:00.000 2016-06-21 00:00:00.000 '7 AVENUE'
111 2016-06-21 00:00:00.000 NULL '8 AVENUE'
</code></pre>
<p>I have tried some ways but it is not returning the correct results because of nulls.</p>
<p>Thanks.</p>
| <pre><code>update t1 set address = tmp.address
from (select t1.ID, t1.opendate, ROW_NUMBER() over (partition by t1.opendate order by t2.opendate desc) row, t2.ADDRESS
from #t1 t1
inner join #t2 t2 on t1.ID = t2.ID and t1.opendate between t2.opendate and isnull(t2.closedate, t1.opendate)) tmp
inner join #t1 t1 on t1.ID = tmp.ID and t1.opendate = tmp.opendate and tmp.row = 1
</code></pre>
|
perl - searching in list of objects which are an accessor of another object <p>I am a Perl-OO beginner and I am encountering a design-challenge. I hope you can give me some hints to get to an elegant solution. I am working with Mouse Object System here.</p>
<p>For a minimal example lets say I have a User-Object. A user has a name.</p>
<pre><code>package User;
use Mouse;
has "name" => (
is => "rw",
isa => "Str|Undef",
);
</code></pre>
<p>Then I have a User-Cache-Object, which gets a list of all Users (from an LDAP-Server). You can say this is a "has-a" Relationship between the User Cache and the User.</p>
<pre><code>package UserCache;
use Mouse;
has "users" => (
is => 'rw',
isa => 'ArrayRef|Undef',
default => sub { [] },
);
</code></pre>
<p>I store this list of Users as an Array of User-Objects in the accessor of the User-Cache.</p>
<pre><code> my $cache = UserCache->new();
foreach my $entry ( $ldap->searchGetEntries() ) {
my $user = User->new();
$user->name($entry->get_value('userdn'));
push @{ $cache->users }, $user;
}
</code></pre>
<p>Now this is where my Problem comes in. If I want to find a User-Object with specific attributes (e.g. a User named John), I have to loop over this whole Array of User-Objects and query each object for its name. When given a list of names, this gets a really inefficient process.</p>
<pre><code>foreach my $user ( @{ $cache->users } ) {
if ( $user->name eq 'John' ) {
#do something with John
}...
}
</code></pre>
<p>Is there a way of storing Lists of Objects in other Objects in a way, that I can efficently search? Like <em>$cache->get_users->get_name('John')</em> and that returns the object I need?</p>
| <p>You don't really have to write the <code>UserCache</code> class yourself. Instead, use <a href="https://metacpan.org/pod/CHI" rel="nofollow">CHI</a> to cache users you want to cache under the key you want to use for lookups. If you want, you can wrap your cache class to abstract away from the specific cache implementation.</p>
<p>Also, you have this:</p>
<pre><code>push @{ $cache->users }, $user;
</code></pre>
<p>where you leak implementation details. Instead, your <code>UserCache</code> object needs something like a <code>save_user</code> method so the code it uses does not depend on the implementation details.</p>
<pre><code>$cache->save_user( $user );
</code></pre>
<p>For Moose objects, you get <a href="https://metacpan.org/pod/Moose::Meta::Attribute::Native::Trait::Array" rel="nofollow">Moose::Meta::Attribute::Native::Trait::Array</a>; for Mouse, you get <a href="https://metacpan.org/pod/MouseX::NativeTraits::ArrayRef" rel="nofollow">MouseX::NativeTraits::ArrayRef</a>.</p>
|
Dynamically create page based on ListModel count <p>I am a beginner QT/QML app development</p>
<p>How can I create a qml dynamically based on the ListModel count.
In the view I am listing the modelObjects in a GridLayout using Repeater.</p>
<pre><code>Item{
id:griditem
anchors.fill:parent
GridLayout{
id: grid2
x:145
y:30
Layout.preferredHeight: 480
Layout.preferredWidth: 1135
rowSpacing:10
columnSpacing:40
columns: 3
rows: 2
Repeater{
id: repeater_Id
model: FeatureModel{}
Loader{
id: loader_Id
source: "QuadTiles.qml"
onLoaded: {
loader_Id.item.nIndex=index
loader_Id.item.type_String = type
loader_Id.item.title_Text.text = title
loader_Id.item.description_Text.text = description
loader_Id.item.btn1_icon.source = icon1
}
}
} //Repeater
}//GridLayout
}
</code></pre>
<p><strong>Edit :</strong>
I am facing some issues
I need to create new views dynamically based on the ModelList count. Each page having maximum 6 item (3 rows and 2 columns) in GridLayout</p>
<p>'QuadTiles.qml' is the qml file which is load in to each item of GridLayout</p>
| <p>Try something like this:<br>
<code>lm</code> is the <code>ListModel</code> that is to be split.</p>
<pre><code>SwipeView {
width: 200
height: 800
clip: true
currentIndex: 0
Repeater {
model: Math.ceil(lm.count / 6)
delegate: ListView {
width: 200
height: 800
property int viewIndex: index
model: DelegateModel {
model: lm
groups: DelegateModelGroup { name: 'filter' }
Component.onCompleted: {
for (var i = viewIndex * 6; i < lm.count && i < (viewIndex * 6) + 6; i++) {
items.setGroups(i, 1, ['items', 'filter'])
}
}
filterOnGroup: 'filter'
delegate: Rectangle {
width: 180
height: 30
border.width: 1
Text {
anchors.centerIn: parent
text: index
}
}
}
}
}
}
</code></pre>
<p>And don't use a <code>Loader</code> as a delegate. The delegates are instantiated dynamically, so the <code>Loader</code> is just useless overhead. You might use a <code>Loader</code> within your delegate for parts, that are usually not shown.</p>
|
receiving ambiguous sky screen while loading google map <p>while loading google map on device i am receiving below screen sometimes.it comes on second load as shown below.<a href="https://i.stack.imgur.com/iFBb9.png" rel="nofollow"><img src="https://i.stack.imgur.com/iFBb9.png" alt="google map"></a> otherwise it comes perfectly as normal google map with route I am using SupportmapFragment and get googleMap object as.</p>
<pre><code> supportMapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map_view_fragment);
</code></pre>
<p>below is code for displaying map in activity/fragment</p>
<pre><code>public static void drawRouteIntoMap(final List<? extends MapHelper> position, final GoogleMap googleMap) {
/*List<MapHelper> position = new ArrayList<MapHelper>();
for (int i = lastPosition; i < maps.size(); i++) {
position.add(maps.get(i));
}*/
final LatLngBounds.Builder mapBounds = new LatLngBounds.Builder();
if (position.size() > 0 && Validator.isNotNull(googleMap)) {
googleMap.clear();
List<PolylineOptions> polylineOptionses = new ArrayList<PolylineOptions>();
PolylineOptions option = null;
Boolean lastPause = null;
for (MapHelper map : position) {
if (map.isPause()) {
if (Validator.isNull(lastPause) || !lastPause) {
option = new PolylineOptions().width(5).color(Color.rgb(255, 0, 155)).geodesic(true);
polylineOptionses.add(option);
}
mapBounds.include(new LatLng(map.getLatitude(),map.getLongitude()));
option.add(new LatLng(map.getLatitude(), map.getLongitude()));
} else {
if (Validator.isNull(lastPause) || lastPause) {
option = new PolylineOptions().width(5).color(Color.rgb(0, 179, 253)).geodesic(true);
polylineOptionses.add(option);
}
mapBounds.include(new LatLng(map.getLatitude(),map.getLongitude()));
option.add(new LatLng(map.getLatitude(), map.getLongitude()));
}
lastPause = map.isPause();
}
for (PolylineOptions options : polylineOptionses) {
googleMap.addPolyline(options);
}
if(Validator.isNotNull(option)){
//List<LatLng> points = option.getPoints();
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
LatLng startPoint = new LatLng(position.get(0).getLatitude(), position.get(0).getLongitude());
googleMap.addMarker(new MarkerOptions().position(startPoint).title("start").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
mapBounds.include(startPoint);
LatLng endPoint = new LatLng(position.get(position.size() - 1).getLatitude(), position.get(position.size() - 1).getLongitude());
mapBounds.include(endPoint);
googleMap.addMarker(new MarkerOptions().position(endPoint).title("finish").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.setPadding(15, 205, 10, 110);
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(mapBounds.build(), 0));
//googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(mapBounds.build(), 10));
googleMap.moveCamera(CameraUpdateFactory.zoomOut());
}
});
}
}
}
</code></pre>
<p>this question is in relation with <a href="http://stackoverflow.com/questions/39656911/zoom-over-specific-route-google-map">zoom over specific route google map</a>.
by using that i get proper route with mapbounds but i m not getting why this screen is displaying.</p>
| <p>This problem occurs when your coordinates are not properly set. Make sure the coordinates that you are using is pointing in the land to get the maps correctly. Another possible reason is your API key is not working, try to generate new API key for this project.</p>
<p>For more information, check these related SO questions.</p>
<ul>
<li><p><a href="http://stackoverflow.com/questions/11151683/android-google-maps-return-error-and-blue-screen">Android google maps return error and blue screen</a></p></li>
<li><p><a href="http://stackoverflow.com/questions/12113009/blue-screen-in-android-google-maps">Blue screen in Android Google Maps</a></p></li>
</ul>
|
Place in new div when match space in string <p>I have this html</p>
<pre><code><span class="item-title">Title</span>
<span class="item-cat">sub-text</span>
</code></pre>
<p>I have in database string like <code>Title sub-text</code>. How can I place <code>sub-text</code> in bottom <code><span></code> when str_replace match space? I've tried something like this</p>
<pre><code><span class="item-title">'.str_replace(' ',"<span class="item-cat">sub-text</span>",$row['category']).'</span>
</code></pre>
<p>But seems not right because I don't know how to divide the string and show only second part in second div. Any help is appreciated.</p>
| <p>In case of sub-text won't have any spaces you can simply use <a href="http://php.net/manual/en/function.explode.php" rel="nofollow">explode()</a> function create two strings. One for title and another one for sub-text.</p>
<p>Code would look seomthing like this,</p>
<pre><code><?php
$mainTitle="Title sub-text";
$parts=explode(" ",$mainTitle);
?>
<span class="item-title"><?php echo $parts[0]; ?></span>
<span class="item-cat"><?php echo $parts[1]; ?></span>
<?php // Other code ?>
</code></pre>
<blockquote>
<p><strong>explode()</strong> just split the string by space( in this case) which will create array of two elements, of which first one is <code>title</code> and second
one would be <code>sub-text</code>.</p>
</blockquote>
|
R add a new column to dataframe using mutate_ where column name is specified by a variable <p>I have a dataframe, that I want to add a column to, where the column is defined by a variable name:</p>
<pre><code>df <- diamonds
NewName <- "SomeName"
df <- df %>% mutate_(paste0(NewName," = \"\""))
</code></pre>
<p>This gives me the following error:</p>
<pre><code>Error: attempt to use zero-length variable name
</code></pre>
<p>I've seen plenty of examples of mutate_ being used to change column names, but not to dynamically create columns. Any help?</p>
| <p>The issue has to do with when the evaluation of the statement is occurring. By my understanding, the goal of <code>mutate_</code> is not to recreate the syntax of <code>mutate</code>, for example using <code>paste</code> to create <code>mutate(SomeName = "")</code>. Instead, it is to allow generation of functions to pass. The reason your approach is failing is (I believe) the fact that it is looking for a function named <code>""</code>.</p>
<p>Instead, you need to pass in a function that can be evaluated (here, I am using <code>paste</code> as a placeholder) and set the name of that column using your variable. This should work:</p>
<pre><code>df <- diamonds
NewName <- "SomeName"
df <- df %>% mutate_(.dots = setNames("paste('')",NewName))
</code></pre>
<p>This also allows more control, for example, you could paste <code>cut</code> and <code>color</code>:</p>
<pre><code>df <- df %>% mutate_(.dots = setNames("paste(cut, color)",NewName))
</code></pre>
<p>gives:</p>
<pre><code> carat cut color clarity depth table price x y z SomeName
<dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <chr>
1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 Ideal E
2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 Premium E
3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 Good E
4 0.29 Premium I VS2 62.4 58 334 4.20 4.23 2.63 Premium I
5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 Good J
6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 Very Good J
7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47 Very Good I
8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53 Very Good H
9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49 Fair E
10 0.23 Very Good H VS1 59.4 61 338 4.00 4.05 2.39 Very Good H
</code></pre>
<p>(Of note, I also got the initial syntax to work the first time, followed by subsequent failures. Worth digging into.)</p>
|
Can you use a npm package without using NodeJS <p>I found a library on github that I would like to use but the download instructions only mention using npm but I am not using a NodeJS project (just a basic html,css,javascript front-end with no back-end server). Am I still able to use that library or is it a lost cause? Is there another way to download it without using npm?</p>
| <blockquote>
<p>Is there another way to download it without using npm?</p>
</blockquote>
<p>If it's on github, then you can checkout or fork the repository as you can with any other git repo.</p>
<blockquote>
<p>Am I still able to use that library or is it a lost cause?</p>
</blockquote>
<p>Whether or not the library will work without Node will depend on the library. </p>
<p>If it presents itself as a Node module, then you'll probably have to modify it (or find a compatible <em>module loader</em> for browser-side JS).</p>
<p>If it depends on NodeJS features (such as the filesystem API) then you'll be out of luck (unless, for example, you polyfill them to work across HTTP)</p>
|
Azure Storage and Data Management <p>I have shutdown the VM in Azure Portal and the status was "Stopped(Deallocated)" but their was a billing process alive for Storage and Data Management, Do anyone know how to Stop these to avoid Billing.</p>
| <p>As you may already know, VHDs containing OS and Data disks for your VM are stored as Page Blobs in your Azure Storage account. One of the things you get charged for in Azure Storage is how much storage you're using and this is what you're getting charged for.</p>
<p>Deallocating the VM will only stop the billing for the VM. </p>
<p>To stop the billing for the storage, you would need to delete the page blobs holding your OS/Data disks. You can accomplish the same by deleting the VM.</p>
<p>Please note that if you delete these blobs, you're essentially losing everything for that VM and you will need to start from scratch if you ever need the VM again. </p>
|
Lambda from API gateway VS kinesis Streams <p><strong>Background</strong></p>
<p>i am studying about AWS kinesis,API gateway.</p>
<p>I understand that ,whenever requests hit API gateway,i can forward the data to a stream or i can choose to trigger a lambda(which will do some processing ).</p>
<p><strong>Thoughts and Query</strong></p>
<p>So,my thought was,if i can directly ,trigger a lambda from API gateway(When requests arrive,it is realtime),what is the advantage of having a kinesis stream(for realtime data processing)?</p>
<p>I could remove the streams and directly trigger lambda from API gateway(even create multiple APIs for different tasks)</p>
<p>Any thoughts in this scenario!</p>
| <p>It depends on frequency of client accesses and time-length of your lambda function.</p>
<p>The number of concurrent executions of lambda function is limited to 100. When lambda is throttled, retrying approaches are different between API Gateway and Kinesis stream.</p>
<p>See <a href="https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html" rel="nofollow">https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html</a> .</p>
<p>You might want to check the estimation of the request rate.</p>
<p>In addition, keep in mind that Kinesis stream guarantees the order that data arrived in a shard.</p>
|
Can i compile java for an older Java version with ant with a newer JDK so it generates output when it compiles code that uses the newer API? <p>I would like to only have JDK 8 installed on my system, and have the ant javac compile action create working classfiles for a java 6 environment.</p>
<p>This sort of works if I syntactically only use java 6 compliant code, but my code can access methods/classes of the java 8 API and still be java 6 compliant according to ant's compile action. </p>
<p>This is even the case when using the "javac" task attributes "source" and "target" set to java 6. I am aware that this generates the following warning: [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6. But this is not the type of warning that helps me detect if my code actually uses newly introduced API elements.</p>
<p>I need the compile action to somehow do something when the code that's being compiled tries to make use of java 8 API introduced methods/classes.</p>
<p>As an example: with java 6 compliant code I can access java.lang.reflect.Constructor.getParameters() if copmiled using JDK 8, which is a method inherited from a Java 8 introduced parent class Executable. When the code runs in a java 6 exeuction environment, executing that statement will result in a thrown NoSuchMethodException, unforseen and thusly unhandled as well. I need my ant compile action generate some different kind of output (a halt or a warning or something else) so that I can automate something on that. </p>
<p>Is there an ant-related solution for me in this scenario?</p>
| <p>You write:</p>
<blockquote>
<p>I am aware that this generates the following warning: [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6.</p>
</blockquote>
<p>This warning points us toward the correct solution. In addition to the <code>-source</code> and <code>-target</code> options, use <code>javac</code>'s <code>-bootclasspath</code> option to specify a bootstrap class path pointing to the <code>rt.jar</code> of <code>1.6</code>. You do not have to have a complete JDKÂ 1.6 on you computer; that jar, which contains the API classes, is sufficient.</p>
<p>Oracle has <a href="http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html#BHCIJIEG" rel="nofollow">further instructions and options for cross-compiling</a> on its website.</p>
<p>Note that this issue is addressed by <a href="http://openjdk.java.net/jeps/247" rel="nofollow">JEP 247</a>, which hopefully will make it into the Java 9 release. Then, there will be a <code>-release</code> compiler option, combining <code>-source</code>, <code>-target</code> and <code>-bootclasspath</code> with an appropriate file shipping with the JDK itself. So you donât need to get that <code>rt.jar</code> from an older JDK anymore.</p>
|
AngularJS: How do I share data accross all pages and controller of my SPA? <p>What is the best way to share some data across all controllers and scopes of my Single page application ? </p>
<p>Let say i have a small set of data I want to be able to access everywhere, and I don't want to query the database every time I need it.</p>
| <p>The data to be stored in $rootscope variable</p>
<p>(or)</p>
<p>data to be stored in services</p>
|
SoftLayer API: Provision Server with Basic RAID Configuration <p>How do you get the appropriate RAID configured on a server order issued through the API? </p>
<p>When attempting to provision a server using the SoftLayer API, we can never get it to properly provision even basic configurations. </p>
<p>After reading <a href="https://sldn.softlayer.com/blog/hanskristian/ordering-raid-through-api" rel="nofollow">https://sldn.softlayer.com/blog/hanskristian/ordering-raid-through-api</a>, the assumption is that if these criteria are true:</p>
<ol>
<li>All disks are the same;</li>
<li>A RAID controller is selected with a specific RAID type; and</li>
<li>An appropriate number of disks are ordered</li>
</ol>
<p>That a single RAID group will be configured as requested. </p>
<p>The problem is, we've ordered servers repeatedly using this recommendation and we've never received the proper configuration. To make matters worse, we've never received the same configuration. </p>
<p>Most recently, we wanted a server configured with RAID10 using 6 SSD drives. Here is the payload submitted: </p>
<pre><code>{
"parameters": [
{
"packageId": 271,
"location": 449494,
"quantity": 1,
"hardware": [{
"hostname": "server-name",
"domain": "domain.com",
"primaryBackendNetworkComponent": {
"networkVlanId": 1235
},
"primaryNetworkComponent": {
"networkVlanId": 1234
}
}],
"prices": [
{"id": 163397},
{"id": 49447},
{"id": 141807},
{"id": 141807},
{"id": 141807},
{"id": 141807},
{"id": 141807},
{"id": 141807},
{"id": 29691},
{"id": 27597},
{"id": 50243},
{"id": 37622},
{"id": 34807},
{"id": 32500},
{"id": 33483},
{"id": 35310},
{"id": 27023},
{"id": 32627},
{"id": 25014},
{"id": 50223}
]
}
]
}
</code></pre>
<p>Before submitting the payload, we checked it against <a href="https://api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json" rel="nofollow">https://api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json</a> to ensure that it showed RAID 10. It did. </p>
<p>After receiving the servers posted with this configuration, this is the topology of the RAID card:</p>
<pre><code>TOPOLOGY :
========
------------------------------------------------------------------------
DG Arr Row EID:Slot DID Type State BT Size PDC PI SED DS3 FSpace
------------------------------------------------------------------------
0 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
0 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
0 0 0 8:0 9 DRIVE Onln N 1.091 TB dflt N N dflt -
1 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
1 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
1 0 0 8:1 12 DRIVE Onln N 1.091 TB dflt N N dflt -
2 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
2 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
2 0 0 8:2 10 DRIVE Onln N 1.091 TB dflt N N dflt -
3 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
3 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
3 0 0 8:3 13 DRIVE Onln N 1.091 TB dflt N N dflt -
4 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
4 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
4 0 0 8:4 11 DRIVE Onln N 1.091 TB dflt N N dflt -
5 - - - - RAID0 Optl N 1.091 TB dflt N N dflt N
5 0 - - - RAID0 Optl N 1.091 TB dflt N N dflt N
5 0 0 8:5 14 DRIVE Onln N 1.091 TB dflt N N dflt -
------------------------------------------------------------------------
</code></pre>
<p>This doesn't even come resemble what we requested. What payload do we need for RAID 10 to provision it reliably and repeatedly? </p>
<p><strong>Update</strong>: After checking servers ordered via the API with other RAID configurations, such as RAID1, this is not confined to RAID10. This problem exhibits with RAID1 requests with 2 identical disks. </p>
| <p>In your payload is missing the raid configuration, it should be something like this:</p>
<pre><code>{
"parameters": [{
"packageId": 271,
"location": 449494,
"quantity": 1,
"hardware": [{
"hostname": "server-name",
"domain": "domain.com",
"primaryBackendNetworkComponent": {
"networkVlanId": 1235
},
"primaryNetworkComponent": {
"networkVlanId": 1234
}
}],
"prices": [{
"id": 163397
}, {
"id": 49447
}, {
"id": 141807
}, {
"id": 141807
}, {
"id": 141807
}, {
"id": 141807
}, {
"id": 141807
}, {
"id": 141807
}, {
"id": 29691
}, {
"id": 27597
}, {
"id": 50243
}, {
"id": 37622
}, {
"id": 34807
}, {
"id": 32500
}, {
"id": 33483
}, {
"id": 35310
}, {
"id": 27023
}, {
"id": 32627
}, {
"id": 25014
}, {
"id": 50223
}]
}],
"storageGroups": [{
"arraySize": 1200,
"arrayTypeId": 5,
"hardDrives": [
0,
1,
2,
3,
4,
5
],
"partitionTemplateId": 6
}]
}
</code></pre>
<p>See the description for the properties here: <a href="http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Storage_Group" rel="nofollow">http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Storage_Group</a></p>
<p><code>"arrayType: 5"</code> is the configuration for the RAID10 you can get all the RAID options using this method <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Configuration_Storage_Group_Array_Type/getAllObjects" rel="nofollow">http://sldn.softlayer.com/reference/services/SoftLayer_Configuration_Storage_Group_Array_Type/getAllObjects</a></p>
<p>See this: <a href="http://stackoverflow.com/questions/35486839/configuring-softlayer-disk-partitions-at-order-time">Configuring Softlayer Disk Partitions at Order Time</a>
for to know more about the partitions templates and RAID configuration</p>
<p>Regards</p>
|
Jquery form validation <p>I am having issues merging my currently; page separated input validation onto a single webpage.
Here is my attempt but it wont call both of the functions, any idea why</p>
<p>Jquery:</p>
<pre><code> <script>
function isValidPassword(Passwordreg){
var pattern = new RegExp(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/);
return pattern.test(Passwordreg);
};
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
return pattern.test(emailAddress);
};
$( document ).ready(function(){
$("#email" ).focus();
$( "#email" ).blur(function() {
checkEmail($("#email").val());
});
$( "#email" ).keydown(function() {
checkEmail($("#email").val());
$( "#Password" ).blur(function() {
checkPassword($("#Password").val());
});
$( "#Password" ).keydown(function() {
checkPassword($("#Password").val());
});
function checkPassword(Pword){
if(!isValidPassword($("#Password" ).val())){
$( "#passwordError" ).html("Does Not Match the Reqirements");
$("#emailError" ).addClass("error");
$('input[type="submit"]').prop('disabled', true);
return false;
}else{
$( "#passwordError" ).html("");
$("#Password" ).removeClass("error");
$('input[type="submit"]').prop('disabled', false);
return true;
}
}
function checkEmail(emailAddie){
if(!isValidEmailAddress($("#email" ).val())){
$( "#emailError" ).html("Please inert a correctly layed out email address");
$("#email" ).addClass("error");
$('input[type="submit"]').prop('disabled', true);
return false;
}else{
$( "#emailError" ).html("");
$("#email" ).removeClass("error");
$('input[type="submit"]').prop('disabled', false);
return true;
}
}
$("#submitB").click(function(e) {
if(!checkPassword($("#Password").val())){
e.preventDefault();
}
});
});
</script>
</code></pre>
<p>And my form has 6 inputs on it but we only need to focus on the 2</p>
<pre><code><form>
<label for="email">Username / Email address</label>
<input id="email" type="text" name="email" ><span id="emailError"></span>
<label for="Password">Password</label>
<input id="Password" type="password" name="Password" ><span id="passwordError"></span>
</form>
</code></pre>
<p>Again these functions work if i try to call them separately with the triggers I have set-up, but they fail when I try to monitor both inputs at once</p>
| <p>You have a syntax error n your code. So it is not working for you.</p>
<p>Here is the fixed code.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function isValidPassword(Passwordreg){
var pattern = new RegExp(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/);
return pattern.test(Passwordreg);
};
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
return pattern.test(emailAddress);
};
$( document ).ready(function(){
$("#email" ).focus();
$( "#email" ).blur(function() {
checkEmail($("#email").val());
});
$( "#email" ).keydown(function() {
checkEmail($("#email").val());
$( "#Password" ).blur(function() {
checkPassword($("#Password").val());
});
$( "#Password" ).keydown(function() {
checkPassword($("#Password").val());
});
});
function checkPassword(Pword){
if(!isValidPassword($("#Password" ).val())){
$( "#passwordError" ).html("Does Not Match the Reqirements");
$("#emailError" ).addClass("error");
$('input[type="submit"]').prop('disabled', true);
return false;
}else{
$( "#passwordError" ).html("");
$("#Password" ).removeClass("error");
$('input[type="submit"]').prop('disabled', false);
return true;
}
}
function checkEmail(emailAddie){
if(!isValidEmailAddress($("#email" ).val())){
$( "#emailError" ).html("Please inert a correctly layed out email address");
$("#email" ).addClass("error");
$('input[type="submit"]').prop('disabled', true);
return false;
}else{
$( "#emailError" ).html("");
$("#email" ).removeClass("error");
$('input[type="submit"]').prop('disabled', false);
return true;
}
}
$("#submitB").click(function(e) {
if(!checkPassword($("#Password").val())){
e.preventDefault();
}
});
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
<script data-require="jquery" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<script src="script.js"></script>
</head>
<body>
<form>
<label for="email">Username / Email address</label>
<input id="email" type="text" name="email" ><span id="emailError"></span>
<label for="Password">Password</label>
<input id="Password" type="password" name="Password" ><span id="passwordError"></span>
</form>
<!-- Put your html here! -->
</body>
</html></code></pre>
</div>
</div>
</p>
<p><a href="https://plnkr.co/edit/fSbsFcqMwAx24kXGv2QX?p=preview" rel="nofollow">Here is a plunker</a></p>
|
Handsontable: When scroll vertically up and down, I got the css style removed <p>I am using a handsontable, I customize the error in cells.</p>
<pre><code>var cell = hot.getCell(rowKey, id);
$(cell).css('background-color', '#ff4c42');
$(cell).text(message);
$(cell).css('color', 'white');
</code></pre>
<p>Now when I scroll up and down and cells with error style disappeared, when I scroll to them again the style disappeared!</p>
| <p>I made this example <a href="http://jsfiddle.net/car3673r/" rel="nofollow">JSFiddle</a> for you.</p>
<pre><code>afterValidate: function(isValid, value, row, prop, source) {
if (row == 2 && hot.propToCol(prop) == 2) {
hot.setDataAtCell(row, hot.propToCol(prop), 'error');
}
},
invalidCellClassName: 'myInvalidClass',
</code></pre>
<p>You need to declare a validator and set a invalidClass in your css.</p>
<p>You can't update the css with your method because the Handsontable settings doesn't have this parameters and when you scroll, it re-render the table and "delete" your changes.</p>
|
Using automapper for mapping <p>I have a class <strong>City</strong> with properties <strong>CityID</strong> and <strong>CityName</strong> in <strong>Util layer</strong> of a project. I have another class <strong>CityVM</strong> that is present in <strong>ViewModel Layer</strong> with the same properties. I want to map the properties of City Util class to CityVM class using <strong>Automapper</strong>. How can I achieve that?
Thanks for the answer in advance.</p>
<p><strong>Edit</strong></p>
<p>It's throwing exception when I am trying to map.</p>
<pre><code>"Missing type map configuration or unsupported mapping"
</code></pre>
| <p>The Exception says that AutoMapper don't know the mapping that you have specified for it. As stated in the <a href="https://github.com/AutoMapper/AutoMapper/wiki/Getting-started#how-do-i-use-automapper" rel="nofollow">Getting Started Guide</a>, you can try:</p>
<pre><code>var config = new MapperConfiguration(cfg => cfg.CreateMap<Order, OrderDto>());
var mapper = config.CreateMapper();
OrderDto dto = mapper.Map<OrderDto>(order);
</code></pre>
<p>But this solution is Config based, you can define multiple Mappers with different Configs, but it prevents you from using the static <code>Mapper.Map<T>()</code> method. If you need just one Mapper, you can create you Mappings static:</p>
<pre><code>Mapper.Initialize(cfg => cfg.CreateMap<Order, OrderDto>());
OrderDto dto = Mapper.Map<OrderDto>(order);
</code></pre>
<p><strong>Edit</strong></p>
<p>You don't need to Map Lists. Instead of mapping</p>
<pre><code>Mapper.Initialize(cfg => cfg.CreateMap<List<Util.City>, List<City>>());
</code></pre>
<p>use</p>
<pre><code>Mapper.Initialize(cfg => cfg.CreateMap<Util.City, City>());
</code></pre>
<p>And then call:</p>
<pre><code>List<Util.City> cityList = Mapper.Map<Util.City[]>(cityList).ToList();
</code></pre>
<p>Please Note, while creating a Map, on the left side is the Source class and on the right side is your destination class. Your Mapping is wrong. It should look:</p>
<pre><code>Mapper.Initialize(cfg => cfg.CreateMap<City, Util.City>());
</code></pre>
|
Differentiate missing values from main data in a plot using R <p>I create a dummy timeseries <code>xts</code> object with missing data on date 2-09-2015 as:</p>
<pre><code>library(xts)
library(ggplot2)
library(scales)
set.seed(123)
seq <- seq(as.POSIXct("2015-09-01"),as.POSIXct("2015-09-02"), by = "1 hour")
ob1 <- xts(rnorm(length(seq),150,5),seq)
seq2 <- seq(as.POSIXct("2015-09-03"),as.POSIXct("2015-09-05"), by = "1 hour")
ob2 <- xts(rnorm(length(seq2),170,5),seq2)
final_ob <- rbind(ob1,ob2)
plot(final_ob)
# with ggplot
df <- data.frame(time = index(final_ob), val = coredata(final_ob) )
ggplot(df, aes(time, val)) + geom_line()+ scale_x_datetime(labels = date_format("%Y-%m-%d"))
</code></pre>
<p>After plotting my data looks like this:
<a href="https://i.stack.imgur.com/3FRKP.png" rel="nofollow"><img src="https://i.stack.imgur.com/3FRKP.png" alt="enter image description here"></a></p>
<p>The red coloured rectangular portion represents the date on which data is missing. How should I show that data was missing on this day in the main plot?</p>
<p>I think I should show this missing data with a different colour. But, I don't know how should I process data to reflect the missing data behaviour in the main plot.</p>
| <p>Thanks for the great reproducible example.
I think you are best off to omit that line in your "missing" portion. If you have a straight line (even in a different colour) it suggests that data was gathered in that interval, that happened to fall on that straight line. If you omit the line in that interval then it is clear that there is no data there.</p>
<p>The problem is that you want the hourly data to be connected by lines, and then no lines in the "missing data section" - so you need some way to detect that missing data section.</p>
<p>You have not given a criteria for this in your question, so based on your example I will say that each line on the plot should consist of data at hourly intervals; if there's a break of more than an hour then there should be a new line. You will have to adjust this criteria to your specific problem. All we're doing is splitting up your dataframe into bits that get plotted by the same line.</p>
<p>So first create a variable that says which "group" (ie line) each data is in:</p>
<pre><code>df$grp <- factor(c(0, cumsum(diff(df$time) > 1)))
</code></pre>
<p>Then you can use the <code>group=</code> aesthetic which <code>geom_line</code> uses to split up lines:</p>
<pre><code>ggplot(df, aes(time, val)) + geom_line(aes(group=grp)) + # <-- only change
scale_x_datetime(labels = date_format("%Y-%m-%d"))
</code></pre>
<p><a href="https://i.stack.imgur.com/nzA0e.png"><img src="https://i.stack.imgur.com/nzA0e.png" alt="enter image description here"></a></p>
|
Create sandbox environment linux for c++ pc2 programming contest system <p>I want to hold a programing contest and use pc^2 <a href="http://pc2.ecs.csus.edu" rel="nofollow">Programming Contest Control System</a><br>
My server is Ubuntu and when someone submit a code to the server pc2 will compile the file and run it but there is problem here how can I prevent attacks to my server because I don't actually check source file it may contain dangerous code and remove or delete my system file even pc2 application files I search Google but I find some method like <strong>chroot</strong> but it still have problem for example if I create sandbox with <strong>chroot</strong> and put my pc2 file inside my sandbox it can delete my pc2 file and if I put my pc2 files outside of my sandbox it doesn't have permission to run so it there any way to solve this problem ?<br>
sorry my English is week it's not my native</p>
| <p>You may look into <a href="https://en.wikipedia.org/wiki/Linux_containers" rel="nofollow">Linux containers</a>, like <a href="https://www.docker.com/" rel="nofollow">Docker</a> or <a href="https://linuxcontainers.org/" rel="nofollow">LXC</a>, and <a href="https://en.wikipedia.org/wiki/UnionFS" rel="nofollow">union filesystems</a>.</p>
<p>This allows you to isolate users from each other, and restrict the usage of OS resources. Furthermore, you can have a readonly base filesystem, which will hold the main system, compilers and tools. On top of that, you can have a writable filesystem, where the code can be compiled and run.</p>
<p>If anything happens to the upper writable filesystem, you may throw it away and create a new one with minimal overhead.</p>
|
How to add variable to header.php controller and use it in header.tpl <p>I am creating a custom theme for OpenCart 2.3 and I need to show some additional information in page header (header.tpl). So I added some variable to catalog/controller/common/header.php:</p>
<pre><code>$data['some_var'] = 'some_value';
</code></pre>
<p>And then I am trying to use this data in the header.tpl:</p>
<pre><code><?php echo $this->data['some_var']; ?>
</code></pre>
<p>But I am always getting this error:</p>
<p>Notice: Undefined index: some_var in /var/www/store_com/public_html/catalog/view/theme/mystore/template/common/header.tpl on line 133</p>
<p>If I try to use this code:</p>
<pre><code><?php echo $some_var; ?>
</code></pre>
<p>Then I am getting another error:</p>
<p>Notice: Undefined variable: some_var in /var/www/store_com/public_html/catalog/view/theme/mystore/template/common/header.tpl on line 133</p>
<p>And even when I do <strong>echo print_r($this->data)</strong> in header.tpl I don't even see this variable in $data array.</p>
<p>What am I doing wrong? Please help.</p>
<p><strong>EDIT</strong><br/>
Here is the full code of my header.php controller file. I added my custom variable at the very end of the file.</p>
<pre><code>class ControllerCommonHeader extends Controller {
public function index() {
// Analytics
$this->load->model('extension/extension');
$data['analytics'] = array();
$analytics = $this->model_extension_extension->getExtensions('analytics');
foreach ($analytics as $analytic) {
if ($this->config->get($analytic['code'] . '_status')) {
$data['analytics'][] = $this->load->controller('extension/analytics/' . $analytic['code'], $this->config->get($analytic['code'] . '_status'));
}
}
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
$this->document->addLink($server . 'image/' . $this->config->get('config_icon'), 'icon');
}
$data['title'] = $this->document->getTitle();
$data['base'] = $server;
$data['description'] = $this->document->getDescription();
$data['keywords'] = $this->document->getKeywords();
$data['links'] = $this->document->getLinks();
$data['styles'] = $this->document->getStyles();
$data['scripts'] = $this->document->getScripts();
$data['lang'] = $this->language->get('code');
$data['direction'] = $this->language->get('direction');
$data['name'] = $this->config->get('config_name');
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
$this->load->language('common/header');
$data['text_home'] = $this->language->get('text_home');
// Wishlist
if ($this->customer->isLogged()) {
$this->load->model('account/wishlist');
$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
} else {
$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
}
$data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
$data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', true), $this->customer->getFirstName(), $this->url->link('account/logout', '', true));
$data['text_account'] = $this->language->get('text_account');
$data['text_register'] = $this->language->get('text_register');
$data['text_login'] = $this->language->get('text_login');
$data['text_order'] = $this->language->get('text_order');
$data['text_transaction'] = $this->language->get('text_transaction');
$data['text_download'] = $this->language->get('text_download');
$data['text_logout'] = $this->language->get('text_logout');
$data['text_checkout'] = $this->language->get('text_checkout');
$data['text_category'] = $this->language->get('text_category');
$data['text_all'] = $this->language->get('text_all');
$data['home'] = $this->url->link('common/home');
$data['wishlist'] = $this->url->link('account/wishlist', '', true);
$data['logged'] = $this->customer->isLogged();
$data['account'] = $this->url->link('account/account', '', true);
$data['register'] = $this->url->link('account/register', '', true);
$data['login'] = $this->url->link('account/login', '', true);
$data['order'] = $this->url->link('account/order', '', true);
$data['transaction'] = $this->url->link('account/transaction', '', true);
$data['download'] = $this->url->link('account/download', '', true);
$data['logout'] = $this->url->link('account/logout', '', true);
$data['shopping_cart'] = $this->url->link('checkout/cart');
$data['checkout'] = $this->url->link('checkout/checkout', '', true);
$data['contact'] = $this->url->link('information/contact');
$data['telephone'] = $this->config->get('config_telephone');
// Menu
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}
$data['language'] = $this->load->controller('common/language');
$data['currency'] = $this->load->controller('common/currency');
$data['search'] = $this->load->controller('common/search');
$data['cart'] = $this->load->controller('common/cart');
// For page specific css
if (isset($this->request->get['route'])) {
if (isset($this->request->get['product_id'])) {
$class = '-' . $this->request->get['product_id'];
} elseif (isset($this->request->get['path'])) {
$class = '-' . $this->request->get['path'];
} elseif (isset($this->request->get['manufacturer_id'])) {
$class = '-' . $this->request->get['manufacturer_id'];
} elseif (isset($this->request->get['information_id'])) {
$class = '-' . $this->request->get['information_id'];
} else {
$class = '';
}
$data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
} else {
$data['class'] = 'common-home';
}
//CUSTOM THEME VARIABLES BEGIN
$data['some_var'] = 'some_value';
//CUSTOM THEME VARIABLES END
return $this->load->view('common/header', $data);
}
}
</code></pre>
| <p>I need to see your controller to get the full picture and then i will give you the full answer, but take a look on your controller and make sure that you bind your data like the sample below:</p>
<pre><code>if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/common/header.tpl', $data);
} else {
return $this->load->view('default/template/common/header.tpl', $data);
}
</code></pre>
<p>Thanks</p>
|
Error handling with c++ <p>I need to do some error handling in c++ that corrects user input if it's a letter or a string. I need to use .at(), .length(), and atoi to handle this. I'm not sure how/where to implement those is the problem. </p>
<pre><code>#include <iostream>
#include <stdlib.h>
#include <string>
#include <time.h>
using namespace std;
int main() {
srand(time(0));
int number;
number = rand() % 50 + 1;
int guess;
int x;
for (x = 5; x > 0; x--) {
cout << "Guess my number, it's between 0-50. You have 5 guesses: ";
cin >> guess;
if (guess < number){
cout << "Your guess was too low" << endl;
}
else if (guess > number){
cout << "You guess was too high" << endl;
}
else {
cout << "You're exactly right!" << endl;
break;
}
} while (guess != number){
break;
}
return 0;
</code></pre>
<p>}</p>
| <p>The best approach to input validation is to write a function that reads into a <code>std::string</code>, checks whatever is needed, and only returns a value when it passes the tests:</p>
<pre><code>int get_value() {
std::string input;
int value = -1;
while (value < 0) {
std::cout << "Gimme a value: ";
std::getline(std::cin, input);
try {
value = std::stoi(input);
} catch(...) {
value = -1;
}
}
return value;
}
</code></pre>
|
Include deployment timestamp into JSP page <p>I'm writing web applications with Java EE 7 using JSP and servlets, deploying to a local Wildfly 10 server.</p>
<p>To help me developing and testing my code, it would be useful to include a little timestamp into the displayed webpage, so that I can directly see when the version I'm looking at in my browser was deployed.</p>
<p>That would prevent me from both forgetting to deploy changes as well as from looking at old cached versions instead of the latest one.</p>
<p>How can I display the date and time when a Java EE web app got deployed to my Wildfly server directly on the webpage?</p>
<p>My IDE is Eclipse Neon for Java EE, if that matters.</p>
| <p>This is not deploytime, but starttime of the application. Maybe it is useful for your purpose. You can inject the class and use it to display data on your page.</p>
<pre><code>@Startup
@Singleton
public class Deploytime
{
private LocalDateTime starttime;
@PostConstruct
public void init() {
starttime = LocalDateTime.now();
}
}
</code></pre>
<p>Apart from that I can only think of <a href="https://github.com/ktoso/maven-git-commit-id-plugin" rel="nofollow">Maven Git Plugin</a> which can generate things like buildtime, commit id, ... into a propery file, which you can also use to display it on the page (if you use git/maven).</p>
|
Why does the browser not want to place the text between the <tr> tags? <p>I want to put the table rows with javascript in the HTML.
Why is <em>trRight</em> not between the <em>tr</em> tags?</p>
<p>I have also tested in other browsers and it's the same issue.</p>
<pre><code><!doctype html>
<html lang="en">
<body>
<table>
<tbody>
<!--Javascript puts code here-->
</tbody>
</table>
</body>
<script>
document.querySelector("tbody").innerHTML += "<tr>trRight</tr>";
document.querySelector("tbody").innerHTML += "<trWrong>trWrong</trWrong>";
</script>
</html>
</code></pre>
<p>Result:</p>
<p><a href="https://i.stack.imgur.com/QslMr.png" rel="nofollow"><img src="https://i.stack.imgur.com/QslMr.png" alt="result of the code"></a></p>
| <p><code><tr></code> is a table row it <a href="https://www.w3.org/TR/html-markup/tr.html" rel="nofollow">doesn't allow contents</a> to be placed other than <code><td></code> or <code><th></code>, you have to place your content only inside <code><td></code> like this:</p>
<pre><code>document.querySelector("tbody").innerHTML += "<tr><td>trRight</td></tr>";
</code></pre>
<p>While <code><trWrong></code> is not a valid tag, still browser considers it as a <a href="https://www.w3.org/TR/custom-elements/" rel="nofollow">custom tag</a> and hence encloses your text.</p>
<p><sub>[Thanks <a href="http://stackoverflow.com/users/828864/skyline3000">@skyline3000</a> for valid link for <code><tr></code> tag]</sub></p>
|
How to pass row $event to bootstrap modal in angular 2 <p>I am trying to delete a record from a table. The user clicks the delete button and it opens a confirmation box. The user clicks on the delete button in the box and then it should delete. I want to pass the row's $event to bootstrap modal so that I can get the cell details and process delete. Below is the code</p>
<pre><code><td>
<a href="#" style="color:brown" data-toggle="modal" data-target="#confirm-delete">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Confirm?
</div>
<div class="modal-body">
Are you sure that you want to delete the record?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a class="btn btn-danger btn-ok" (click)="deleteExpense($event)">Delete</a>
</div>
</div>
</div>
</div>
</code></pre>
<p>How to achieve this? Is there any better way?</p>
| <p>Better to create one Delete modal component for the same instead of using same code again and again
here is my code for the same , just pass the data of row and use like this</p>
<pre><code><delete (deleteFun)="DeleteElement(Number)" [pk]='Number'></delete>
</code></pre>
<p>you can see here working example </p>
<p><a href="http://plnkr.co/edit/AiDiNl8SrSKIwDUYWl50?p=preview" rel="nofollow">http://plnkr.co/edit/AiDiNl8SrSKIwDUYWl50?p=preview</a></p>
<p>PS: for more components see here</p>
<blockquote>
<p><a href="https://github.com/MrPardeep/Angular2-DatePicker" rel="nofollow">https://github.com/MrPardeep/Angular2-DatePicker</a></p>
</blockquote>
|
How to make scrollable html table columns responsive using bootstrap <p>I'm not a web designer. I was trying to design a web layout with some scrollable columns which contains some data in the form of anchor tags which are loaded dynamically. I've designed a <code>html table</code> structure along with a style sheet to achieve this. Source code of this table is as shown below</p>
<pre><code><table>
<tr>
<!--COLUMN HEADERS -->
<td id="titles" style="width: 50%">
<b style="padding-left: 4%">CURRENCY</b>
<b style="padding-left: 9%">COUNTRY</b>
<b style="padding-left: 8%">SECTOR</b>
<b style="padding-left: 4%">LOCATION COUNT</b>
</td>
</tr>
<tr>
<td style="width: 50%">
<!--1st COLUMN TO HOLD COUNTRY NAMES -->
<div id="column">
<div ng-repeat="currency in allCurrencies">
<a href=""
ng-click="filterProductByCurrency(currency); filterCountryByCurrency(currency); filterSectorByCurrency(currency)">
<span ng-bind="currency"></span> <br>
</a>
<input type="hidden" name="currencyHolder" ng-model="selCurrency">
</div>
</div>
<!--2nd COLUMN TO HOLD CURRENCY NAMES -->
<div id="column">
<div ng-repeat="country in allCountries">
<a href=""
ng-click="filterProductByCountry(country); filterSectorByCurrAndCtry(country)">
<span ng-bind="country"></span> <br>
</a>
<input type="hidden" name="countryHolder" ng-model="selCountry">
</div>
</div>
<!--3rd COLUMN TO HOLD SECTOR NAMES -->
<div id="column">
<div ng-repeat="sector in allSectors">
<a href="" ng-click="filterProductBySectors(sector); filterLocBySectors(sector)"> <span
ng-bind="sector"></span> <br>
</a>
<input type="hidden" name="variantHolder" ng-model="selVariant">
</div>
</div>
<!--4th COLUMN TO HOLD LOCATION COUNT RANGE -->
<div id="column">
<div ng-repeat="locCount in locationRangeValues">
<a href="" ng-click="filterProductByRange(locCount)">
<span ng-bind="locCount"></span> <br>
</a>
</div>
</div>
</td>
</tr>
</table>
</code></pre>
<p>And the <code>CSS</code> styling for class <code>coulmn</code> is as shown below</p>
<pre><code>#column {
background-color: #f5f5f5;
float: left;
width: 14%;
height: 125px;
overflow: auto;
overflow-y: scroll;
white-space: nowrap;
text-align: center;
}
</code></pre>
<p>And <code>CSS</code> styling for class for <code>titles</code> is as given below</p>
<pre><code>#titles{
background-color: #f5f5f5;
color: #069;
fill: #069;
}
</code></pre>
<p>This works fine, but the issue with this setup is it's not responsive. I've interagted bootstrap within my application. Is there any way to make this setup more responsive using bootstrap? Please help. </p>
| <p>To make any table responsive just place the table inside a <code><div></code> element and apply the class <code>.table-responsive</code> on it, as demonstrated in the example below:</p>
<pre><code><div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Row</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Biography</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John</td>
<td>Carter</td>
<td>johncarter@mail.com</td>
<td>Lorem ipsum dolor sit ametâ¦</td>
</tr>
<tr>
<td>2</td>
<td>Peter</td>
<td>Parker</td>
<td>peterparker@mail.com</td>
<td>Vestibulum consectetur scelerisqueâ¦</td>
</tr>
<tr>
<td>3</td>
<td>John</td>
<td>Rambo</td>
<td>johnrambo@mail.com</td>
<td>Integer pulvinar leo id risusâ¦</td>
</tr>
</tbody>
</table>
</div>
</code></pre>
<p>see working ex <a href="https://jsfiddle.net/DTcHh/26318/" rel="nofollow">here</a></p>
|
Azure ad group membership claims <p>I've set the groupMembershipClaims property in an app's manifest in Azure AD to "All", which should result in a user's security group memberships to be returned in the id token. </p>
<p>However, they are not being returned. Have tried to re-login multiple times. Is there something I am doing obviously wrong?</p>
| <p>Can you be more specific in terms of what exactly you are trying to achieve and how'd you want to do it.</p>
<p>Apparently, if the thing mentioned in your question is what exactly you are looking for and since the groupMembershipsClaims property is set to "All", you'll get the group claims in the JWT token. </p>
<p>You may want to read this article <a href="https://www.simple-talk.com/cloud/security-and-compliance/azure-active-directory-part-4-group-claims/" rel="nofollow">https://www.simple-talk.com/cloud/security-and-compliance/azure-active-directory-part-4-group-claims/</a> . This should help you resolve your issues.</p>
<p>Let me know in case you face this issue after you follow the procedure mentioned by the author.</p>
<p>Thank you and hope it helps.</p>
<p>Regards</p>
<p>Lakshminarayana Erukulla</p>
<p>Senior Development Engineer, <a href="http://imaginea.com/practices/microsoft" rel="nofollow">Team Imaginea</a></p>
<p>#Imaginea #ImagineaMSPractice</p>
|
SQL Trigger To Update <p>Good day I have an external Program that stores information in SQL, I am trying to do a trigger that Updates a table when some of the fields in that Table change.</p>
<p>So I have one column <code>Contractual Amount</code> that should be updated everytime any of the values in <code>ufAPCHANG1EAMNT</code>, <code>ufAPHANGE2AMNT</code> and <code>ufAPCHANGE3AMNT</code> changes.</p>
<p>A person can change one or all of these values and can be either +ve or -ve then if they are any changes to those fields the <code>Contractual Amount</code> should be updated accordingly but adding the +ve amount and subtracting the negative amount.</p>
<p>Please can you check my code and let me know where I am going wrong.</p>
<pre><code>ALTER trigger [dbo].[trgContractualAmt]
ON [dbo].[Vendor]
AFTER UPDATE
AS
declare
@IdI integer,
@value1 decimal,
@Value2 decimal,
@value3 decimal,
@sum decimal,
@total decimal
SELECT
@IdI = i.DCLink,
@value1 = i.ufAPCHANGE1AMT,
@Value2 = i.ufAPCHANGE2AMNT,
@value3 =i.ufAPCHANGE3AMNT,
@total = i.ufAPContAmt
FROM
inserted i
BEGIN
IF TRIGGER_NESTLEVEL() > 1
RETURN
IF @value1 <> (select ufAPCHANGE1AMT from Vendor where DCLink = @IdI)
UPDATE Vendor
SET ufAPContAmt = ufAPContAmt + @value1
where DCLink = @IdI
if @Value2 <> (select ufAPCHANGE2AMNT from Vendor where DCLink = @IdI)
UPDATE Vendor
SET ufAPContAmt = ufAPContAmt + @value2
where DCLink = @IdI
if @Value3 <> (select ufAPCHANGE3AMNT from Vendor where DCLink = @IdI)
UPDATE Vendor
SET ufAPContAmt = ufAPContAmt + @value3
where DCLink = @IdI
END
</code></pre>
| <p>I'll suggest to use simple query when possible:</p>
<pre><code>ALTER TRIGGER dbo.trgContractualAmt ON dbo.Vendor
AFTER UPDATE
AS
BEGIN
UPDATE
V
SET
ufAPContAmt += CASE WHEN (V.ufAPCHANGE1AMT <> I.ufAPCHANGE1AMT)
THEN I.ufAPCHANGE1AMT
ELSE 0
END
+ CASE WHEN (V.ufAPCHANGE2AMNT <> I.ufAPCHANGE2AMNT)
THEN I.ufAPCHANGE2AMNT
ELSE 0
END
+ CASE WHEN (V.ufAPCHANGE3AMNT <> I.ufAPCHANGE3AMNT)
THEN I.ufAPCHANGE3AMNT
ELSE 0
END
FROM
Vendor V
INNER JOIN inserted I
ON V.DCLink = I.DCLink;
END;
</code></pre>
|
How to convert nested list to object <p>When I receive JSON data like </p>
<pre><code>[
{
"id":1,
"name":"New Island",
"residents":[
{
"name":"Paul",
"age":"25"
}
]
},
{
"id":2,
"name":"One Nation",
"residents":[
{
"name":"James",
"age":"23"
},
{
"name":"Jessica",
"age":"26"
}
]
}
]
</code></pre>
<p>drf deserializer makes it to list which contain OrderedDict</p>
<p>But I want to make it to list of class object.</p>
<p>Here are my django models</p>
<pre><code>class Country(models.Model):
name = models.CharField(max_length=20)
class Resident(models.Model):
name = models.CharField(max_length=20)
country = models.ForeignKey('Country', related_name='residents')
</code></pre>
| <p>From Python's <a href="https://docs.python.org/3.5/library/json.html" rel="nofollow">JSON library</a></p>
<pre><code>import json
data = '[{"id":1,"name":"New Island","residents":[{"name":"Paul","age":"25"}]},{"id":2,"name":"One Nation","residents":[{"name":"James","age":"23"},{"name":"Jessica","age":"26"}]}]'
x = json.loads(data)
for each_set in x:
for every_person in each_set["residents"]:
print(every_person["name"]) #getting resident's name
print(every_person["age"]) #getting age
print(each_set["name"]) #getting the country name
</code></pre>
<p>From there it's as easy as passing in the proper parameters to classes like</p>
|
Get User in a Doctrine EventListener <p>when I register a new Plasmid Entity, I want give him an automatic name (like: p0001, p0002, p0003), to do this, I need to select in the database the last Plasmid entity for a specific User, get its autoName, and use this previous name to define the new one.</p>
<p>But, when I inject the token_storage in my listener, the token is null... In the controller, I can have the user, it's work.</p>
<p>The service.yml</p>
<pre><code> app.event_listener.plasmid:
class: AppBundle\EventListener\PlasmidListener
arguments: ["@security.token_storage"]
tags:
- { name: doctrine.event_listener, event: prePersist }
</code></pre>
<p>And, the PlasmidListener</p>
<pre><code>class PlasmidListener
{
private $user;
public function __construct(TokenStorage $tokenStorage)
{
$this->user = $tokenStorage->getToken()->getUser();
}
public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
// If the entity is not a Plasmid, return
if (!$entity instanceof Plasmid) {
return;
}
// Else, we have a Plasmid, get the entity manager
$em = $args->getEntityManager();
// Get the last plasmid Name
$lastPlasmid = $em->getRepository('AppBundle:Plasmid')->findLastPlasmid($this->user);
// Do something with the last plasmid in the database
}
}
</code></pre>
<p>If someone know why I can get the actual user in the Doctrine Listener ?</p>
<p>Thanks</p>
| <p>I think that you should store pointer to tokenStorage class in your service instead of user object:</p>
<pre><code>class PlasmidListener
{
private $tokenStorage;
public function __construct(TokenStorage $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
public function prePersist(LifecycleEventArgs $args)
{
$user = $this->tokenStorage->getToken()->getUser();
//...
}
}
</code></pre>
|
Compile and Execute QxORM qxBlog example <p>I'm actually in a project in which I use Qt and I need to use an ORM. I found QxORM. In the process of getting started with this ORM, I need to be able to compile and execute the qxBlog example provided with it. I have thoroughly followed </p>
<ul>
<li>the QxORM installation tutorial : <a href="http://www.qxorm.com/qxorm_en/tutorial_3.html" rel="nofollow">http://www.qxorm.com/qxorm_en/tutorial_3.html</a></li>
<li>the qxBlog example test tutorial <a href="http://www.qxorm.com/qxorm_en/tutorial_1.html" rel="nofollow">http://www.qxorm.com/qxorm_en/tutorial_1.html</a></li>
</ul>
<p>But when I execute the project (qxBlog) with QtCreator, I get this error </p>
<pre><code>C:\Users\HP\dev\libraries\qxorm\QxOrm_1.4.2\test\qxBlog\include\precompiled.h:4: erreur : C1083: Cannot open include file: 'QxOrm.h': No such file or directory
</code></pre>
<p>Following this error, I compiled the QxORM library with all its dependencies to get the <strong>qxormd.dll</strong> and put either in bin or lib folder (that I created) but it didn't work.</p>
<p>Can anyone help me with this issue? </p>
<p>Thanks in advance!</p>
<p>I have changed the <strong>"#include "</strong> line in <strong>precompiled.h</strong> to <strong>"#include <../../include/QxOrm.h>"</strong> (relative path to QxOrm.h file) but I still get a similar error because of the includes in that file (QxOrm.h). </p>
<pre><code>C:\Users\HP\dev\libraries\qxorm\QxOrm_1.4.2\include\QxOrm.h:58: erreur : C1083: Cannot open include file: 'QxPrecompiled.h': No such file or directory
</code></pre>
<p>I don't want to put the QxORM library in the same folder as the project. How can I successfully include <strong>Qxorm.h</strong> with all its dependencies without putting the entire library in the same folder as my project ? </p>
<p>Thanks in advance !</p>
<p>Thanks for you answer. I have added an include path in my .pro file. I get no such previous errors. Nevertheless, I get this error </p>
<pre><code>"LNK1104: cannot open file 'QxOrmd.lib'"
</code></pre>
<p>Can anyone help me with this?</p>
<p>Thanks in advance.</p>
| <p>I found an answer to my question with @drescherjm help.</p>
<p>All I had to do was to add an include path to my .pro file. I did it by adding the following line :</p>
<pre><code>INCLUDEPATH += ../../../QxOrm/include/
</code></pre>
|
Docker container and virtual python environment <p>I'm getting started working with Docker. I installed Docker Toolbox on Windows 10 and downloaded the desired container. I need full access to containerâs filesystem with the ability to add and edit files. Can I transfer the contents of the container into a Virtual Python Environment in Windows filesystem? How to do it?</p>
| <p>Transferring files between Windows and Linux might be a little annoying because of <a href="https://blog.codinghorror.com/the-great-newline-schism/" rel="nofollow">different line endings</a>.</p>
<p>Putting that aside, sounds like you are looking to create a Docker based development environment. There are good tutorials online that walk you through setting one up, I would start with one of these</p>
<ol>
<li><a href="https://blog.codeship.com/running-rails-development-environment-docker/" rel="nofollow">Running a Rails Development Environment in Docker</a>. This one is about Rails, but the principles will be the same. Section 3 specifically talks about about sharing code between your host machine and the Docker container.</li>
<li><a href="https://www.digitalocean.com/community/tutorials/how-to-work-with-docker-data-volumes-on-ubuntu-14-04" rel="nofollow">How To Work with Docker Data Volumes on Ubuntu 14.04</a> includes an brief introduction to Docker containers, different use cases for <a href="https://docs.docker.com/engine/tutorials/dockervolumes/" rel="nofollow">data volumes</a>, and how to get each one working. <em>Sharing Data Between the Host and the Docker Container</em> section talks about what you are trying to do. This example talks about reading log files created inside the container, but the principle is the same for adding/updating files in the container.</li>
</ol>
|
Outlook deforms my mail <p>I'm doing a newsletter with mailchimp.
But when I send a test mail to myself, Outlook deforms it, is it normal?</p>
<p>I tried to change it to HTML but it doesn't worked.</p>
| <p>Yes it is normal, doing e-mails is tricky.</p>
<p>Please share with use the markup.</p>
<p>Build e-mails have a lot of tweaks and tricks. You might have some compatibility issue on your code.</p>
|
Disadvantages of using vanilla code for a Single Page Application <p>I am building a SPA that basically incorporates multiple video streams (using WebRTC) and various other components such as a text 'chat' feature.</p>
<p>I have spent a couple of weeks building a proof of concept prototype using vanilla javascript, jQuery, HTML 5 and Node.js. I was considering using a framework like Angular, or a library like React for the real product.</p>
<p>However, for the scope of the project and from what I learnt building the prototype, I'm pretty confident I can build this using the tools mentioned above.</p>
<p>I can modularise my code and test it using these tools, and from what I am reading these seem to be the main benefits of using something like Angular.</p>
<p>What I'm worried about is not understanding the disadvantages of taking this vanilla approach. I'm aware this question is leaning towards the 'opinionated' side of things which is why I am asking for specific disadvantages as I'm sure there must be things due to my lack of experience in this area that I am overlooking.</p>
| <p>The only specific disadvantage is it may not conform to standards, making it more difficult for someone to read later. If you're doing the project alone, go for it. If you're doing it for a company, you can still do it but document it very well and make sure all of your code is clean.</p>
|
Python read lines from a file and write from a specific line number to another file <p>I want to read the lines from a file and write from a specific line number to another file. I have this script, which writes all the read lines. I need to skip the first four lines and write the rest to another fils. Any ideas?</p>
<pre><code>for k in range (0,16):
print 'k =',k
from abaqus import session
k=k+1
print k
f1 = open('VY_NM_VR_lin_o1_bonded_results_{k}.txt'.format(k=k))
#with open('VY_{k}'.format(k=k), 'a') as f1:
lines = f1.readlines()
for i, line in enumerate(lines):
#print i
print(repr(line))
#if line.startswith(searchquery):
f2.write(line)
#f2.write('%s'%listc + "\n")
i = i+1
#else :
# i = i+1
#os.close(f1)
f1.close()
f2.close()
</code></pre>
| <p><a href="https://docs.python.org/3/library/itertools.html#itertools.islice" rel="nofollow"><code>itertools.islice</code> is designed for this</a>:</p>
<pre><code>import itertools
with open('VY_NM_VR_lin_o1_bonded_results_{k}.txt'.format(k=k)) as f1:
# islice w/4 & None skips first four lines of f1, then generates the rest,
# and writelines can take that iterator directly to write them all out
f2.writelines(itertools.islice(f1, 4, None))
</code></pre>
<p>If you need to process the lines as you go, then skip <code>writelines</code> and go back to:</p>
<pre><code> for line in itertools.islice(f1, 4, None):
... do stuff with line ...
f2.write(line)
</code></pre>
<p>Either way, you never even see the first four lines (Python is reading them and discarding them for you seamlessly).</p>
|
How to access lib folder modules of ear file from a different deployment on same WildFly server? <p>I have an ear (App.ear) and a war (Web.war) file deployed in the same WildFly. The App.ear contains AppEJB.jar as a module and Util.jar in lib folder of the same. I need the Web.war to be able to see the Util.jar and AppEJB.jar of App.ear. For the modules AppEJB.jar to be seen from Web.war I've put jboss-deployment-structure.xml in the META-INF folder of the Web.war as follows:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.App.ear.AppEJB.jar" />
</dependencies>
</deployment>
</jboss-deployment-structure>
</code></pre>
<p>The question is how do I access the Util.jar from Web.war?</p>
| <p>I believe you need dependency for Util.jar in your Web.war's pom.xml</p>
|
How To Set an local Maven Repository (Spring Cloudataflow Server) -->Pivotal CF DEV <p>Environment </p>
<ul>
<li>Pivotal Cloud Foundry DEV</li>
<li>Spring Cloud Data Flow Server</li>
<li>Spring Cloud Data Flow Shell</li>
</ul>
<p>Maven Specific Environment Variables (Spring Cloud Data Flow Server)</p>
<p>MAVEN_LOCALREPOSITORY =C:/Users/xx/.m2/repository/
MAVEN_REMOTE_REPOSITORIES_REPO1_URL=<a href="http://repo.spring.io/libs-snapshot" rel="nofollow">http://repo.spring.io/libs-snapshot</a></p>
<p>Deploying Streams which contains Apps locating in the Remote Repository works fine! Deploying Streams which contains Apps locating in the Local Repository crashes (org.springframework.cloud.dataflow.rest.client.DataFlowClientException: failed to resolve MavenResource:....).</p>
<p>Why?</p>
| <p>The property for <code>local</code> repository needs to be:
<code>
MAVEN_LOCAL_REPOSITORY =C:/Users/xx/.m2/repository/
</code>
<code>underscore</code> between LOCAL and REPOSITORY.</p>
<p>Did you see <code>MAVEN_LOCALREPOSITORY</code> anywhere in the documentation?</p>
|
Extending Ionic2 and injecting ModalController <p>I am trying to develop a datepicker component that can be used for any project.</p>
<p>I have an NgModule that has components and I inject IonicModule in to it so it can use all the components/directives of ionic2.</p>
<pre><code>@NgModule({
imports: [
CommonModule,
IonicModule.forRoot(DatePickerModule)
],
exports: [DatePickerComponent, DatePickerDirective],
entryComponents: [DatePickerComponent],
declarations: [DatePickerComponent, DatePickerDirective],
providers: [DateService, nls]
})
export class DatePickerModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: DatePickerModule
};
}
};
</code></pre>
<p>One of the components injects ionic modal controller to display a modal.</p>
<pre><code>export class MainDirective{
public static config:any;
constructor(private modalCtrl:ModalController) {
}
openModal() {
this.modalCtrl.create(DatePickerComponent
).present();
}
}
</code></pre>
<p>This NgModule is imported in to another App and from that app I am trying to call openModal.
This is how I import</p>
<pre><code>@NgModule({
imports: [
IonicModule.forRoot(App),
DatePickerModule.forRoot(),
],
})
</code></pre>
<p>What happens is that it throws an error '_getPortal' of undefined from ionic-angular library.
I am guessing that it can't find the app to display to.</p>
<p>I am also guessing that I need to pass to forRoot the ACTUAL APP that will be working but I have no idea how to do this.</p>
<p>What would be the best way to approach this problem?</p>
| <p>You should only call <code>forRoot</code> on the root module. This call sets up a bunch of application providers, which should only be done when bootstrapping Ionic. What you should do instead is just import <code>IonicModule</code> (no forRoot).</p>
<p>As for the <code>ModalController</code>, it's already provided when you import <code>IonicModule.forRoot</code> in the root module, so you don't need to worry about trying to add that. If you wanted to add it, you could, but it is dependent on the Ionic <code>App</code> which is only available when you bootstrap. So really, it's redundant to try to add it.</p>
|
Finding the Datediff between Records in same Table <pre><code>IP QID ScanDate Rank
101.110.32.80 6 2016-09-28 18:33:21.000 3
101.110.32.80 6 2016-08-28 18:33:21.000 2
101.110.32.80 6 2016-05-30 00:30:33.000 1
</code></pre>
<p>I have a Table with certain records, grouped by Ipaddress and QID.. My requirement is to find out which record missed the sequence in the date column or other words the date difference is more than 30 days. In the above table date diff between rank 1 and rank 2 is more than 30 days.So, i should flag the rank 2 record.</p>
| <p>While <a href="https://msdn.microsoft.com/en-us/library/ms189461.aspx" rel="nofollow">Window Functions</a> could be used here, I think a self join might be more straight forward and easier to understand:</p>
<pre><code>SELECT
t1.IP,
t1.QID,
t1.Rank,
t1.ScanDate as endScanDate,
t2.ScanDate as beginScanDate,
datediff(day, t2.scandate, t1.scandate) as scanDateDays
FROM
table as t1
INNER JOIN table as t2 ON
t1.ip = t2.ip
t1.rank - 1 = t2.rank --get the record from t2 and is one less in rank
WHERE datediff(day, t2.scandate, t1.scandate) > 30 --only records greater than 30 days
</code></pre>
<p>It's pretty self-explanatory. We are joining the table to itself and joining the ranks together where rank 2 gets joined to rank 1, rank 3 gets joined to rank 2, and so on. Then we just test for records that are greater than 30 days using the datediff function.</p>
|
Find n-cliques in igraph <p>I would like to know if I can find so-called n-cliques in an igraph object. Those are defined as "a maximal subgraph in which the largest geodesic distance between any two nodes is no greater than <em>n</em>" according to Wasserman & Faust. I'm aware that cliques of <em>n=1</em> can be found via <code>cliques()</code> and that the sizes of cliques can be defined beforehand, but is there any way to find cliques of <em>n</em> larger than 1?</p>
| <p>In <strong>theory</strong>, you could try <a href="http://finzi.psych.upenn.edu/R/library/RBGL/html/kCliques.html" rel="nofollow"><code>RBGL::kCliques</code></a>: </p>
<pre><code>library(igraph)
library(RBGL)
set.seed(1)
g <- random.graph.game(100, p.or.m = 300, type = "gnm")
coords <- layout.auto(g)
cl <- kCliques(igraph.to.graphNEL(g))
k <- 2
clSel <- cl[[paste0(k, '-cliques')]][[1]] # select first of all k-cliques (e.g.)
plot(
g,
layout = coords,
vertex.shape = "none",
vertex.label.color = ifelse(V(g) %in% clSel, "red", "darkgrey"),
edge.color = ifelse(tail_of(g, E(g)) %in% clSel & head_of(g, E(g)) %in% clSel, "orange", "#F0F0F099"),
vertex.size = .5,
edge.curved = 1
)
</code></pre>
<p>However, in <strong>practice</strong>...</p>
<pre><code>all(print(distances(induced_subgraph(g, clSel))) <=k ) # should be TRUE
# [1] FALSE
</code></pre>
<p>there seems to be something <strong>wrong</strong> if we use the definition: </p>
<blockquote>
<p>In Social Network Analysis, a k-clique in a graph is a subgraph where
the distance between any two nodes is no greater than k.</p>
</blockquote>
<p>Or maybe I misunderstood something... </p>
|
Espresso test: How to open my application back after opening the recent apps? <p>I want to open my application back while writing an Espresso test case after opening recent apps by calling <code>pressRecentApps()</code> method.
Is there a way to do this except of simulating a click by coordinates?</p>
| <p>I'd say that you can't. The moment your app looses focus, you are out of luck.</p>
<p>You probably need to use <a href="https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html" rel="nofollow">UI Automator</a> for that</p>
|
Unknown command 'import-graphml', when trying to import into Neo4j database <p>It has been asked before, but in that case the problem was miraculously solved (<a href="https://github.com/jexp/neo4j-shell-tools/issues/25" rel="nofollow">https://github.com/jexp/neo4j-shell-tools/issues/25</a>). I, sadly, am not so lucky.</p>
<p><strong>Problem</strong>: neo4j-shell does not recognize the import-graphml command.</p>
<pre><code>neo4j-sh (?)$ help import-graphml
No manual entry for 'import-graphml'
neo4j-sh (?)$ import-graphml -i /data/maorg.neo4j.shell.ShellException: Unknown command 'import-graphml'
</code></pre>
<p><strong>Question</strong>: any suggestions on how to solve this, what have I missed?</p>
<p>Thanks in advance!</p>
| <p>My mistake, I assumed these tools were part of the neo4j-shell. However they require there own installation <a href="https://github.com/jexp/neo4j-shell-tools" rel="nofollow">https://github.com/jexp/neo4j-shell-tools</a></p>
|
Create Application with Authenticates against O365 Azure AD with OpenIdConnect <p>I've got an application I'm creating for use with Office 365 accounts (Will be multi-tenant). I'm looking to use OpenID Connect for authentication. I do not need regular Microsoft accounts working.</p>
<p>I've tried creating an application at:
<a href="https://portal.azure.com" rel="nofollow">https://portal.azure.com</a> -> Azure Active Directory -> App Registrations</p>
<p>As well as:
<a href="https://manage.windowsazure.com" rel="nofollow">https://manage.windowsazure.com</a> -> Active Directory -> Applications</p>
<p>These did not appear to work for OpenId Connect.</p>
<p>Creating an app at:
<a href="https://apps.dev.microsoft.com" rel="nofollow">https://apps.dev.microsoft.com</a></p>
<p>Did work for OpenId Connect.</p>
<p>Can someone please help advise:</p>
<ol>
<li>What's the difference between these different URL's?</li>
<li>Is it possible to get OpenID Connect running from an app registered on one of the Azure sites so that all my Azure stuff is centralized?</li>
</ol>
| <p>At the moment, there are two different OpenID Connect endpoints you need to choose from. If you don't require Microsoft accounts, I recommend you register an app at portal.azure.com, and use the <code>https://login.microsoftonline.com/common/oauth2/authorize</code> endpoint for performing OIDC. There is good protocol documentation and code samples available at aka.ms/aaddev</p>
|
WPF text box border changes color upon mouse entry <p>For some reason my text box border is changing color to an offputting blue whenever the mouse hovers over the text box. here is my xaml: </p>
<pre><code> <TextBox
BorderThickness="1"
BorderBrush="Black"
x:Name="textBox"
custom:ScrollToEndBehavior.OnTextChanged="True"
VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center"
Height="154"
Margin="32,220,36,5"
TextWrapping="Wrap"
Text="{Binding LogText, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Width="449"
Background="WhiteSmoke"
Visibility="{Binding Path=IsLogVisible, Converter={StaticResource BoolToVis}}"
IsReadOnly="True"/>
</code></pre>
| <p>Change the default style to black with a IsMouseOver trigger:</p>
<pre><code><Style TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="border"
SnapsToDevicePixels="True">
<ScrollViewer HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
Name="PART_ContentHost"
Focusable="False" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Border.BorderBrush" TargetName="border"
Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</code></pre>
|
Magento2 Custom content div <p>I'm trying to add a banner to all my pages.</p>
<p>So i created this:</p>
<pre><code><block class="Magento\Framework\View\Element\Template" name="banner" template="banner.phtml"/>
</code></pre>
<p>inside </p>
<blockquote>
<p>default.xml</p>
</blockquote>
<p>Which contains:</p>
<pre><code><?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header.panel">
<block class="Magento\Framework\View\Element\Html\Links" name="header.links">
<arguments>
<argument name="css_class" xsi:type="string">header links</argument>
</arguments>
</block>
<!-- the banner --> <block class="Magento\Framework\View\Element\Template" name="banner" template="banner.phtml"/>
</referenceContainer>
<referenceBlock name="logo">
<arguments>
<argument name="logo_img_width" xsi:type="number">250</argument>
<argument name="logo_img_height" xsi:type="number">100</argument>
</arguments>
</referenceBlock>
<referenceContainer name="footer">
<block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/>
</referenceContainer>
<referenceBlock name="report.bugs" remove="true"/>
<move element="copyright" destination="before.body.end"/>
</body>
</page>
</code></pre>
<p>So my question is, where do i make the actual banner. Where do i add my custom html, like i cannot find where its located at all do i have to create this? </p>
| <p>Hey I think I helped you out on this one already, but here you go. </p>
<p>follow this folders paths:</p>
<pre><code>app/code/YouTheme/Banners/view/frontend/templates/banner.phtml
</code></pre>
<p><code>YouTheme/Banners</code> are folders from your custom module... Let say Kevin/Banners or whatever you'd like to use.
banner.phtml is where your custom html code goes. </p>
<p>Remember to clean cache and sometimes run using shell</p>
<pre><code>php bin/magento setup:static-content:deploy
</code></pre>
|
I have this python function for DFS, why is it throwing error? <pre><code>##This function will return the edges for an undirected graph####
###Example: when edges = [[1,2],[3,2]]
### this will return
{
1: {'nbr': [2], 'id': 1, 'visited': False},
2: {'nbr': [1, 3], 'id': 2, 'visited': False},
3: {'nbr': [2], 'id': 3, 'visited': False}
}
def createEdges(edges):
E = {}
for y in edges:
for x in edges:
if x[0] not in E:
E[x[0]] = {"id": x[0], "nbr": [x[1]], "visited": False}
elif x[1] not in E:
E[x[1]] = {"id": x[1], "nbr": [x[0]], "visited": False}
elif x[0] in E and x[1] not in E[x[0]]['nbr']:
E[x[0]]['nbr'].append(x[1])
elif x[1] in E and x[0] not in E[x[1]]['nbr']:
E[x[1]]['nbr'].append(x[0])
return E
####A function to explore the a vertex of the graph with edges E
def explore(vertex, E):
if vertex not in E:
return
E[vertex]['ccNum'] = cc
E[vertex]['visited'] = True
for x in E[vertex]['nbr']:
if E[x]['visited'] == False:
explore(x, E)
### this function will set the visited index to true for
### all the connecting points of the vertex
### A function for DFS
def DFS(E):
cc = 1
for x in E:
if E[x]['visited'] == False:
explore(x, E)
cc += 1
</code></pre>
<p>Everything was running well before the introduction of "cc" which keep tracks
of total connecting sub graphs</p>
Its now throwing error that:
<h3>Global name cc is not defined</h3>
<p>although cc is defined expose is being called under DFS, which has cc defined in its scope</p>
| <p>Yes, <code>cc</code> is defined in scope of <code>DFS</code>, that does not make it visible inside <code>explore</code>. You could define it as a parameter to <code>explore</code>;</p>
<pre><code>def explore(vertex, E, cc):
</code></pre>
<p>and pass in the value;</p>
<pre><code>. . .
explore(x, E, cc)
. . .
</code></pre>
|
Connecting to shards separately to read only, speed performance <p>Problem. I need to read documents from Mongodb, 500M documents, it is sharded to 10 shards. </p>
<p>My biggest issue is the speed, right now. </p>
<p>I have connected to each shard separately and read each one as separate task, assuming my speed will increase 10x. </p>
<p>It is somewhat faster, but still not fast enough.</p>
<p>Any suggestions to increase the speed? </p>
<p>Note: I am reading document by document from the cursor.
Trying not have lower memory footprint.
Right now, it takes </p>
<p>26 sec to go over 100K documents, on 1 shard
4.5 min to go over 1M documents, on 10 shards</p>
<p>So from here, it looks like it will take 37.5 hrs to go over 500M.</p>
<p>Anyone have dealt with speed optimization issue? </p>
| <p>Here are some tips to improve the speed with some assumptions</p>
<ol>
<li><p>MongoDB is a nosql database which uses quorum for consistency and reliability. In your case though you are reading from shards separately but MongoDB uses quorum of 3 by default. (it means reads will be happen from 3 replicas and then most newest/consistent results are served). Here I am assuming your environment is replicated with a factor of 3
Making quorum value 1 will provide results faster but might be inconsistent/old.</p></li>
<li><p>Indexing is commonly used option in all databases to read records (and only required fields) much faster than normal reads.</p></li>
<li><p>Use of SSDs instead of rotating disks will give you better throughput (Though might not be applicable in current case but should be helpful in future)</p></li>
<li><p>MongoDB 3.0 version uses WiredTiger Engine which claimed to be much faster (5x-7x) than older version.</p></li>
</ol>
<p>Another option you can consider if you have more money, is adding more shards in the system and scale it horizontally</p>
<p>Before jumping to optimize read latency, Why do you need to read all 500M records in the DB?
Reading all records from database makes no sense in normal real life oltp transactions.</p>
|
HttpLoggingInterceptor (OkHttp3) logging a lot of times for each request <p>I'm trying to do some requests using Retrofit2 and OkHttp3, and intercepting them using HttpLoggingInterceptor. I am injecting the OkHttp client using Dagger.. and it's all ok but when I just make a request to my server I can see the request and response logged in Logcat three or more times when it should be just one time.. </p>
<p>The part of the code where I am setting the interceptor is like:</p>
<pre><code>HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(logging);
</code></pre>
<p>Example Logcat result, for just ONE request called:</p>
<pre><code>D/OkHttp: --> GET http://date.jsontest.com/ http/1.1
D/OkHttp: Accept: application/json
D/OkHttp: --> END GET
D/OkHttp: --> GET http://date.jsontest.com/ http/1.1
D/OkHttp: Accept: application/json
D/OkHttp: --> END GET
D/OkHttp: --> GET http://date.jsontest.com/ http/1.1
</code></pre>
<p>Which can be the problem? Any help?
Thanks</p>
| <p>try adding @Singleton annotation to Dagger. Maybe, you add several loggers instead of one</p>
|
Rails - How to avoid repeating same i18n attributes translations <p>I am building a Rails application using I18n translations.</p>
<p>I have two models (Blog and Event), sharing same attributes (title, content).<br>
In my I18n yml files, how can I avoid repeating same keys for each attributes models and share them ?</p>
<p>Extract of my actual code:</p>
<pre><code>fr:
activerecord:
attributes:
blog:
title: Titre
content: Contenu
event:
title: Titre
content: Contenu
</code></pre>
<p>I also tried to set attributes as default, removing wrapped model key without any luck.</p>
<pre><code>fr:
activerecord:
attributes:
title: Titre
content: Contenu
</code></pre>
<p>Thanks for your help !</p>
<p><strong>My project</strong>:</p>
<ul>
<li>Rails 4.2.7.1</li>
<li>Ruby 2.3.0</li>
</ul>
| <p>Similar kind of question is answered <a href="http://stackoverflow.com/a/4910818/4758119">here</a></p>
<p>You can achieve it using yaml aliases</p>
<pre><code>fr:
activerecord:
attributes:
blog: &title_content
title: Titre
content: Contenu
event: *title_content
</code></pre>
<p>Refer <a href="https://github.com/cyklo/Bukkit-OtherBlocks/wiki/Aliases-(advanced-YAML-usage)" rel="nofollow">yaml aliases</a> for more info.</p>
|
Execute/Reject function based on customs attribute value in dotnet core C# <p>I'm trying to learn the attributes in C# dotnet core, so I wrote the 2 below classes.</p>
<ol>
<li><p><code>Attribute class</code>:</p>
<pre><code>using System;
namespace attribute
{
// [AttributeUsage(AttributeTargets.Class)]
[AttributeUsage(AttributeTargets.All)]
public class MyCustomAttribute : Attribute
{
public string SomeProperty { get; set; }
}
//[MyCustom(SomeProperty = "foo bar")]
public class Foo
{
[MyCustom(SomeProperty = "user")]
internal static void fn()
{
Console.WriteLine("hi");
}
}
}
</code></pre></li>
<li><p><code>Main class</code>:</p>
<pre><code>using System;
using System.Reflection;
namespace attribute
{
public class Program
{
public static int Main(string[] args)
{
var customAttributes = (MyCustomAttribute[])typeof(Foo).GetTypeInfo().GetCustomAttributes(typeof(MyCustomAttribute), true);
if (customAttributes.Length > 0)
{
var myAttribute = customAttributes[0];
string value = myAttribute.SomeProperty;
// TODO: Do something with the value
Console.WriteLine(value);
if (value == "bar")
Foo.fn();
else
Console.WriteLine("Unauthorized");
}
return 0;
}
}
}
</code></pre></li>
</ol>
<p>I need the function <code>Foo.fn()</code> to be executed if the <code>SomeProperty</code> element in the <code>MyCustomAttribute</code> is equal to <code>bar</code>.
My code work fine if I applied it into the <code>class level</code>, but not working on the <code>function level</code></p>
<p><strong>IMPORTANT NOTE</strong>
I'm very new to this, so any advice or feedback to improve my code, is welcomed. thanks</p>
| <p>your solution is to find the declared method & in that method find the attribute.</p>
<pre><code>var customAttributes = (MyCustomAttribute[])((typeof(Foo).GetTypeInfo())
.DeclaredMethods.Where(x => x.Name == "fn")
.FirstOrDefault())
.GetCustomAttributes(typeof(MyCustomAttribute), true);
</code></pre>
|
Semantic HTML for a business card <p>I am trying to write semantic HTML for a business card.
I want to show the name, title, email and phone number on the markup.</p>
<pre class="lang-html prettyprint-override"><code><div id="bussinesscardcontainer">
<section class="Details">
<span> Name :ABC</span>
<span> Title:XYZ </span>
</section>
<footer class="contact">
<span class="email"> Email:abc@abc.com</span>
<span class="phonenumber">Mobile:123-123-123</span>
</footer>
</div>
</code></pre>
<p>I just want to understand is my markup sematically right or not.</p>
<p>This markup would end up looking as
<a href="http://stackoverflow.com/questions/40050363/difficulty-in-designing-business-card-using-css">Difficulty in Designing Business card using CSS</a></p>
| <p>Your markup is technically correct but could subjectively be improved. </p>
<p>The HTML5 spec added many, more descriptive HTML properties like <code><footer></code> that you are using but left implementation up to web developers. This has resulted in less than optimal usage of HTML properties in my experience.</p>
<p>For structural components of a document, the best guide I've found is produced by <a href="http://html5doctor.com/downloads/h5d-sectioning-flowchart.pdf" rel="nofollow">HTML5Doctor</a>, which gives you a flow chart of usage guidelines for these properties.</p>
<p>In your specific case, I'd probably omit the use of <code><footer></code> and switch how you are using <code><section></code> and <code><div></code> like this:</p>
<pre><code><section class="businesscard-container">
<div class="businesscard-details">
<span> Name :ABC</span>
<span> Title:XYZ </span>
</div>
<div class="businesscard-contact">
<span class="email"> Email:abc@abc.com</span>
<span class="phonenumber">Mobile:123-123-123</span>
</div>
</section>
</code></pre>
|
Leaving case statement in one line using beautify plugin in VS Code <p>After installing beautify plugin in VS Code pressing <kbd>Shift</kbd> + <kbd>Alt</kbd> + <kbd>F</kbd> results in reformatting a switch case form</p>
<pre><code>switch (cmd)
{
case glob.CmdsClient.GET_CHANGED_ITEMS: cmds.getChangedItems(data, socket); break;
case glob.CmdsClient.UPDATE_ITEM: cmds.updateItem(data); break;
default: console.log("Unkonwn CMD #", cmd);
}
</code></pre>
<p>to</p>
<pre><code>switch(cmd) {
case glob.CmdsClient.GET_CHANGED_ITEMS:
cmds.getChangedItems(data, socket);
break;
case glob.CmdsClient.UPDATE_ITEM:
cmds.updateItem(data);
break;
default:
console.log("Unkonwn CMD #", cmd);
}
</code></pre>
<p>How can I prevent VS Code to do that?</p>
| <p>You can configure all keyboard shortcuts from the visual studio options menu. Please check the following links for reference.
<a href="https://msdn.microsoft.com/en-us/library/5zwses53.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/5zwses53.aspx</a></p>
|
Javascript not working for unknown reason after making some little tiny change to it somewhere <p>Sorry for bothering everyone, I was just executing it in the wrong browser.</p>
| <p>just remove this line:</p>
<pre><code>document.getElementById("update").addEventListener("click", update);
</code></pre>
<p>Or create the update element</p>
|
Python Pandas - filtering df by the number of unique values within a group <p>Here is an example of data I'm working on. (as a pandas df)</p>
<pre><code> index inv Rev_stream Bill_type Net_rev
1 1 A Original -24.77
2 1 B Original -24.77
3 2 A Original -409.33
4 2 B Original -409.33
5 2 C Original -409.33
6 2 D Original -409.33
7 3 A Original -843.11
8 3 A Rebill 279.5
9 3 B Original -843.11
10 4 A Rebill 279.5
11 4 B Original -843.11
12 5 B Rebill 279.5
</code></pre>
<p>How could I filter this df, in a way to only get the lines where invoice/Rev_stream combo has both original and rebill kind of Net_rev. In the example above it would be only lines with index 7 and 8. </p>
<p>Is there an easy way to do it, without iterating over the whole dataframe and building dictionaries of invoice+RevStream : Bill_type?</p>
<p>What I'm looking for is some kind of</p>
<pre><code>df = df[df[['inv','Rev_stream']]['Bill_type'].unique().len() == 2]
</code></pre>
<p>Unfortunately the code above doesn't work.</p>
<p>Thanks in advance.</p>
| <p>You can group your data by <code>inv</code> and <code>Rev_stream</code> columns and then check for each group if both <code>Original</code> and <code>Rebill</code> are in the <code>Bill_type</code> values and filter based on the condition:</p>
<pre><code>(df.groupby(['inv', 'Rev_stream'])
.filter(lambda g: 'Original' in g.Bill_type.values and 'Rebill' in g.Bill_type.values))
</code></pre>
<p><a href="https://i.stack.imgur.com/P9a9T.png" rel="nofollow"><img src="https://i.stack.imgur.com/P9a9T.png" alt="enter image description here"></a></p>
|
how to Import com.android.internal.telephony <p>How do I Import the following? I have tried them this way but nothing is happening . Please help?</p>
<pre><code>import com.android.internal.telephony.cat.AppInterface;
import com.android.internal.telephony.cat.LaunchBrowserMode;
import com.android.internal.telephony.cat.Menu;
import com.android.internal.telephony.cat.Item;
import com.android.internal.telephony.cat.Input;
import com.android.internal.telephony.cat.ResultCode;
import com.android.internal.telephony.cat.CatCmdMessage;
import com.android.internal.telephony.cat.CatCmdMessage.BrowserSettings;
import com.android.internal.telephony.cat.CatCmdMessage.SetupEventListSettings;
import com.android.internal.telephony.cat.Log;
import com.android.internal.telephony.cat.CatResponseMessage;
import com.android.internal.telephony.cat.TextMessage;
import com.android.internal.telephony.uicc.IccRefreshResponse;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.IccCardConstantsa;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.cat.CatService;
</code></pre>
| <p>These classes are hidden. You can not use directly. I guess <strong>reflection</strong> is the one solution.</p>
|
Not receiving push form Urban Airship on iOS <p>I'm trying to get my iOS devices to receive push notifications again, but it's not really working out.</p>
<hr>
<p>The context in which I'm working:</p>
<h3>My project setup</h3>
<ul>
<li>Platforms I need to support: iOS8+ </li>
<li>UA version I'm using: 8.0.1 (installed using Cocoapods) </li>
<li>Background modes (Remote notifications) and Push Notifications are ON </li>
</ul>
<h3>My code</h3>
<ul>
<li>Added <code>didReceiveRemoteNotification:</code> to the Application delegate: â </li>
<li><p>Added <code>UNUserNotificationCenter</code> support (and implemented the delegate methods) for iOS10: â</p></li>
<li><p>Configured an <code>UAConfig</code>: â </p></li>
<li>UA takes off: â </li>
<li>UAPush has all the <code>notificationOptions</code> and has <code>userPushNotificationsEnabled</code> set to <code>YES</code>: â</li>
</ul>
<hr>
<p>Here are a few snippets of my code:</p>
<p>(in <code>applicationDidFinishLaunching:</code>)</p>
<pre><code>if (UNUserNotificationCenter.class) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!error) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
DLog(@"There was an error trying to request authorization for push: %@", error);
}
}];
} else {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:(UIUserNotificationTypeAlert
| UIUserNotificationTypeSound
| UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
UAConfig *config = [UAConfig config];
config.inProduction = self.urbanAirshipInProduction;
if(self.urbanAirshipInProduction) {
config.productionAppKey = self.urbanAirshipKey;
config.productionAppSecret = self.urbanAirshipSecret;
} else {
config.developmentAppKey = self.urbanAirshipKey;
config.developmentAppSecret = self.urbanAirshipSecret;
}
[UAirship takeOff:config];
UAPush *pusher = [UAirship push];
pusher.notificationOptions = (UANotificationOptionAlert |
UANotificationOptionBadge |
UANotificationOptionSound);
pusher.pushNotificationDelegate = self;
pusher.userPushNotificationsEnabled = YES;
</code></pre>
<p>With the above code I was expecting to receive calls to <code>applicationDidReceiveRemoteNotification:fetchCompletionHandler:</code> and <code>UNUserNotificationCenterDelegate</code> methods for iOS10. </p>
<p>But alas, none of them methods even dared to get called.</p>
<hr>
<p>I have no clue as to why push won't get pushed to my devices. I checked the App in UA and <strong>Installed</strong>, <strong>Opted in</strong> and <strong>Background</strong> are all green when I search for my device token.</p>
<p>The problem arises with both iOS 8,9 and iOS10. But I'm not sure if this is really an OS thing. </p>
<p>Why? </p>
<p>Because I found a support ticket <a href="https://support.urbanairship.com/hc/en-us/community/posts/208269743-Unable-to-receive-background-push-notifications" rel="nofollow">here</a> and somewhere to the bottom "<em>aboca_ext</em>" (just search the page for his/her username) says:</p>
<blockquote>
<p>Hi guys, I found my problem, I was cleaning up my cache when my application was starting, but after UA initiated sqlite db, and by this I was deleting their db. After I fixed that, everything worked as it should. </p>
</blockquote>
<p>Now that's interesting because my project also uses <code>SQLCipher</code>, I'm wondering if that produces some kind of conflict (even though I'm not clearing <em>any</em> cache or whatsoever), but I'm not seeing any errors produced by either SQLCipher or UA.<br>
Another funny (actually not so funny) note is that I think UA actually started failing after installing it using Cocoapods, but again--I'm not really sure if that's the problem.</p>
| <p>The Urban Airship SDK takes care of registering with UNUserNotificationCenter for you. You should be able to remove registration calls. I don't think it should be causing problems for you, but it could prevent some features such as OOTB categories from working.</p>
<p>As for push notification events, I would recommend listening using the push delegate on the UAPush instance instead of the factory methods or the UNUserNotificationCenter. The UA delegate methods are called across all OS versions. Hopefully it will help simplify your event handling code.</p>
<p>Deleting the sql lite database could cause some issues with reporting, but I would expect push to continue to work. Could you turn on verbose logging and the channel registration payload to see if opt_in is set to true? You can enable verbose logging on the UAConfig object.</p>
|
Angular 2 Webpack and editing files <p>This might be a completely stupid question, but I'm a newbie and totally new to webpack :)</p>
<p>So I started a project using this: <a href="https://github.com/preboot/angular2-webpack" rel="nofollow">webpack</a>
I got it up and running fine, with <code>npm install</code>, <code>npm start</code> and <code>npm run build</code>, just like adviced. Then I transfered the files in the <code>dist</code> folder to my server and it works like a charm. My problem is when I want to actually edit my code in the editor, do I then really have to rebuild and transfer the content from the <code>dist</code> folder to the server every time? Otherwise it wouldn't be a problem, but since I have php files on the server, and I can't access the server from localhost. So I can't test the app from my editor and localhost. </p>
<p>Sorry again if this is a stupid question! Better ask than be sorry ;)</p>
<p>EDIT: It does update to localhost the changes I do, I have also tried to use <code>npm run start:hmr</code> like it suggests in the readme file of the webpack. Won't work.</p>
| <p>According to docs :
<a href="https://github.com/preboot/angular2-webpack#developing" rel="nofollow">https://github.com/preboot/angular2-webpack#developing</a></p>
<blockquote>
<p>Developing</p>
<p>After you have installed all dependencies you can now start developing
with:</p>
<ul>
<li>npm start</li>
</ul>
<p>It will start a local server using webpack-dev-server which will
<strong>watch, build (in-memory), and reload for you</strong>. The application can be
checked at <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a>.</p>
</blockquote>
<p>So Webpack should watch the project files for you and rebuild app</p>
|
Profile time taken by Delayed Job <p>I have a huge number of jobs in multiple queues, and I'm wondering if it would be possible to profile the time taken by each job?</p>
| <p>You can use <a href="https://github.com/ice799/memprof" rel="nofollow">https://github.com/ice799/memprof</a>.</p>
<p>Also to record different events of job you can use hooks<a href="https://github.com/collectiveidea/delayed_job/blob/master/README.md#hooks" rel="nofollow">https://github.com/collectiveidea/delayed_job/blob/master/README.md#hooks</a></p>
|
Symfony using ParamConverter with POST action <p>I'm building <code>rest API</code>, and have method to save posts.</p>
<pre><code>postPostAction(Request $request)
{
}
</code></pre>
<p>my <code>POST</code> request contains all <code>Entity/Post</code> properties</p>
<p>How to use <code>ParamConverter</code> to have <code>Entity/Post</code> in this method parameters like:</p>
<pre><code>postPostAction(Post $post)
{
}
</code></pre>
<p>Do I need create custom <code>ParamConverter</code>, or it make sense using ParamConverter only with <code>PUT</code> and <code>GET</code> ?</p>
| <p>You can use default paramConverter like this</p>
<pre><code>use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/**
* @ParamConverter("thePost", class = "AppBundle:Post")
*/
public function postPostAction(Post $thePost)
{
// ...
}
</code></pre>
<p>The annotation takes several parameters, there the name of the variable to convert and the class to convert to.</p>
<p>You could even omit the annotation and write</p>
<pre><code>public function postPostAction(Post $thePost)
{
// ...
}
</code></pre>
<p>this would automatically convert your variable to an entity.</p>
<p>You can find more informations in the <a href="http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html" rel="nofollow">documentation</a>.</p>
|
Code that makes cyclic reference for x spaces in list <p>I have a tasko to make a program in which i get m, n and k. I should create a list a with <code>n*m</code> element.
List <code>b</code> is supposed to have <code>n*m</code> element. It is created from list a with cyclic shift k to the right for m elements of lists.
I know it is poorly explained. Example is:</p>
<pre><code>n=3
m=4
A=1 2 3 4 5 6 7 8 9 10 11 12
k=1
B=4 1 2 3 8 5 6 7 12 9 10 11
</code></pre>
<p>What i have at the moment is:</p>
<pre><code>from random import randint
n = int(input())
m=int(input())
A = []
B=[0]
B=B*n*m
for i in range(n*m):
A = A + [randint(1, 30)]
print('\nLista A:\n')
for i in range(n*m):
print(A[i], end = ' ')
print()
k=int(input())
for i in range(-1, m*n, m):
B[m-1-i]=A[i]
print(B[m-1-i])
print('\nLista B:\n')
for i in range(n*m):
print(B[i], end = ' ')
</code></pre>
<p>Thanks</p>
| <p>Try this... </p>
<pre><code># Start with an empty list
B = []
# Take A in chunks of m
for i in range( int(len(A)/m) ):
# Take an m-sized chunk of A
chunk = A[m*i:m*(i+1)]
# Shift it to the right by k (python style!)
shift = chunk[-k:] + chunk[:-k]
# Add it to B
B += shift
print (B)
</code></pre>
|
Git submodule with same name in different branches <p>I was wondering whether it is possible to have a git submodule pointing to two different repositories <em>using the same directory name</em>, depending on the branch currently checked out.</p>
<pre><code>overall-repo (Branch A)
\subproject at domainA
overall-repo (Branch B)
\subproject at domainB
</code></pre>
<p>If I try this using the regular <code>git submodule add</code> command, git wants me to specify a different name or force the previous target, although I have the other branch checked out.</p>
| <p>In case someone else stumbles upon this, too: The name does not necessarily reflect the folder in which the submodule exists. </p>
<p>So the command
<code>git submodule add --name subproject-B domainB subproject</code>
creates the submodule with a unique name (<code>subproject-B</code>) but lets it reside in the path specified as last parameter.</p>
<p>Or, speaking in terms of the generated .submodule file:</p>
<pre><code>[submodule "subproject-B"] #new name
path = subproject #but same path
url = domainB
</code></pre>
|
Calling function template of class template in C++ <p>I have intermediate level of knowledge in C++ and I would like to beg your pardon if you find the question is very easy or not of standard to post in this blog. But, somehow I was unable to solve it. :) </p>
<p>Your kind help would be appreciated. Here is my code:
The class template is following in a .hpp file:</p>
<pre><code>template<typename T>
class FastRetinexFilter{
public:
static T* getInstance();
T Adjust(cv::Mat source, cv::Mat &destination, bool adjustBrightness=true, bool adjustColors=true, int n=3, bool filterOnlyIllumination=false, bool guidedFilter=false, double adjustmentExponent=1.0/2.0, int kernelSize=25, int finalFilterSize=5, double upperBound=255.0);
......
......
......
private:
.....
.....
static T *s_instance;
};
</code></pre>
<p>The definition of the functions are following in a .cpp file</p>
<pre><code>#include "FastRetinexFilter.hpp"
using namespace cv;
template <class T> T* FastRetinexFilter<T>::s_instance = 0;
template <class T> T*
FastRetinexFilter<T>:: getInstance() {
if (!s_instance)
s_instance = new FastRetinexFilter();
return s_instance;
}
template <class T> T FastRetinexFilter<T>::Adjust(cv::Mat source, cv::Mat &destination, bool adjustBrightness, bool adjustColors, int n, bool filterOnlyIllumination, bool guidedFilter, double adjustmentExponent, int kernelSize, int finalFilterSize, double upperBound){
if (adjustBrightness==false && adjustColors==false){
source.copyTo(destination);
return;
}
cv::Mat gray;
cvtColor(source, gray, COLOR_BGR2GRAY);
......
......
}
......
......
......
</code></pre>
<p>Now, I would like to call the adjust function from another class, where I have included the header file and the member of FastRetinexFilter class is properly visible there. </p>
<p>I tried to do it in this manner :</p>
<pre><code>FastRetinexFilter::getInstance()->Adjust(colorImgMat, result, brightnessAdjustment, colorCorrection, n, false, gif, a);
</code></pre>
<p>But it is giving me error. It says that </p>
<blockquote>
<p>"FastRetinexFilter" is not a class, namespace, or enumeration</p>
</blockquote>
<p>please suggest how should I can call this function template by using the getInstance() method.</p>
<p>When I don't use the template, the definition is like this. I do like this in other classes, which works fine : </p>
<pre><code>FastRetinexFilter* FastRetinexFilter::instance = 0;
FastRetinexFilter* FastRetinexFilter::getInstance() {
if (!instance)
instance = new FastRetinexFilter();
return instance;
}
In the header file the declaration is like this :
public:
static FastRetinexFilter* getInstance();
......
.....
private:
static FastRetinexFilter* instance;
......
......
</code></pre>
<p>To call some function (e.g. connectedComponentLabeling) from this class, I do :</p>
<pre><code>FastRetinexFilter::getInstance()->connectedComponentLabeling(binImageCopy,numComponent);
</code></pre>
<p>But I don't understand, how to do it in the case of templates.
The function "getInstance()" will return a object pointer of the class FastRetinexFilter.
So according to your answers, I should do like this :</p>
<pre><code>FastRetinexFilter<FastRetinexFilter*>::getInstance()->Adjust(...);
</code></pre>
<p>But this does not work.
What should I try ? Please suggest. I need to use template for other functions in the this class. So, it is necessary to use class template and function template here. </p>
| <p>You forgot the template parameter:</p>
<pre><code>FastRetinexFilter<...>::getInstance()->Adjust(...);
^^^^^
Specify the type
</code></pre>
|
Apache Tomcat failed to start <p>I am using mac 15 inch retina eye display laptop currently running Sierra os . I am facing an issue from past few days apache tomcat does not start in netbeans. it gives an error port 8084 already in use. and when i try to change port to 8080 then it says starting of tomcat failed while 8082 port it says port already in use. Sometimes apache tomcat starts and then again it does the same port in use and unable to start. Please give me some solution to it. </p>
| <p>That means that there is another instance of Tomcat running at the same time. If you are unable to stop already running Tomcat instance from Netbeans you can do it from command line.</p>
<ol>
<li>Find Tomcat process id by executing <code>ps aux | grep tomcat</code>.</li>
<li>Stop Tomcat: <code>kill <pid></code> or if for some reason it does not work to stop <code>kill -9 <pid></code></li>
</ol>
|
Re-evaluate quality gate in Sonarqube without a new analysis <p>Is there any way to tell Sonarqube to check again if a project passes a quality gate without starting a new analysis? </p>
<p>Currently, whenever I change the metrics of a quality gate, I would run a new analysis (obviously with the same result, as there are no code changes) for every project using that gate to get updated information whether it passes with the new requirements.</p>
<p>I hope there is an easier way?</p>
| <p>Quality gate compliance is calculated as part of the analysis. No way around that.</p>
|
$_POST is not working in my script <p>I wanted to create a $_POST function for this URL: /api.php?key=apikey&host=victimip&port=chooseport&time=time&method=udp</p>
<p>It does not work and I don't know what's causing this.</p>
<p>In index.php I will type in the fields so 'victimip' should be changed, 'chooseport', 'time' and 'mehtod'</p>
<p>Here is my Index.php where I type all the in the fields:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>STRESSSS</title>
<style type="text/css">
td {
width: 300px;
}
</style>
</head>
<body>
<form action="action.php" method="post" />
<table>
<tr>
<td>Host</td>
<td><input type="text" name="host"></td>
<tr>
<td>Port</td>
<td><input type="text" name="port"></td>
</tr>
<tr>
<td>Time</td>
<td><input type="text" name="time"></td>
</tr>
<tr>
<td>Method</td>
<td><select name="method"><option value="tcp">tcp</option><option value="udp">udp</option></select></td>
</tr>
<tr>
<td></td>
<td style="text-align:left;"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>And here is action.php</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
// USE $this->input->xss_clean($this->input->post('NAME_OF_FIELD'));
// k lets go
// api.php?key=apikey&host=victimip&port=chooseport&time=time&method=udp
$Host = $_POST["host"];
$Port = $_POST["port"];
$Time = $_POST["time"]; //idk wot this is but make sure it's not 0
$Method = $_POST["method"];
if($Host && $Port && $Time && $Method) {
die("Stressing " . $Host . ":" . $Port . " using the " . $Method . " method for " . $Time . " seconds.");
} else {
// you could redirect them back here if you wanted.
die("Invalid parameters...");
}
?></code></pre>
</div>
</div>
</p>
<p>What's wrong? It feels like something is wrong in actions.php but I'm not sure.</p>
| <p>The url you provided is for GET method </p>
<pre><code> URL: /api.php?key=apikey&host=victimip&port=chooseport&time=time&method=udp
</code></pre>
<p>If you want show these value in your input field you should use </p>
<pre><code> <body>
<form action="action.php" method="post" />
<table>
<tr>
<td>Host</td>
<?php echo '<td><input type="text" name="host" value="'. $_GET['host'] .'"></td>' ;?>
<tr>
<td>Port</td>
<?php echo '<td><input type="text" name="port" value="'. $_GET['port'] .'"></td>' ;?>
</tr>
.......
</code></pre>
<p>and for select </p>
<pre><code> <?php echo '<td><select name="method" value="' . $_GET['method'] .
'"><option value="tcp">tcp</option><option value="udp">udp</option></select></td>' ;?>
</code></pre>
|
Writing to a File in Java using FileWriter <p>I would like to write to a file after a set of characters. For example, if I want to write <code>xyz</code> into a file <code>test.txt</code> which contains string <code>hello world</code>. I want write after the letter <code>w</code>. The output should be <code>hello wxyzorld</code> in the file.</p>
<p>How do it do it? Using a <code>FileWriter</code> and <code>BufferedWriter</code> I can write to a file but not at a certain position. Could you help me if there is anyway I can do it? </p>
| <pre><code>public static void main(String[] args) {
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(new File("/path/to/test.txt")));
String line;
StringBuilder stringBuilder = new StringBuilder();
int offset = 7;
while((line = bufferedReader.readLine()) != null) {
for(int i=0; i<line.length(); i++) {
if(i == offset) {
stringBuilder.append("xyz" + line.charAt(i));
} else if(i == line.length()-1) {
stringBuilder.append(line.charAt(i) +"\n");
} else {
stringBuilder.append(line.charAt(i));
}
}
}
System.out.println(stringBuilder);
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
</code></pre>
<p>Something like this perhaps? You can append the rest of the lines accordingly to your StringBuilder.</p>
|
Limit tablelayout rows, android <p>I was wondering if it's possible to add a limit such as maximum of row/s to the tablelayout? </p>
<p>So I can, let's say, insert or show only last 100 instead of entire view. The data is dynamically populated and inserted.</p>
<p><strong>Solution</strong></p>
<pre><code> int _tableCount = _tableLayout.getChildCount();
if(_tableCount > 100)
{
_tableLayout.removeViewAt(100);
}
</code></pre>
| <p>You can check count of rows by <code>getChildCount()</code> method, and add rows only if count is less than 100.</p>
|
ADALiOS 2.2.5 and 2.2.6 does not work in below iOS 9 <p>In my application I have updated to latest ADALiOS library versions 2.2.6 (tried with 2.2.5 as well) to support for iOS 10 but after updating it stopped working in below iOS 9. If you try to open webview for WAAD login then login screen loads and immediately gets disappear in below iOS 9 and stating with a message <code>"The network connection was lost."</code> Please help me on it. The same is working fine with iOS 9 and iOS 10.</p>
| <p>I just tested it on simulator iOS8.1, but things worked.</p>
<p>Maybe you can try restarting the simulator as suggested by this? (<a href="http://stackoverflow.com/questions/25797339/nsurlconnection-get-request-returns-1005-the-network-connection-was-lost">NSURLConnection GET request returns -1005, "the network connection was lost"</a>)</p>
|
How can I send data between Intel Edison and a mobile device using Ad Hoc or SoftAP? <p>I am working on a project where I need to transfer data between an Intel Edison and a mobile device (hoping for cross platform compatability) without using a router. I have considered Wi-Fi Direct, but this is not available on iOS and only available on a handful of android devices. Furthermore, in the Intel Edison Wi-Fi guide (link below), it tells you how to use ad hoc mode, but only between two Intel Edison devices. I am also not sure whether Android devices can connect to an ad hoc network.
So my question is whether or not using the Intel Edison's SoftAP mode will allow me to transfer data to and from an Intel edison and a mobile device? Or is there a better way to achieve this?</p>
<p>Intel edison wifi guide:
<a href="http://download.intel.com/support/edison/sb/edison_wifi_331438001.pdf" rel="nofollow">http://download.intel.com/support/edison/sb/edison_wifi_331438001.pdf</a> </p>
<p>Thanks in advance! </p>
| <p>If you want to use Wifi, SoftAP seems like to be the best option. But if you need a short range connection, you should consider Bluetooth. Since nowadays there are lots of wifi APs around us, the user might be forced to disconnect from his internet-accessing wifi AP to connect to your data network which might be inconvenient for him/her.</p>
|
PHP List files in same directory <p>I'm trying to list files in a folder. I have done this before, so I am not sure why I am having a problem now.</p>
<p>I have a PDF files I am trying to display to my web page. The directory structure looks like this:</p>
<pre><code>folder1/folder2/displayFiles.php
folder1/folder2/files.pdf
</code></pre>
<p>displayFiles.php is the process file where I am using the code below. </p>
<p>I am trying to display the file called files.pdf onto the page, which is in the same directory as the process file.</p>
<p>Here is my code so far:</p>
<pre><code> <?php
$dir = "folder1/folder2/";
// $dir = "/"; <-- I also tried this
$ffs = scandir($dir);
foreach($ffs as $ff)
{
if($ff != '.' && $ff != '..')
{
$filesize = filesize($dir . '/' . $ff);
echo "<ul><li><a download href='$dir/$ff'>$ff</a></li></ul>";
}
}
?>
</code></pre>
<p>Please help me fix this. I know it's a simple fix. I just cannot find the code to fix it.</p>
<p>Thank you in advance.</p>
| <p>Just use <code>glob</code></p>
<p><a href="http://php.net/manual/de/function.glob.php" rel="nofollow">http://php.net/manual/de/function.glob.php</a></p>
<pre><code>$pdfs = glob("*.pdf"); // if needed loop through your directorys and glob files
print_r($pdfs);
</code></pre>
<p>Just an example. You should be able to use it with some edits.</p>
|
Getting multimple results from Ajax post <p>Maybe this is a duplicate but I can not understand why mo code does not work. I am trying to get multiple results via Ajax/php.</p>
<p>This is from my php file:</p>
<pre><code>$result11 = 'test1'
$result22 = 'test2';
echo json_encode(array("data1" => $result11, "data2" => $result22));
</code></pre>
<p>Ajax call:</p>
<pre><code>$(document.body).on('submit','#sendmessage',function() {
$.ajax({
type: "POST",
url: "/send.php",
data: {par:par,kid:kid,ha:ha,sform:sform,editors:editors},
cache: false,
dataType:'json',
success: function(datax) {
alert(datax.data1);
}
});
return false;
});
</code></pre>
<p><strong>Problem:</strong></p>
<p>When I submit a form, the page refreshes instead of sending ajax request.</p>
<p>At the same time this works but I can't get multiple results from Php file:</p>
<pre><code>$(document.body).on('submit','#sendmessagex',function() {
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "/send.php",
data:str,
success: function(data) {
alert(data);
}
});
return false;
});
</code></pre>
| <p>Add a preventDefault() call to your script</p>
<pre><code>$(document.body).on('submit','#sendmessagex',function(event) {
//----------------------------------------------------^^^^^
event.preventDefault();
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "/send.php",
data:str,
success: function(data) {
alert(data);
}
});
return false;
});
</code></pre>
|
Access variables in other file in node.js <p>I want to define a variable in one file called vars.js. then I want to access those variable from another file called mybot.js. this is what I ahve in each file:</p>
<p>vars.js:
<code>var token = 'abcfgk6'</code></p>
<p>mybot.js:</p>
<pre><code>var request = require(./vars.js);
...
bot.login(token);
</code></pre>
| <p>You have to export the variable in <code>vars.js</code></p>
<pre><code>var token = 'abcfgk6'
exports.token = token;
</code></pre>
<p>And then access via:</p>
<pre><code>var request = require(./vars.js);
...
bot.login(request.token);
</code></pre>
<p>Hope it helps!</p>
|
Should I close the groovy Sql in Grails service <p>I'm using groovy Sql in a Grails project. </p>
<pre><code>class MyService{
def sessionFactory
def method(){
def sql = new Sql(sessionFactory.currentSession.connection())
def query =...
sql.rows(query,...)
sql.close()
}
}
</code></pre>
<p>I see a lot of examples online about groovy sql in grails. All of them are not including the <code>sql.close()</code> in their code.</p>
<p>I'm wondering why. Is it because Grails has already managed the session connection after a service method is executed?
If so can you give me some evidence(or resources) I can refer to?</p>
| <p>This is not necessary. Please refer to <a href="http://stackoverflow.com/questions/35588115/does-groovy-sql-sql-firstrow-closes-connection-after-execution">Does groovy.sql.Sql.firstRow Closes Connection After Execution?</a></p>
<p>Take a look at the link provided in the comments of the question by dmahapatro <a href="https://github.com/apache/groovy/blob/GROOVY_2_4_X/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L1709" rel="nofollow">https://github.com/apache/groovy/blob/GROOVY_2_4_X/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L1709</a></p>
|
CGI- Password from HTML won't print <p>We were asked to create a twitter-like program using C, HTML, MySQL and CGI. The first step is creating the login page wherein we would ask the user to enter their username and password. I used CGI x HTML in doing that and here are my programs:</p>
<p>HTML:</p>
<pre><code><html>
<body>
<form action='/cgi-bin/password .cgi'>
Username: <input type="text" name="user" ><br>
Password: <input type="password" name ="password" id="password" maxlength="10">
<input type ="submit" value='Submit'>
</form>
</body>
</html>
</code></pre>
<p>CGI: </p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char *data;
char *token;
printf("Content-type:text/html\r\n\r\n");
printf("<!DOCTYPE html><html><head><title>Is Your Password and username this?<title></head><body>");
data = getenv("QUERY_STRING");
if (data) {
token = strtok(data, "&");
while (token) {
while (*token != '=')
{
token++;
}
token++;
token = strtok(NULL, "&");
}
printf("The average is %s\n", token);
}
printf("</body></html>");
exit(EXIT_SUCCESS);
}
</code></pre>
<p>PROBLEM: After entering the username and password and pressing the submit button, the cgi is not printing anything. It's just blank space. How do I fix this and be able to print what the user enetered in the username and password boxes? Thanks! </p>
| <p>For starters I suggest you <em>copy</em> the string you get from <code>getenv</code>. You should never modify the string you get from <code>getenv</code>, and <code>strtok</code> modifies it. </p>
<p>Also, when you call <code>strtok</code> the pointer you get is pointing to the beginning of the name in the <code>name=value</code> pair. By modifying the pointer variable (which you do with <code>token++</code>) you lose the start and will not have a pointer to the name anymore.</p>
<p>Then I suggest you look at something like <a href="http://en.cppreference.com/w/c/string/byte/strchr" rel="nofollow"><code>strchr</code></a> to simplify the code and don't have the inner loop.</p>
<p>Putting it all together, if it is possible you could do something like</p>
<pre><code>char data_ptr = getenv("QUERY_STRING");
char data[strlen(data_ptr) + 1]; // +1 for the string terminator
strcpy(data, data_ptr);
char *name = strtok(data, "&");
while (name != NULL)
{
char *value_sep = strchr(name, '=');
if (value_sep != NULL)
{
*value_sep = '\0';
char *value = ++value_sep;
printf("Name = %s\r\n", name);
printf("Value = %s\r\n", value);
}
else
{
printf("Malformed query string\r\n");
}
name = strtok(NULL, "&");
}
</code></pre>
<p>You can <a href="http://ideone.com/rLovYk" rel="nofollow">see it in "action" here</a>.</p>
|
Cast a kmalloc memory block into multiple structures <p>I have to reserve a large amount of kernel memory (1.5 MB) and share it with the user space. For the short story, I load my kernel module which allocates a large memory buffer in init function using kmalloc, then the user program call ioctl to retrieve the kernel memory address and remaps it using mmap because I need to share this memory between the two parts.</p>
<p>I would like to know if it's possible to cast this memory block as a structure and use the remaining memory as a data buffer and both parts would see the same structure.
It's hard to explain exactly what I want so here is an example.</p>
<p>Here is the structure I want to share between the driver and the user space program :</p>
<pre><code>typedef struct _MemoryBlock {
int param1;
int param2;
short* vm_array1;
short* km_array1;
long* vm_array2;
long* km_array2;
} MemoryBlock;
</code></pre>
<p>Structure used to retrieve memory addresses when calling ioctl :</p>
<pre><code>typedef struct _MemStruct {
void *address; // Kernel memory address
void *vmAddress; // Virtual memory address
size_t size; // Size of the memory block
} MemStruct;
</code></pre>
<p>As I said, the kernel has allocated 1.5 MB of memory using kmalloc, user part then call ioctl and retrieve the kernel address of this memory block using MemStruct (which is updated by the driver and returned). The <em>address</em> field is the kernel address returned by kmalloc and <em>vmAddress</em> is set to NULL and will be updated after the call to mmap :</p>
<pre><code>MemStruct *memStruct = malloc(sizeof(MemStruct));
ioctl(_This.fd, IOCTL_GET_MEM, (unsigned long) memStruct);
</code></pre>
<p>Then I have to remap this memory :</p>
<pre><code>unsigned long mask = getpagesize() - 1;
off_t offset = ((unsigned long) memStruct->address) & ~mask;
memStruct->vmAddress = mmap(0, memStruct->size, PROT_READ | PROT_WRITE, MAP_SHARED, _This.fd, offset);
</code></pre>
<p>And in the user part I would like to do this :</p>
<pre><code>MemoryBlock *memBlock = (MemoryBlock*) memStruct->vmAddress;
memBlock->param1 = 42;
memBlock->param2 = 0;
vm_array1 = (short*) (memStruct->vmAddress + sizeof(MemoryBlock));
km_array1 = (short*) (memStruct->address + sizeof(MemoryBlock));
int i;
for (i = 0; i < 1000; i++) {
vm_array1[i] = 42;
}
</code></pre>
<p>As you can see I use the remaining space of the memory (after the memory used by the structure) to declare a short array.</p>
<p>After that the driver could also access the same memory using the km_array1.</p>
<p>Is this possible ?</p>
| <p>I suppose that the field 'address' of your struct _Menstruct contains the value returned by kmalloc. In this case, this value does'nt have any visibility outside of the kernel space. In the user part, you creates a pointer to short type (km_array1) which points to the kernel address. You will probably have segfault or memory violation. You need to do the assignement in your kernel (km_array1 = (short*)(memstruct->address +sizeof(MemoryBlock)) try writing some random values in the kernel space with the km_array1 variable, and read them in the user part using vm_array1.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.