I'm trying to add a circle every click on button1. For some reason after adding the first circle, I can't add a second. Please help, it's for a school project... Here's the code: http://ift.tt/1FBNY2q
via Chebli Mohamed
I'm trying to add a circle every click on button1. For some reason after adding the first circle, I can't add a second. Please help, it's for a school project... Here's the code: http://ift.tt/1FBNY2q
I'm attempting to add a build task into a Maven pom file so that I can transfer a jar file as well as some xml files to an SFTP server (it's a VM with Tomcat installed) but I have been unable to so far.
I've had a look at a few links, but they either don't quite match the requirements, have missing steps, or don't work. I'm basically a beginner with Maven so I'm not sure if I'm doing it correctly.
The requirement is that I want to invoke a Maven build, with command line arguments for the hostname, username, and password (which I have working) which then will upload a jar file and the xml files to a VM with Tomcat running in it via SFTP (FTP doesn't work, and I don't think SCP will work as I don't have a passfile). I also don't want to mess with the main Maven settings.xml file to add the connection details in, which some of the links I found seem to be reliant upon.
I have the following profile so far, using FTP, but it doesn't work due to not using SFTP.
<profiles>
<profile>
<!-- maven antrun:run -Pdeploy -->
<id>deploy</id>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<configuration>
<target>
<!-- <loadproperties srcFile="deploy.properties" /> -->
<ftp action="send" server="${server-url}"
remotedir="/usr/share/myappserver/webapps/myapp/WEB-INF/lib"
userid="${user-id}" password="${user-password}" depends="no"
verbose="yes" binary="yes">
<fileset dir="target">
<include name="artifact.jar" />
</fileset>
</ftp>
<ftp action="send" server="${server-url}"
remotedir="/var/lib/myappserver/myapp/spring"
userid="${user-id}" password="${user-password}" depends="no"
verbose="yes" binary="yes">
<fileset dir="src/main/resource/spring">
<include name="*.xml" />
</fileset>
</ftp>
<!-- calls deploy script -->
<!-- <sshexec host="host" trust="yes" username="usr" password="pw"
command="sh /my/script.sh" /> -->
<!-- SSH -->
<taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="maven.plugin.classpath" />
<taskdef name="ftp"
classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
classpathref="maven.plugin.classpath" />
</target>
</configuration>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I tried swapping ftp for sftp, and using org.apache.tools.ant.taskdefs.optional.ssh.SFTP instead, but it didn't seem to work.
So to summarize, the SFTP config needs to be self contained within the pom file as much as possible, with stuff like the host url, username and password being passed in when invoked.
I am trying to call a custom function inside a bxslider callback but the function doesn't get recorgnized (aka: Uncaught Reference Error: nextSlideCustom() is not a function)
my current code looks like
var slider=$('#slider1').bxSlider({
pager: 'true',
onSlideNext: nextSlideHandle()
});
and in a different js file I am defining this function:
function nextSlideHandle(){
console.log("huhu");
}
so what's the problem with my code, or is it mory likely a wrong configuration of the slider or something?
thanks in advance!
How to disable browser auto filling form username and password fields. I have already tried autocomplete="off". It's not working for me. Please find the form below. And help me to solve this.
If I want to compare two values, I can write:
SELECT * FROM table1
JOIN table2 ON table1.col = table2.col;
I've noticed that this does not work if both table1.col and table2.col are NULL. So my corrected query looks like this:
SELECT * FROM table1
JOIN table2 ON
(table1.col = table2.col)
OR
(table1.col IS NULL AND table2.col IS NULL);
Is this the correct way to compare two values? Is there a way to say two values are equal if they are both NULL?
I looked at many examples before I wrote this, and I know many languages and clearly understand the syntax and what is going on in the code I listed below, however, when I compile my program for example:
gcc -o /sbin/"name" readfile.c
I get the following error:
This makes no since to me since my code clearly includes #include <stdio.h> which defines the FILE as referenced here ---- stdio.h.
//PROGRAM (readfile.c)
#include <stdio.h>
int main(){
FILE *fp;
fp = fopen("dummy.txt","w");
fprint(fp, "testing...\n");
fclose(fp);
}
//FILE (dummy.txt) *is in the same directory
Hello World
Let's say I have the array A1:A5 in excel:
A
1
2
3 'test'
4
5 'test2'
How can I return "3"? I'm looking for something in Excel formulas. The blanks are genuine blanks.
I'm currently looping to create a MBTiles map, and add information to my database each time. Here's how I configured my connection and execute actions during the loop:
if ($pdo_mbtiles == null) {
echo "Opening new database connection".PHP_EOL;
$pdo_mbtiles = new PDO('sqlite:'.$filename,
'',
'',
array(
PDO::ATTR_PERSISTENT => true
)
);
}
$pdo_mbtiles->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo_mbtiles->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$q = $pdo_mbtiles->prepare("INSERT INTO tiles (zoom_level, tile_column, tile_row,tile_data) VALUES (:zoom_level, :tile_column, :tile_rowTMS, :tile_data)");
$q->bindParam(':zoom_level', $zoom_level);
$q->bindParam(':tile_column', $tile_column);
$q->bindParam(':tile_rowTMS', $tile_rowTMS);
$q->bindParam(':tile_data', $tile_data, PDO::PARAM_LOB);
$q->execute();
After 1018 times looping (this number doesn't change no matter how many times I try), I get this error message:
SQLSTATE[HY000]: General error: 14 unable to open database file
I checked the solution written here: How to prevent SQLITE SQLSTATE[HY000] [14]? but the echoed message only appears at the first time of the loop, so I assume the PDO connection isn't closed.
I didn't find other documentation relevant to this error code.
What could possibly go wrong here?
I need help on 4b please
‘Warpbreaks’ is a built-in dataset in R. Load it using the function data(warpbreaks). It consists of the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn. It has three variables namely, breaks, wool, and tension.
b. For the ‘AM.warpbreaks’ dataset, compute for the mean and the standard deviation of the breaks variable for those observations with breaks value not exceeding 30.
data(warpbreaks)
warpbreaks <- data.frame(warpbreaks)
AM.warpbreaks <- subset(warpbreaks, wool=="A" & tension=="M")
mean(AM.warpbreaks<=30)
sd(AM.warpbreaks<=30)
This is what I understood this problem and typed the code as in the last two lines. However, I wasn't able to run the last two lines while the first 3 lines ran successfully. Can anybody tell me what is the error here? Thanks! :)
I'm implementing the following CSS Selector
Select all span elements except those which class contains the word icon
So the following seems to be working:
.music-site-refresh span:not([class*="icon"]) {
font-family:Montserrat, sans-serif;
}
But I thought it should be like this:
.music-site-refresh span:not(span[class*="icon"]) {
font-family:Montserrat, sans-serif;
}
But the second one doesn't work in my testbed.
Could anyone explain me which one is correct and why?
On click of button i am trying to create one div and try to append static div into that and this is giving error.
Uncaught TypeError: elm.appendChild is not a function.
<script>
function s()
{
var elm = '<div' +
'style="background-color:orange;height:125px;width:75px;"'+
'</div>';
var x=document.getElementById("ss")
elm.appendChild(x);
}
</script>
<div id="ss">
<ul>
<li style="background-color:grey;">
<h2 class="wheater_CityName">Mumbai</h2><br><br>
<div style=
"margin-left: 30%;
margin-top: -21%;"
>
</div>
<hr style= "margin-top: -83px; ">
</li>
<li>sad</li>
<li>as</li>
</ul>
</div>
<input type="button" value="ss" onclick="s()"/>
I'm using a descendant accessor like so:
var myxml:XMLList = new XMLList;
...
myxml..node
and would like to replace it w/
const sNode:String = 'node';
myxml..[{sNode}]
This sort of thing has worked before.
const sAttrib:String = 'attrib';
myxml.@[{sAttrib}]
works, but trying the same sort of thing w/a descendant accessor causes a compiler error.
Yes, I could do
myxml.descendants(sNode)
but I'd rather do it w/operators, if I can.
The XML might be something like:
<map>
<node>
<node />
</node>
</map>
I have defined an Adapter based as authentication.
Doing a custom security test which works successfully.
But when I wanted to implement User Subscription based Push Notifications and added a mobile security test in authentication Config.XML I am facing lot of issues.
As I'm trying to deploy the app and test in android device. I have also included the mobile security test in android tag of application-descriptor.xml. But facing lot of issues to deploy the adapter itself after this.
Can anyone guide me on this please?
Please refer to the below code snippets which I am using
authenticationConfig.xml
<mobileSecurityTest name="MST1">
<testUser realm="AdapterAuthRealm"/>
<testDeviceId provisioningType="none"/>
</mobileSecurityTest>
<webSecurityTest name="WST1">
<testUser realm="AdapterAuthRealm"/>
</webSecurityTest>
<customSecurityTest name="Master-Password">
<test realm="AdapterAuthRealm" isInternalUserID="true"/>
</customSecurityTest>
Authentication was running fine till I had only the customSecurityTest being defined.
After adding web and mobile security test, there is no response when I give the credentials and click login neither from GUI side nor from the console logs side.
I have also added security test in android tag in application-descriptor.xml as below
<android securityTest="MST1" version="1.0">
<worklightSettings include="false"/>
<pushSender key="xxxxxxxxxxx" senderId="xxxxxxxxxxxxxxx"/>
<security>
<encryptWebResources enabled="false"/>
<testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
<publicSigningKey/>
<packageName/>
</security>
</android>
I am trying to write a recursive directive. I have seen this thread: Recursion in Angular directives
It works when you put the recursive directive under ul-li but goes into infinite loop with a table-tr
<table>
<tr>
<td>{{ family.name }}</td>
</tr>
<tr ng-repeat="child in family.children">
<tree family="child"></tree>
</tr>
</table>
Here is a plunker : http://ift.tt/1LnI4Uo
EDIT: I am not trying to build a tree directive.In my recursive directive I have to use table and tr tags.
Say that i have registered a generic netlink interface using genl_register_family_with_ops with multiple callbacks.
I don't see any warnings about it and I assume the callbacks are serially called but there is no information about how the callbacks are called neither.
Is it possible that multiple callbacks are called concurrently on the same generic netlink interface I have registered? Do I need any synchronization between the callbacks?
To make the question simpler:
Can a single netlink callback be preempted or concurrently run in two cores?
I have trouble with GoogleAPI in my app. I use Google Maps and Places - both needs API key. Everything works fine, until I upload my signed app to Google Play. From what I know and from what I read so far, the API key has to have the same fingerprint as my signed app to work properly from app downloaded from GP. So I created a new API key, add two fingerprints with package name to this key. First with fingerprint from debug.keystore and second from fingerprint from my keystore which I'm using for singning app when I do release build (I'm using android studio ->generate signed apk). This way I assumed that this will work for debug and release, but it work only for debug. To be sure that fingerprint of my app is the same as I have under Google API key I have implemented method which extract fingreprint of my app on runtime. They are match - when I do debug release I see fingerpring "A", when I do it for release I see "B" and I have both of then are the same as fingerprints which I have under API key (section Restrict usage to your Android apps). Note that package name is also correct.
Summary I don't know what I'm missing, or why this is not working when fingerprints are matched - result after release build is that Places api indicates KEY_INVALID and maps is gray, without titles.
I have been trying to find a solution for this but have not found the answer that works for me. Basically what I want are gender specific translations in Symfony2 using twig and the service lingohub.
Our translations files for English look like this:
<trans-unit id="1234" resname="some_key">
<source xml:lang="en">My text goes here </source>
<target xml:lang="en">My text goes here </target>
</trans-unit>
for another language it would look like this:
<trans-unit id="2345" resname="some_key">
<source xml:lang="en">My text goes here </source>
<target xml:lang="es">My text in Spanish goes here</target>
</trans-unit>
what I now want is a gender specific translation. I would love to use transchoice and use the translations from my files
On the Symfony doc I can only find the example with static text.
Question is what do I have to put in twig and what into the translations files?
I tried to put the choices in twig but then it does not translate at all. I also tried to put one key and the choices in the translation file but this also does not work. It selects always the second option and also prints the text as it is (including {f} for female)
What I want is something like:
{% transchoice gender with {'%lastname%': user.lastname} %}
{f} key_for_female |{m} key_for_male | {u} key_for_unknown
{% endtranschoice %}
which will be replaced by translations like
<trans-unit id="1234" resname="key_for_female">
<source xml:lang="en">Hello Ms %lastname% </source>
<target xml:lang="en">Hello Ms %lastname% </target>
</trans-unit>
so that the output is in the end "Hello Ms Doe". What is the correct syntax? ;)
all the files in the folder are adding except the following one, i dont know what the issue, i guess there is a .git folder is that something related.
There are files and folders in the dompdf-module, need to be added to the repo.
These was the response after i add the files from the folder dino/dompdf-module
I have a tab panel with some items inside them, when I add many elements the panel puts a horizontal movement controlers, how can i do to put a tooltip in this controls?
This is the definition of my tab Panel:
var tabPanel = Ext.create('Ext.tab.Panel',{
id: 'tabTabla',
items: [{
title: 'list1',
tooltip: 'list1',
items:[tree]
}, {
title: 'list2',
tooltip: 'list2',
autoWidth : true,
autoHeight : true,
plain : true,
defaults : {
autoScroll : true,
bodyPadding : 0
},
items: [{
xtype : 'label',
text : 'list description.',
},
gridV]
},{
title: 'list3',
tooltip: 'list3',
autoWidth : true,
autoHeight : true,
plain : true,
defaults : {
autoScroll : true,
bodyPadding : 0
},
items: [
gridC
]
}]
});
In this tab Panel I add more panels:
Ext.apply(this, {
title: 'TITLE',
constrain: true,
header : {
titlePosition : 2,
titleAlign : 'center'
},
closable : false,
x : 20,
y : 270,
layout : 'fit',
animCollapse : true,
collapsible : true,
collapseDirection : Ext.Component.DIRECTION_LEFT,
items: [tabPanel]
});
I'm using User Timings to measure how long something takes, by doing e.g. ga('send', 'timing', 'jQuery', 'Load Library', 20, 'Google CDN');
In Google Analytics web interface at Behavior > Site Speed > User Timings I can see both an average and an histogram (by clicking the tab Distribution).
Using the Analytics Core Reporting API I'm able to retrieve the average user timing by querying on the metric ga:avgUserTimingValue. I was wondering if it's possible to retrieve the histogram or the raw data itself. I'm specifically looking to create a box plot using the user timings data.
I want convert just 256 numbers to binary without using if, while, etc., just by using the ? operator and four binary operators.
My programs works well for numbers 1 to 64, but after 64 it does not work! How can I do this? I must store all results in the variable b.
public class NaarBinair {
public static int g=1,b=0;
public static void main(String[] args){
int r1 = g % 2 ;
int q1 = g / 2 ;
int r2 = q1 % 2 ;
int q2 = q1 / 2 ;
int r3 = q2 % 2 ;
int q3 = q2 / 2 ;
int r4 = q3 % 2 ;
int q4 = q3 / 2 ;
int r5 = q4 % 2 ;
int q5 = q4 / 2 ;
int r6 = q5 % 2 ;
int q6 = r5 / 2 ;
int r7 = q6 % 2 ;
int q7 = r6 / 2 ;
String s1 = String.valueOf(r1) ;
String s2 = String.valueOf(r2) ;
String s3 = String.valueOf(r3) ;
String s4 = String.valueOf(r4) ;
String s5 = String.valueOf(r5) ;
String s6 = String.valueOf(r6) ;
String s7 = String.valueOf(r7) ;
b = Integer.parseInt( s7 + s6 + s5 + s4 + s3 + s2 + s1 ) ;
System.out.println(b);
}
}
I have a complex database Model with joins. I don't want to use store procedure so I want to use AutoMapper to flatten it so I can query it. I can't seem to figure out how to flatten it using AutoMapper and structuremap. Below are my classes generated from the Entity Framework using code first from existing database. I am using an Interface and Implementing a class to query the objects. I need to get users who has permissions to a contract.
[Table("Contract")] public class Contract { public Contract() { CDRLs = new HashSet(); ContractDocuments = new HashSet(); WDTOes = new HashSet(); }
[Table("PMO")]
public class PMO
{
public PMO()
{
Contracts = new HashSet<Contract>();
Products = new HashSet<Product>();
USERS = new HashSet<USER>();
}
[Table("USERS")]
public class USER
{
public USER()
{
Organizations = new HashSet<Organization>();
Organizations1 = new HashSet<Organization>();
Products = new HashSet<Product>();
Products1 = new HashSet<Product>();
Programs = new HashSet<Program>();
Programs1 = new HashSet<Program>();
PMOes = new HashSet<PMO>();
ROLES = new HashSet<ROLE>();
}
[Table("ROLES")]
public class ROLE
{
public ROLE()
{
PERMISSIONS = new HashSet<PERMISSION>();
USERS = new HashSet<USER>();
LastModified = DateTime.Now;
InsertDate = DateTime.Now;
}
[Table("PERMISSIONS")] public class PERMISSION {
public PERMISSION()
{
ROLES = new HashSet<ROLE>();
}
I am trying to make a website with a topcontainer with fixed position, giving id position:fixed; in CSS. However, this makes the following class fixed aswell even though I use postion:relative;. Can somebody please help me?
The HTML:
<!DOCTYPE HTML>
<html>
</html>
<body>
<link rel="stylesheet" href="../../css/style_four_sprint.css"/>
<script type="text/javascript">
function selected_four_sprint(val){
if (val == "next"){
document.write(5 + 6)
}
}
</script>
<head>
<title>Hello Wolrd</title>
</head>
<div class="top_container">
<div class="top_container">
<img id="loggo" src="../../images/logo_top_small.png"/>
<div id="toolname">Love to all!</div>
<div class="select">
<table>
<tr>
<td>What do you want?</td>
<td>
<select id="four_sprint_select" onchange="selected_four_sprint(value);">
<option>Select</option>
<option value="next">Next</option>
</td>
</tr>
<table>
</div>
</div>
<div class="teams_container">
<div id="no_team"> No team </div>
<div id="bamse"> Bamse </div>
<div id="skalman"> Skalman </div>
</div>
</body>
The css:
body, html {
padding:0;
width:100%;
margin:0;
height:2000px;
z-index:1;
background:white;
font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.top_container{
top:3px;
left:0px;
position:fixed;
height:43px;
width:100%;
border-bottom:1px solid #bcbaba;
z-index:15000;
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #e5e5e5 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
}
#toolname{
color:black;
float:left;
padding-right:20px;
position:relative;
margin-left:10px;
font-family:'Ericsson Capital TT';
z-index:2000;
font-size:15px;
margin-top:7px;
line-height:30px;
height:30px;
border-right:1px solid #DEDEDE;
/* border-bottom:1px solid #bcbaba; */
}
#loggo{
margin-top:8px;
margin-left:8px;
float:left;
}
.select{
margin-left:10px;
float:left;
font-size:14px;
height:30px;
line-height:30px;
margin-top:5px;
border-right:1px solid #DEDEDE;
padding-right:10px;
}
.teams_container{
width:100%;
background-color:#55555;
padding-top:35px;
position:relative;
right:200px;
font-size:25px;
}
I need close the settings screen from another app, how to works appLock.
here:
my service code, this code works OK
final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
Timer timer = new Timer();
timer.scheduleAtFixedRate(
new TimerTask() {
public void run() {
String appProcesses = activityManager.getRunningTasks(1).get(0).topActivity.getPackageName();
if (appProcesses.equals("com.android.settings")) {
Intent i1=new Intent(service.this, LockedScreen.class);
i1.setAction(Intent.ACTION_MAIN);
i1.addCategory(Intent.CATEGORY_HOME);
i1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i1);
}
}
}
, 0, 1000);
my lock screen code in backpresed and this code don't close settings activity:
@Override
public void onBackPressed() {
super.onBackPressed();
try {
ActivityManager am = (ActivityManager) getApplicationContext().getSystemService("Settings");
Method forceStopPackage;
forceStopPackage = am.getClass().getDeclaredMethod("forceStopPackage", String.class);
forceStopPackage.setAccessible(true);
forceStopPackage.invoke(am, "com.android.settings");
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
error in backpressed, this error is in forceStopPackage = am.getClass().getDeclaredMethod("forceStopPackage", String.class);:
09-11 09:35:21.315 3037-3037/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at pe.com.oscar.settingsintent.LockedScreen.onBackPressed(LockedScreen.java:41)
at android.app.Activity.onKeyUp(Activity.java:2361)
at android.view.KeyEvent.dispatch(KeyEvent.java:2707)
at android.app.Activity.dispatchKeyEvent(Activity.java:2594)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2098)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3608)
at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3578)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2828)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5071)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
HELPP PLEASE!!
I'm curious, how values from string-pool get removed?
suppose:
String a = "ABC"; // has reference of string-pool
String b = new String("ABC"); // has heap reference
b = null;
a= null;
In case of GC, "ABC" from heap get collected.But "ABC" still there in pool(because its in permGen and GC would not effect it).
if we keep adding values like
String c = "ABC"; // pointing to 'ABC' in pool.
for(int i=0; i< 10000; i++) {
c = ""+i; // each iteration add new value in pool. and pervious values has no pointer
}
I want to know, will pool remove unreferred values? if not, it's mean pool eating up unnecessary memory. than what's a point, jvm is using pool? when it could be a performance risk?
The bar item images I prepared are about 35*35 and I use the Sketch to export the [1x & 2x] size images; (I can't insert any images for instances at here because of my zero reputation//Sorry about this!)
Then it displays a blue square :<
the function and title of Item is OK
BUT just the icons are wrong
Could someone tells me how to fix it! Appreciate!!!
I've been designing a game where I want the game to stop as soon as the ball makes contact with the ground. My function below is intended to set up the ground.
class GameScene: SKScene, SKPhysicsContactDelegate {
var ground = SKNode()
let groundCategory: UInt32 = 0x1 << 0
let ballCategory: UInt32 = 0x1 << 1
func setUpGround() -> Void {
self.ground.position = CGPointMake(0, self.frame.size.height)
self.ground.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(self.frame.size.width, self.frame.size.height)) //Experiment with this
self.ground.physicsBody?.dynamic = false
self.ground.physicsBody?.categoryBitMask = groundCategory //Assigns the bit mask category for ground
self.ball.physicsBody?.contactTestBitMask = ballCategory //Assigns the contacts that we care about for the ground
self.addChild(self.ground)
}
}
The problem I am noticing is that when I run the iOS Simulator, the Ground node is not being detected. What am I doing wrong in this case?
Is it possible to connect to a MySQL from Swift with out having a .php script echoing JSON? I want to use it for passwords etc. So I can't have it visible for every one else.
I need to run React in production mode, which presumably entails defining the following somewhere in the enviornment:
process.env.NODE_ENV = 'production';
The issue is that I'm running this behind Tornado (a python web-server), not Node.js. I also use Supervisord to manage the tornado instances, so it's not abundantly clear how to set this in the running environment.
I do however use Gulp to build my jsx files to javascript.
Is it possible to somehow set this inside Gulp? And if so, how do I check that React is running in production mode?
Here is my Gulpfile.js:
'use strict';
var gulp = require('gulp'),
babelify = require('babelify'),
browserify = require('browserify'),
browserSync = require('browser-sync'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer');
var vendors = [
'react',
'react-bootstrap',
'jquery',
];
gulp.task('vendors', function () {
var stream = browserify({
debug: false,
require: vendors
});
stream.bundle()
.pipe(source('vendors.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('build/js'));
return stream;
});
gulp.task('app', function () {
var stream = browserify({
entries: ['./app/app.jsx'],
transform: [babelify],
debug: false,
extensions: ['.jsx'],
fullPaths: false
});
vendors.forEach(function(vendor) {
stream.external(vendor);
});
return stream.bundle()
.pipe(source('build.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('build/js'));
});
gulp.task('watch', [], function () {
// gulp.watch(['./app/**/*.jsx'], ['app', browserSync.reload]);
gulp.watch(['./app/**/*.jsx'], ['app']);
});
gulp.task('browsersync',['vendors','app'], function () {
browserSync({
server: {
baseDir: './',
},
notify: false,
browser: ["google chrome"]
});
});
gulp.task('default',['browsersync','watch'], function() {});
I have a SVG image that is typically displayed numerous times on a single page. I use the exact same tag each time I include the image.
<object width="50px" height="50px" data="/img/uimg0.svg" type="image/svg+xml">
For some reason web browsers are using multiple requests to repeatedly get the exact same SVG image file. Can this be coded differently so the data is downloaded once and reused?
I am using Fragment to create a app which i can slide left and right to view questions. When i submit a question from another fragement it will update the 2nd listFragment/listView. However it always crash. Furthermore i tried storing stuff into the variable '"storeText"', it will be null after onActivityCreated.
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.widget.ArrayAdapter;
import java.util.ArrayList;
public class UserQuestion extends ListFragment {
ArrayAdapter<String> adapter;
private UserQuestionStorage storage = new UserQuestionStorage();
private String storeText;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//Set the list that was needed
ArrayList<String> getQuestionList = storage.getQuestionList();
this.adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, getQuestionList);
//Test Storage
this.storeQuestion(123, 1111, "Question 1", "true", "false");
this.storeQuestion(123, 1111, "Question 2", "true", "false");
storeText = "Storing this to variable.";
setListAdapter(this.adapter);
}
public void storeQuestion(int id, int ownerID, String questionText, String optionOne, String optionTwo) {
Question userQuestion = new Question();
userQuestion.createQuestion(id, ownerID, questionText, optionOne, optionTwo);
this.storage.storeQuestion(questionText);
//TODO: This is not working
Log.d("QUESTION", "" + this.storage.getQuestionList()); //Storage is always wipe.
Log.d("ADAPTER", "" + adapter);
Log.d("TESTSTRING", "" + storeText);
//refreshList();
}
public void refreshList(){
this.adapter.notifyDataSetChanged();
}
}
Again, working on a Chrome extension here. This time, I'm looking to make a transparent png appear at a random place within the window. I feel like I could somehow use jQuery .animate() somehow? I would like to make the image appear somewhere random on the screen, or have it appear on top of a random element on the screen, be it text of an image etc. I have not an idea where to even begin. Any ideas? All input appreciated!
Using Intern I have to get an hidden json object from the page and then build a dictionary. After this, querying this dictionary I should perform an other action on the DOM. The problem is that I do not know how to bind these 2 things, because I want the second operation is executed after the first one is completed.
My code is something like:
var self._formMap = null;
if(self._formMap === null || Object.keys(self._formMap).length === 0) {
return remote.findByXpath(selector)
.getAttribute('value')
.then(function(value) {
var jsonValue = JSON.parse(value);
var formMap = {};
for (var item in jsonValue) {
if (jsonValue.hasOwnProperty(item)) {
var key = jsonValue[item][0].split(/[\/]+/).pop();
formMap[key] = item;
}
}
return formMap;
}).then(function (map) {
self._formMap = map;
return _super_.setInputInForm.call(this, [..., formMap, ..]); // function in another file, but that shares the same remote object.
});
}
In the second step, when I call the setInputInForm, it's like the remote is undefined. Is it maybe because I'm returning the formMap in the first step? Could be a problem of promise? Furthermore, I would like to isolate the first steps, and put it into a function, always returning a promise.
Thanks.
I am using pretty nice plugin which provides tags input directive for AngularJS.
I'm using the parameter onTagAdding to check tag's value before it will be added to input.
on-tag-adding="{expression}"
So, as documentation says:
Expression to evaluate that will be invoked before adding a new tag. The new tag is available as $tag. This method must return either true or false. If false, the tag will not be added.
So here is an live example.
$scope.checkTag = function(tag) {
angular.forEach($scope.forbiddenTags, function(e){
if (e.text === tag.text) {
alert('Tag is forbidden')
return false;
}
})
alert('Execution is continuing');
}
I'm expecting that if entered value matches one for those tags from $scope.forbiddenTags array, then false should be returned and function's execution should be stopped, but it works not like i am expecting =). I have tried just with return but it doesn't work either.
Any help and suggestions will be appreciated! Thanks in advance!
I'm trying to build XercesC-3.2.1 with MinGW.
After running $ mingw32-make in the xerces directory, I get the following error:
mingw32-make[4]: Entering directory '/my/path/to/xerces-c-3.1.2/src'
process_begin: CreateProcess(NULL, /bin/mkdir -p xercesc/util, ...) failed.
make (e=2): The system cannot find the file specified.
Following the XercesC build instructions, I'm running the configure script as
$ ./configure CC=mingw32-gcc CXX=mingw32-g++
but without the variable LDFLAGS=-no-undefined. This is opposed to the build instructions in the XercesC webpage because otherwise the configure script will not work (the flag is not recognized by gcc). The configure script seems to run fine, however. After that, running mingw32-make gives the error above.
My mingw32-make and mingw32-gcc versions are
I tried adding C:\MinGW\libexec\gcc\mingw32\4.8.1 to my PATH, as suggested here but had no exit.
I also fresh installed MinGW in another machine that has no other compiler (or Cygwin, or anything) and got the same results.
I have the following model structure:
class Test < ActiveRecord::Base
has_many :questions
end
class Question < ActiveRecord::Base
belongs_to :test
belongs_to :answer, class_name: 'Choice'
has_many :choices, dependent: :destroy
end
class Choice < ActiveRecord::Base
belongs_to :question
has_one :question_answered, dependent: :nullify, class_name: 'Question', foreign_key: 'answer_id'
end
Now I wanted to create a single form where the user could create/save the tests params and edit all the questions and their choices, and also select which one is the correct answer.
The problem arrives when the user is creating a new question. None of the choices have an id and, therefore, I don't know how to define which will be the correct answer without having to write extra code on my controller (only using accepts_nested_attributes_for).
What I did is: Before saving the nested attributes of Test (but saving test before), I fetch from params all the questions and choices that don't have an id and save them. After that I update the answer_id params for all the questions.
This solutions is working right now but I don't think it's the most elegant one. Knowing Rails and its awesomeness, I know there is a better way of doing this. What do you guys suggest?
for my email signature I want to use a hosted HTML code that is generated through a PHP script, since I may want to change information of the signature I really want that hosted solution to be sure that not only mails in the future, but also sent mails have the "new" signature.
I have a PHP script behind "http://ift.tt/1FBNQ2Z" (yes, no .php ending) waiting for a call. If i open that domain it will output valid HTML code.
But how can I embed the output in my mails as html signature? Iframes are not an option, since they dont work everywhere. Html img tags dont work since that url doesnt output an image.
Any ideas? :-) - Thanks!
I want to get a file thrown by the client using the TFTP session. I mean the TFTP session has to listen to the port continuously and catch the file that was thrown from the client.
I have googled it and couldn't find any library except "package org.apache.commons.net.tftp". In this library I can able to find the methods for transferring the file from server from TFTP session and placing it in users PC and vice versa. but could not able to receive the file which is thrown by the client to the server.
Manually i can achieve this by starting the "pumpkin" as the tftp server and accept the file thrown by the client up on receiving the file through tftp session.where pumpkin will acts like a server on my system.
I can find the python library for the same it's "TFTPY".Can any one help me in doing this in java.Thanks in advance.
Write a program to find whether the given string is Lucky or not.
A string is said to be lucky if the sum of the ASCII values of the characters in the string is even.
Function specifications:
int checkLucky(char * a)I am trying to make a music player, this is where I've put the NSLog to show the current index:
- (void) handle_NowPlayingItemChanged: (id) notification
{
MPMediaItem *currentItem = [musicPlayer nowPlayingItem];
NSUInteger currentIndex = [musicPlayer indexOfNowPlayingItem];
UIImage *artworkImage = [UIImage imageNamed:@"NoSongImage.png"];
MPMediaItemArtwork *artwork = [currentItem valueForProperty:MPMediaItemPropertyArtwork];
if (artwork) {
artworkImage = [artwork imageWithSize: CGSizeMake (200, 200)];
}
[self.artwork setImage:artworkImage];
NSString *titleString = [currentItem valueForProperty:MPMediaItemPropertyTitle];
if (titleString) {
self.songName.text = [NSString stringWithFormat:@"%@",titleString];
} else {
self.songName.text = @"Unknown title";
}
NSLog(@"%li", currentIndex);
}
this is my didSelectRowAtIndexPath for my UITableView:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (songsList == YES){
NSUInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
MPMediaItem *selectedItem = [[songs objectAtIndex:selectedIndex] representativeItem];
[musicPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:[songsQuery items]]];
[musicPlayer setNowPlayingItem:selectedItem];
[musicPlayer play];
songsList = NO;
}
else if (albumsList == YES && albumsSongsList == NO){
albumsSongsList = YES;
NSUInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
MPMediaItem *selectedItem = [[albums objectAtIndex:selectedIndex] representativeItem];
albumTitle = [selectedItem valueForProperty:MPMediaItemPropertyAlbumTitle];
MPMediaItemArtwork *albumArtwork = [selectedItem valueForProperty:MPMediaItemPropertyArtwork];
albumSelected = [albumArtwork imageWithSize: CGSizeMake (44, 44)];
[self.tableView reloadData];
[self.tableView setContentOffset:CGPointZero animated:NO];
}
else if (albumsSongsList == YES){
albumsSongsList = NO;
MPMediaQuery *albumQuery = [MPMediaQuery albumsQuery];
MPMediaPropertyPredicate *albumPredicate = [MPMediaPropertyPredicate predicateWithValue: albumTitle forProperty: MPMediaItemPropertyAlbumTitle];
[albumQuery addFilterPredicate:albumPredicate];
NSArray *albumTracks = [albumQuery items];
NSUInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
MPMediaItem *selectedItem = [[albumTracks objectAtIndex:selectedIndex] representativeItem];
[musicPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:[albumQuery items]]];
[musicPlayer setNowPlayingItem:selectedItem];
[musicPlayer play];
}
}
The BOOLS determine to the tableView willDisplayCell which table to load. The above all display the UITableView correctly with the correct content. The problem is, when I open Albums, and select a song, it seems to play the first song of the album (at the top of the tableView) instead. If I then again go back to albums and select a different song, the correct song is selected. Then again, if I go back once more and select a song, the first song is played again and repeats so on...
In my NSLog, the reason its playing the first song due to a currentIndex of 9223372036854775807
Why is it returning this number, what am I doing incorrectly? Your help is very much appreciated.
I have a four node SQL Server 2014 (12.0.4416) environment with one node acting as a read only node. When I setup routing, I can use the applicationintent = readonly property and everything seems to work. My connections that use applicationintent readonly forward to the correct server. Confirmed by running a select @@servername.
However, when I disconnect the readonly replica from the network or reboot it, the connections now go back to reading from the primary.
Do you have to enable anything to get it working again after a reboot?
Could anyone advise why my scanf function only works once and it ends in a continuous loop.
#include <stdio.h>
#include <conio.h>
int main(void)
{
int accno;
float bbal, charge, rebate, limit, balance;
printf("Enter account number (-1 to end):");
scanf("%d", &accno);
while (accno != -1) // User input phase
{
printf("Enter beginning balance:"); // User input phase
scanf(" %.2f ", &bbal); // leave space after scanf("
printf("Enter total charges:");
scanf(" %.2f ", &charge);
printf("Enter total rebates:");
scanf(" %.2f ", &rebate);
printf("Enter credit limit:");
scanf(" %.2f ", &limit);
balance = bbal - charge + rebate;
// credit limit exceeded phase
if (balance > limit)
{
printf("Account: %u", accno);
printf("Credit limit: %.2f", limit);
balance = bbal - charge + rebate;
printf("Balance: %.2f", balance);
printf("Credit limit exceeded!");
}
printf("Enter account number (-1 to end):");
scanf("%d", &accno);
}
getch();
}
I have a BASh script which produces a script at /directory/filename.sh The file location and filename are a single variable. Because I used cat <<"EOT" >$FILELOCATION to produce the file, the file string is literal so I wasn't able to evaluate the variables inside it at the time it was produced. Instead, I used placeholders, then used sed afterwards.
Here is what I tried; in each instance, $NEWSTRING was not evaluated.
sed -i 's/STRINGTOREPLACE/$NEWSTRING/g' $FILELOCATION
sed -i 's/STRINGTOREPLACE/"$NEWSTRING"/g' $FILELOCATION
sed -i 's/STRINGTOREPLACE/'"$NEWSTRING"'/g' $FILELOCATION
Please advise on the correct way to evaluate a variable in sed within a BASh script.
Thank you!
I have two tables. Table 1 has about 750,000 rows and table 2 has 4 million rows. Table two has an extra ID field in which I am interested, so I want to write a query that will check if the 750,000 table 1 records exist in table 2. For all those rows in table 1 that exist in table 2, I want the respective ID based on same SSN. I tried the following query:
SELECT distinct b.UID, a.*
FROM [Analysis].[dbo].[Table1] A, [Proteus_8_2].dbo.Table2 B
where a.ssn = b.ssn
Instead of getting 750,000 rows in the output, I am getting 5.4 million records. Where am i going wrong? Please help?
I am simply trying to do away with the 'Result' button in the following script. I am happy for the first dropdown options to be selected on page load, and the script to already have run based on this output:
var dd1 = document.getElementById("dropdown");
var dd2 = document.getElementById("dropdown2");
var res = document.getElementById("result");
var output = document.getElementById("output");
function getSpecificText(v1, v2) {
var con = v1.toString() + v2.toString();
var res = "";
switch (con) {
case "500012":
res = text1 ";
break;
case "
500024 ":
res = "
text2 ";
break;
case "
500036 ":
res = "
text3 ";
break;
case "
500048 ":
res = "
text4 ";
break;
case "
500060 ":
res = "
text1 ";
break;
case "
1000012 ":
res = "
text2 ";
break;
case "
1000024 ":
res = "
text3 ";
break;
case "
1000036 ":
res = "
text4 ";
break;
case "
1000048 ":
res = "
text1 ";
break;
case "
1000060 ":
res = "
text2 ";
break;
case "
1500012 ":
res = "
text3 ";
break;
case "
1500024 ":
res = "
text4 ";
break;
case "
1500036 ":
res = "
text1 ";
break;
case "
1500048 ":
res = "
text2 ";
break;
case "
1500060 ":
res = "
text3 ";
break;
case "
2000012 ":
res = "
text3 ";
break;
case "
2000024 ":
res = "
text4 ";
break;
case "
2000036 ":
res = "
text1 ";
break;
case "
2000048 ":
res = "
text2 ";
break;
case "
2000060 ":
res = "
text3 ";
break;
case "
2500012 ":
res = "
text3 ";
break;
case "
2500024 ":
res = "
text4 ";
break;
case "
2500036 ":
res = "
text1 ";
break;
case "
2500048 ":
res = "
text2 ";
break;
case "
2500060 ":
res = "
text3 ";
break;
// ...
}
return res
}
function getSelected() {
var v1 = dd1.options[dd1.selectedIndex].value;
var v2 = dd2.options[dd2.selectedIndex].value;
output.innerHTML = getSpecificText(v1, v2);
}
res.addEventListener("
click ", getSelected);
<p>
Value:
<select name="dropdown" id="dropdown">
<option value="5000">5000</option>
<option value="10000">10000</option>
<option value="15000">15000</option>
<option value="20000">20000</option>
<option value="25000">25000</option>
</select>
Months:
<select name="dropdown2" id="dropdown2">
<option value="12">12</option>
<option value="24">24</option>
<option value="36">36</option>
<option value="48">48</option>
<option value="60">60</option>
</select>
Months
<button id="result">Result</button>
<div id="output"></div>
</p>
I want to forecast measure value for the next month using data from complete previous months.
For example in this moment September 11, I have to forecast the value of the September month (cause the September month is not over) based on January-August values.
I am using MDX function LinRegPoint with the hierarchy detailed below
- DimTime
- Hierarchy Time
- Year
- Quarter
- Month
This is the query I been trying without success:
WITH
MEMBER [Measures].[Trend] AS
LinRegPoint
(
Rank
(
[Time].[Hierarchy Time].CurrentMember
,[Time].[Hierarchy Time].CurrentMember.Level.MEMBERS
)
,Descendants
(
[Time].[Hierarchy Time].[2015]
,[Time].[Hierarchy Time].CurrentMember.Level
)
,[Measures].[Quality]
,Rank
(
[Time].[Hierarchy Time]
,[Time].[Hierarchy Time].Level.MEMBERS
)
)
SELECT
{
[Measures].[Quality]
,[Measures].[Trend]
} ON COLUMNS
,Descendants
(
[Time].[Hierarchy Time].[2015]
,[Time].[Hierarchy Time].[Month]
) ON ROWS
FROM [Cube];
The above query return all month forecasted values to today date including the September month, however It forecasts the September value taking the real values from January to September current date. I need the LinRegPoint function just takes the previous complete months in this case January to August.
Note the query returns a forecasted value for 9 month (September) but it is using the real value to calculate it. It would result in a misunderstood line as shown in the below images.
This image shows the drawn line taking the previous full-month (1-8):
Note the positive slope line.
This image shows the drawn line taking all months (1-9)
Note the negative slope line.
Question: How can I exclude the no complete current month from real values but allowing the forecasted value be calculated.
EDIT: The set should be changing to exclude the last month member in real values but calculating the forecasted value for it.
Thanks for considering my question.
Just saw this error today on our application. We have a small box on top right of the webpage. It gets updated every minute. What it does is make a jsonp call to each of our hospital partners via intranet and pulls the latest news. The issue doesn't happen often. I actually found out why the error is happening.
Uncaught TypeError: jQuery11020382352269484832883_1441911920555 is not a function
This error shows up in console when a jsonp request doesn't get the response from the jsonp service within the time assigned on the jsonp timeout.
I wrapped our endpoint call with try-catch but it is still spitting out that error. I want to get rid of "Uncaught TypeError" and display our own custom error.
I have a txt file consisting of tab-separated data with type double. The data file is over 10 GB, so I just wish to read the data line-by-line and then do some processing. Particularly, the data is layout as an matrix with, say 1001 columns, and millions of rows. Below is just a fake sample to show the layout.
10.2 30.4 42.9 ... 3232.000 23232.45
...
...
7.234 824.23232 ... 4009.23 230.01
...
For each line I'd like to store the first 1000 values in an array, and the last value in a separate variable. I am new to C, so it would be nice if you could kindly point out major steps.
Update:
Thanks for all valuable suggestions and solutions. I just figured out one simple example where I just read a 3-by-4 matrix row by row from a txt file. For each row, the first 3 elements are stored in x, and the last element is stored in vector y. So x is a n-by-p matrix with n=p=3, y is a 1-by-3 vector.
Below is my data file and my code.
Data file:
1.112272 -0.345324 0.608056 0.641006
-0.358203 0.300349 -1.113812 -0.321359
0.155588 2.081781 0.038588 -0.562489
My code:
#include<math.h>
#include <stdlib.h>
#include<stdio.h>
#include <string.h>
#define n 3
#define p 3
void main() {
FILE *fpt;
fpt = fopen("./data_temp.txt", "r");
char line[n*(p+1)*sizeof(double)];
char *token;
double *x;
x = malloc(n*p*sizeof(double));
double y[n];
int index = 0;
int xind = 0;
int yind = 0;
while(fgets(line, sizeof(line), fpt)) {
//printf("%d\n", sizeof(line));
//printf("%s\n", line);
token = strtok(line, "\t");
while(token != NULL) {
printf("%s\n", token);
if((index+1) % (p+1) == 0) { // the last element in each line;
yind = (index + 1) / (p+1) - 1; // get index for y vector;
sscanf(token, "%lf", &(y[yind]));
} else {
sscanf(token, "%lf", &(x[xind]));
xind++;
}
//sscanf(token, "%lf", &(x[index]));
index++;
token = strtok(NULL, "\t");
}
}
int i = 0;
int j = 0;
puts("Print x matrix:");
for(i = 0; i < n*p; i++) {
printf("%f\n", x[i]);
}
printf("\n");
puts("Print y vector:");
for(j = 0; j < n; j++) {
printf("%f\t", y[j]);
}
printf("\n");
free(x);
fclose(fpt);
}
With above, hopefully things will work if I replace data_temp.txt with my raw 10 GB data file (of course change values of n,p, and some other code wherever necessary.)
I have additional questions that I wish if you could help me.
char line[] as char line[(p+1)*sizeof(double)] (note not multiplying n). But the line cannot be read completely. How could I assign memory JUST for one single line? What's the lenght? I assume it's (p+1)*sizeof(double) since there are (p+1) doubles in each line. Should I also assign memory for \t and \n? If so, how?Again I am new to C, any comments are very appreciated. Thanks a lot!
I have this code:
val rdd = sc.textFile(sample.log")
val splitRDD = rdd.map(r => StringUtils.splitPreserveAllTokens(r, "\\|"))
val rdd2 = splitRDD.filter(...).map(row => createRow(row, fieldsMap))
sqlContext.createDataFrame(rdd2, structType).save(
org.apache.phoenix.spark, SaveMode.Overwrite, Map("table" -> table, "zkUrl" -> zkUrl))
def createRow(row: Array[String], fieldsMap: ListMap[Int, FieldConfig]): Row = {
//add additional index for invalidValues
val arrSize = fieldsMap.size + 1
val arr = new Array[Any](arrSize)
var invalidValues = ""
for ((k, v) <- fieldsMap) {
val valid = ...
var value : Any = null
if (valid) {
value = row(k)
// if (v.code == "SOURCE_NAME") --> 5th column in the row
// sourceNameCount = row(k).split(",").size
} else {
invalidValues += v.code + " : " + row(k) + " | "
}
arr(k) = value
}
arr(arrSize - 1) = invalidValues
Row.fromSeq(arr.toSeq)
}
fieldsMap contains the mapping of the input columns: (index, FieldConfig). Where FieldConfig class contains "code" and "dataType" values.
TOPIC -> (0, v.code = "TOPIC", v.dataType = "String")
GROUP -> (1, v.code = "GROUP")
SOURCE_NAME1,SOURCE_NAME2,SOURCE_NAME3 -> (4, v.code = "SOURCE_NAME")
This is the sample.log:
TOPIC|GROUP|TIMESTAMP|STATUS|SOURCE_NAME1,SOURCE_NAME2,SOURCE_NAME3|
SOURCE_TYPE1,SOURCE_TYPE2,SOURCE_TYPE3|SOURCE_COUNT1,SOURCE_COUNT2,SOURCE_COUNT3|
DEST_NAME1,DEST_NAME2,DEST_NAME3|DEST_TYPE1,DEST_TYPE2,DEST_TYPE3|
DEST_COUNT1,DEST_COUNT2,DEST_COUNT3|
The goal is to split the input (sample.log), based on the number of source_name(s).. In the example above, the output will have 3 rows:
TOPIC|GROUP|TIMESTAMP|STATUS|SOURCE_NAME1|SOURCE_TYPE1|SOURCE_COUNT1|
|DEST_NAME1|DEST_TYPE1|DEST_COUNT1|
TOPIC|GROUP|TIMESTAMP|STATUS|SOURCE_NAME2|SOURCE_TYPE2|SOURCE_COUNT2|
DEST_NAME2|DEST_TYPE2|DEST_COUNT2|
TOPIC|GROUP|TIMESTAMP|STATUS|SOURCE_NAME3|SOURCE_TYPE3|SOURCE_COUNT3|
|DEST_NAME3|DEST_TYPE3|DEST_COUNT3|
This is the new code I am working on (still using createRow defined above):
val rdd2 = splitRDD.filter(...).flatMap(row => {
val srcName = row(4).split(",")
val srcType = row(5).split(",")
val srcCount = row(6).split(",")
val destName = row(7).split(",")
val destType = row(8).split(",")
val destCount = row(9).split(",")
var newRDD: ArrayBuffer[Row] = new ArrayBuffer[Row]()
//if (srcName != null) {
println("\n\nsrcName.size: " + srcName.size + "\n\n")
for (i <- 0 to srcName.size - 1) {
// missing column: destType can sometimes be null
val splittedRow: Array[Any] = Array(Row.fromSeq(Seq((row(0), row(1), row(2), row(3),
srcName(i), srcType(i), srcCount(i), destName(i), "", destCount(i)))))
newRDD = newRDD ++ Seq(createRow(splittedRow, fieldsMap))
}
//}
Seq(Row.fromSeq(Seq(newRDD)))
})
I'm trying to get the width of a selected text in pixels and show it as an alert();. Does this exist?
EDIT (copied it from the comment I wrote below)
I did many efforts but all went in vain, now i'm trying to see if I can get the value of selection.toString() and then bind it to .width() if i can manage to do it, i'm pretty sure i can combine them both to get the width I'm looking for.
EDIT 12:42 am
I tried this
if(selection.toString() != '' ){
var selected = selection.toString();
alert($(selected).width());
}
I get the value of null