Showing posts with label Recent Questions - Stack Overflow. Show all posts
Showing posts with label Recent Questions - Stack Overflow. Show all posts

Thursday, 21 July 2016

Weird JRuby Interpreter Issue(s) in CircleCI Containers.

I'm trying to activate JRuby in a containerized CI environment, the machines are running Ubuntu: Linux-3.13.0-91-generic-x86_64-with-Ubuntu-12.04-precise, specifically I have a script which is creating WAR files:

#!/bin/bash --login

if [ "$1" == "" ]; then
BUILD_ENV="production"
else
BUILD_ENV="$1"
fi

echo "Building for: $BUILD_ENV"


rvm install jruby-9.1.2.0
rvm use jruby-9.1.2.0


rvm get head
function nightly_ci() {
    if [[ "$(python -mplatform)" =~ .*Ubuntu*. ]]; then
            export PATH="$PATH:$HOME/.rvm/scripts/rvm"
            chmod 755 ~/.rvm ~/.bashrc && echo rvm_autoupdate_flag=0     >> ~/.rvmrc
            printf '%s' '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
    fi
}
nightly_ci
# install and package all gems (fixes issues with :gem/:ref gemfile)
echo "bundle install --without development test profile"
bundle install --without development test profile
echo "bundle package --all"
bundle package --all

# build war file, smartroom.war
echo "RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile"
RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile --trace
echo "RAILS_ENV=$BUILD_ENV bundle exec warble war"
RAILS_ENV=$BUILD_ENV bundle exec warble war --trace

This works all well and good on localhost, and will run on the containerized environment but only after the JRuby interpreter is explicitly invoked from the command line.

For example I run my script it runs download JRuby, make sure the paths are setup correctly, bundle installs the necessary gems, then makes the WAR. However, this does not work in the containerized environment because the bundle install uses the gems in the native Ruby version and does not install the correct gems into JRuby. If I type rvm install jruby-9.1.2.0 after the script is executed it will tell me that JRuby is already installed and then if I rerun the script it works completely fine. I was thinking it was possible my bash profile was misconfigured but it does not appear to be so. Here is my bashrc on the container:

source ~/.circlerc &>/dev/null

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

# The next line updates PATH for the Google Cloud SDK.
source '/opt/google-cloud-sdk/path.bash.inc'

# The next line enables shell command completion for gcloud.
source '/opt/google-cloud-sdk/completion.bash.inc'

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

And my .profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

My JRuby version: jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.76-b04 on 1.7.0_76-b13 +jit [linux-x86_64]

Lastly I tried invoking the exact set of commands as I do via the shell programmatically, (this needs to be done because I'm trying to automate the WAR generation during a nightly-build) after the script finished and then reran the script and to no avail, I was hoping you guys might have some insight.



from Recent Questions - Stack Overflow http://ift.tt/29Ot8rL
via https://ifttt.com/ IFTTT

Need this if/else Statement to function with a click action from a button

Admittedly I'm really new to javascript and I assume what I am trying to do is simple but I am having a lot of trouble figuring out how to make this function work with the click of a button instead of a page load/reload.

<script type="text/javascript">
    <!--
    var ic = 9; // Number of alternative images
    var xoxo = new Array(ic); // Array to hold filenames

    xoxo[0] = "images/StaminUp.png"
    xoxo[1] = "images/DoubleTap.png"
    xoxo[2] = "images/QucikRevive.png"
    xoxo[3] = "images/ElectricCherry.png"
    xoxo[4] = "images/Juggernog.png"
    xoxo[5] = "images/SpeedCola.png"
    xoxo[6] = "images/MuleKick.png"
    xoxo[7] = "images/WidowsWine.png"
    xoxo[8] = "images/DeadShot.png"

    function pickRandom() {
        if (Math.random)
            return [Math.floor(Math.random() * xoxo.length)];
        else {
            var now = new Date();
            return (now.getTime() / 1000) % xoxo.length;
        }
    }
    // Write out an IMG tag, using a randomly-chosen image name.
    var choice = pickRandom(ic);
    // -->
    
    </script>
<html>
<head>

</head>
<body>
<p id="perk"></p>
<script>document.getElementById("perk").innerHTML = ('<img src= "'+xoxo[choice]+'">')</script>
</body> 
</html> 


from Recent Questions - Stack Overflow http://ift.tt/29Q2nzK
via https://ifttt.com/ IFTTT

Excel VBA Fault Code

Range("A10").End(xlDown).Offset(1, 0).Select

This code has to work, but im getting an error. Does anyone see the fault?

fault 1004 runtime. Methode Offset object range failed



from Recent Questions - Stack Overflow http://ift.tt/29OsZEN
via https://ifttt.com/ IFTTT

System.Indexoutofrangeexception error not understood

Hi i am a beginner at c# and i did not understand why the exception is thrown at the program shown below

PROGRAM:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, i, x=0, y=0;
            Console.WriteLine("Enter the degree of matrix:");
            n = int.Parse(Console.ReadLine());
            int[,] num = new int[n, n];
            int p = n * n;
            for (i = 1; i <= p; i++)
            {
                num[x, y] = i;
                if (num[x, y] % n == 0) { y++; }
                if (y % 2 == 0) { x++; }
                if (y % 2 != 0) { x--; }
            }
            for (i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    Console.Write(num[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

REQUIRED RESULT:

Enter order of matrix:
4

1 8 9  16
2 7 10 15
3 6 11 14 
4 5 12 13

But an exception as stated in the topic is thrown at num[x ,y]=i; . I do not understand why System.IndexOutOfRangeException occurs as the loop clearly ends at the end of the 2d array.

P.S. the program is meant to run only once.



from Recent Questions - Stack Overflow http://ift.tt/29Q2qeN
via https://ifttt.com/ IFTTT

How to scale Node-RED horizontally across a cluster of nodes?

Is it possible to scale out Node-RED horizontally on a cluster of nodes? Could not find any documentation on the same. My scenario is to handle millions of events per second and process them in real time using Node-RED.



from Recent Questions - Stack Overflow http://ift.tt/29OsGtu
via https://ifttt.com/ IFTTT

How to optimize join between a small table and large table?

A small database (one machine n1) and a very large database(on machine n2, with billion records) need to be joined. The app server would need to read the data from the db servers into memory. Should it read the small db first ? and then read from the second db ?

How can this join be executed fastest ? How is this done in real life in general ?



from Recent Questions - Stack Overflow http://ift.tt/29Q2I5f
via https://ifttt.com/ IFTTT

Value of array changes while copying to another array

I looked into this problem, found i was using a local variable in a function so it was going out of scope, changed the code but the problem persists. The code :

#include <iostream>
#include <cmath>
#define SAMPLE_SIZE 12

class sine_curve
{
public:


int get(double amplitude, double time, double *x, double frequency, int sample)
{
    for(sample = 0; sample <= time; sample++)
    {
        x[sample] = amplitude * sin(2 * 3.142 * frequency * sample);
        std::cout << x[sample]<<"\t";
    }

    std::cout << std::endl;
return *x;    }

};

class quantisation_
{
public:

};

int main()
{

double amplitude, time, frequency, x[SAMPLE_SIZE], y[SAMPLE_SIZE];
int sample;

std::cout << "Enter amplitude: ";
std::cin >> amplitude;
std::cout << "Enter time: ";
std::cin >> time;
sine_curve sine;
sine.get(amplitude, time, x, frequency,sample);

for(sample = 0; sample <= time; sample++)
{
    std::cout << x[sample] << std::endl;
}

std::cout << std::endl;

*y = *x;
for(sample = 0; sample <= time; sample++)
{
    std::cout << y[sample] << std::endl;
}
}

The output :: Enter amplitude: 23
Enter time: 3
0 1.00344e-307 2.00687e-307 3.01031e-307
0
1.00344e-307
2.00687e-307
3.01031e-307

0
2.07377e-317
5.61259e-321
2.12203e-314

When I print the array y, the value changes. i followed this link and the rest I don't remember but their answer was also the same.



from Recent Questions - Stack Overflow http://ift.tt/29OsVoD
via https://ifttt.com/ IFTTT

java.lang.IllegalStateException: the temporary folder has not yet been created

I am creating a new @Rule for my use case which looks like

public class ActiveDirectoryConfigurationRule extends ExternalResource {

  @Rule
  public TemporaryFolder temporaryFolder = new TemporaryFolder();

  public File addActiveDirectoryConfigurationToFile(ActiveDirectoryConfiguration configuration) throws IOException {
    File file = temporaryFolder.newFile();
    objectMapper.writeValue(file, configuration);
    return file;
  }

  private ObjectMapper registerJdk8ModuleAndGetObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new Jdk8Module());
    return objectMapper;
  }
}

In my Test I use it as

public class ActiveDirectoryConfigurationStoreTest {

      @Rule
      public ActiveDirectoryConfigurationRule configurationRule = new ActiveDirectoryConfigurationRule();

          @Test
          public void getWhenConfigurationExists() throws Exception {
            ActiveDirectoryConfiguration activeDirectoryConfiguration = //....;
            File configurationToFile = configurationRule.addActiveDirectoryConfigurationToFile(activeDirectoryConfiguration);

            ActiveDirectoryConfigurationStore configurationStore = new ActiveDirectoryConfigurationStore(configurationToFile);
            Optional<ActiveDirectoryConfiguration> mayBeConfiguration = configurationStore.getConfiguration();
            assertTrue(mayBeConfiguration.isPresent());
          }
        }

When I run this test, I get error as

java.lang.IllegalStateException: the temporary folder has not yet been created

    at org.junit.rules.TemporaryFolder.getRoot(TemporaryFolder.java:145)
    at org.junit.rules.TemporaryFolder.newFile(TemporaryFolder.java:78)
    at com.conf.store.ActiveDirectoryConfigurationRule.addActiveDirectoryConfigurationToFile(ActiveDirectoryConfigurationRule.java:48)
    at com.conf.store.ActiveDirectoryConfigurationStoreTest.getWhenConfigurationExists(ActiveDirectoryConfigurationStoreTest.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Seems like when creating your own @Rule, I am not able to depend on any existing @Rule

Is that the issue? and how do I resolve it?



from Recent Questions - Stack Overflow http://ift.tt/29Otpeq
via https://ifttt.com/ IFTTT

Not able to change color of BMGlyphLabel in Swift SpriteKit

According to the BMGlyph library, you can change the label color by doing:

self.label.color = UIColor(...)

The font I created using bmGlyph has a 1px black stroke with a white background.

Using SKACtion.colorizeWithColor() isn't an option since it doesn't work. Already tested it. Is not like any normal SKSpriteNode.

I just wanted to change the label color depending on the user's score. This is my code:

            var color = UIColor.whiteColor()

            if self.score > 10 {
                color = getUIColor(153, g: 185, b: 152, a: 1)
            }else if self.score > 40 {
                color = getUIColor(156, g: 151, b: 217, a: 1)
            }else if self.score > 60 {
                color = getUIColor(127, g: 191, b: 217, a: 1)
            }else if self.score > 80 {
                color = getUIColor(232, g: 121, b: 198, a: 1)
            }else if self.score > 100 {
                color = getUIColor(232, g: 74, b: 95, a: 1)
            }else if self.score > 120 {
                color = getUIColor(125, g: 227, b: 179, a: 1)
            }else if self.score > 150 {
                color = getUIColor(152, g: 226, b: 90, a: 1)
            }else if self.score > 200 {
                let redRand = CGFloat(arc4random_uniform(255))
                let greenRand = CGFloat(arc4random_uniform(255))
                let blueRand = CGFloat(arc4random_uniform(255))
                color = getUIColor(redRand, g: greenRand, b: blueRand, a: 1)
            }

            self.scoreLabel.color = color

Any solution for this? I would like to keep my 1px border font.

Thanks.



from Recent Questions - Stack Overflow http://ift.tt/29Q2c7g
via https://ifttt.com/ IFTTT

Code digger in Visual studio 2013

I am using vs 2013 and new to code digger. For the following code i had generated test data.

Code:

 public static int Test(int value)
    {
        if (value == 0)
        {
            return -1;
        }
        else if (value <= 10)
        {
            return 0;
        }
        else if (value <= 100)
        {
            return 1;
        }
        else
        {
            return 2;
        }
    }

Test data generated by code digger:

value result
  0     -1
  1     0
 11     1
 111    2

My actual doubt is, on what basis test data(value) has been generated by code digger to cover all paths. For an instance value 10 can also been used to get the result 0 but code digger generated 11.



from Recent Questions - Stack Overflow http://ift.tt/29Q2z1T
via https://ifttt.com/ IFTTT

Is there a package in python to query oracle DB w/ only pip install?

I am looking for a package (something like pymongo for MongoDB) which will allow me to do a pip install - and nothing more - in order to query an Oracle DB. Is there one? Can I use mysql-connector - and if so, how do I tell it I am trying to connect to an oracle DB?

Thanks, Larry



from Recent Questions - Stack Overflow http://ift.tt/29OsRoX
via https://ifttt.com/ IFTTT

Using Google Cloud Endpoint, why is there a static/proxy.html used for certain requests?

We're using a Google Cloud Java Endpoint with a Javascript Client and we've noticed that in some cases, requests, originating from IE11, seem to be go thru the cloud endpoint static proxy (http://ift.tt/29UMPcC) -- as the HTTP referrer (referer).

Why?

Furthermore, when those requests fail, they do with the follow error:

response: { status: 0 statusText: No status text available body: {"error":{"code":-1,"message":"A network error occurred, and the request could not be completed."}} }

Any help would be appreciated!



from Recent Questions - Stack Overflow http://ift.tt/29Q3rmS
via https://ifttt.com/ IFTTT

Is there any other methods to hide the DIV?

I have known 3 methods and i have implemented these 3 methods in my code but i want to know any other ways to hide the div using style.

1  display: none 
2  visibility: hidden
3  opacity: 0; 

1st <a href="http://google.com" style="display: none;">hide</a> link.<br />
2nd <a href="http://yahoo.com" style="visibility: hidden;">hide</a> link.<br />
3rd <a href="http://example.com" style="opacity: 0;">hide</a> link.


from Recent Questions - Stack Overflow http://ift.tt/29Q2bAb
via https://ifttt.com/ IFTTT

How to create checkbox looks like font-awesome glyphicon

I want to create a font-awesome glyph-icon which act like checkbox, this means that I need to create a checkbox, which need to disguise as font-awesome icon.

How can I do it?!



from Recent Questions - Stack Overflow http://ift.tt/29OtqPh
via https://ifttt.com/ IFTTT

Does DirectX 12 eliminate the need for texture atlasing?

I remember when I saw the initial talks on DirectX 12, I thought that it eliminated the need for texture atlasing. However it doesn't seem as obvious a conclusion now that I'm going through the documentation.

One feature I have seen that could replace it is dynamic non-uniform indexing of resource arrays in HLSL:

Texture2D<float4> textures[128];
SamplerState sampler;

textures[NonUniformResourceIndex(textureIndex)].Sample(sampler, uv);

Another potential feature is ExecuteIndirect, which encodes what still are a bunch of separate draw and resource changes calls to a buffer and submits it to the GPU at once, in a single CPU call.

Both of these would address the limitations of texture atlases (inability to use border modes on atlas regions, problematic mipmapping), but I'm wondering if the performance characteristics or expected to be similar to texture atlasing or if that technique is still justified.

I'm also curious to know if the answer generalizes to Mantle, Vulkan and Metal.



from Recent Questions - Stack Overflow http://ift.tt/2acqgEE
via https://ifttt.com/ IFTTT

how do I build compute-engine-packages on custom image for google compute engine?

Howdy world: I followed google's documentation, and built a custom image running slackware64-14.2. However, I haven't successfully built the compute-engine-packages on this image yet.

I enabled connecting via serial port, and can login via serial port, but not through gcloud api or cpi, or through standard ssh.

After downloading the latest (july 19, 2016) release, I tried to build it like this:

/usr/bin/python setup.py build
/usr/bin/python setup.py install

After rebooting, the serial console never makes it to login prompt, and hangs at

Compiling GSettings XML schema files: /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas &

Can't find any documentation on building this other than typing --help after the commands and guessing. Can anybody point me in the right direction?



from Recent Questions - Stack Overflow http://ift.tt/2acqsDE
via https://ifttt.com/ IFTTT

multiples ng-repeat for populate table

Im trying to populate the same table with values from different scope variables. The A and B will always have the same lenght.

$scope.a = [1,2,3]
$scope.b = [4,5,6]
<table>
  <thead>
    <tr>
      <th>A</th>
      <th>B</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="itemA in a, itemB in b"> <!-- How should be this ng-repeat?-->
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>

The result should be a table like:

A - B

1 - 4

2 - 5

3 - 6



from Recent Questions - Stack Overflow http://ift.tt/29OtoHo
via https://ifttt.com/ IFTTT

JMeter Master Slave configuration is not working in CentOS

I setup a Master Slave load testing environment using JMeter. I am using 3 CentOS machines with following IP's

xxx.xxx.xxx.1 (Master)
xxx.xxx.xxx.2 (Slave1)
xxx.xxx.xxx.3 (Slave2)

Here are the steps i did.

1) Added the following to the slaves jmeter.properties file:

remote_hosts=xxx.xxx.xxx.1

2) Added the following to master jmeter-server file

#RMI_HOST_DEF=-Djava.rmi.server.hostname=xxx.xxx.xxx.2 `

Then when i'm executing the following command from the /apache-jmeter-2.13/bin folder of xxx.xxx.xxx.2 Slave machine.(I dont have root user access have only SUDO root access)

sudo ./jmeter-server

I'm getting the error

./jmeter-server: line 32: ./jmeter: Permission denied

Is my Master Slave setup is correct? Am i doing something wrong here? Do i need to do anything else to setup master slave?



from Recent Questions - Stack Overflow http://ift.tt/29Q2rzi
via https://ifttt.com/ IFTTT

Django: FileField name special chars replaced automatically

My model:

class MyFile(models.Model):
    file = models.FileField(upload_to="myfiles", max_length=500)
    slug = models.SlugField(max_length=500, blank=True)

When file names contain special chars, such as ' '(space), special chars will be replaced by underscore automatically. Where (in which function) does this happen? How to disable this automatic validation?

Thanks Thanks



from Recent Questions - Stack Overflow http://ift.tt/29OtlLx
via https://ifttt.com/ IFTTT

OleDb Exception

For 5 hour searching i can't find my mistake. I get this exception. What is wrong?

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in MyDictionary.exe

Additional information: Syntax error in INSERT INTO statement.

My code:

public void Insert(Word word)
{
    string language=FindLanguage();
    try
    {
        command.CommandText ="INSERT INTO "+language+" ( Native , Foreign , Definition , AddingDate)  values ( '" + word.Native + "' , '" + word.Foreign + "' , '" + word.Definition + "' ,'" + word.AddingDate + "')";
            command.CommandType = System.Data.CommandType.Text;
            connection.Open();

            command.ExecuteNonQuery();
    }
    catch (Exception)
    {
        throw;
    }
    finally
    {
        if (connection != null)
        {
            connection.Close();
        }
    }
}



from Recent Questions - Stack Overflow http://ift.tt/29Q2mvI
via https://ifttt.com/ IFTTT