dimanche 30 novembre 2014

Javac Compiling Error


Vote count:

0




I'm getting an error while compiling this source code, using UTF-8 encoding: PlayerJoin.java:1: error: illegal character: '\u00bb' package my.package; ^ PlayerJoin.java:1: error: illegal character: '\u00bf' package my.package; ^ 2 errors



asked 21 secs ago

Lme

1






Javac Compiling Error

Cannot get Stripe Example app to send test payment to Stripe account


Vote count:

0




I have tried to use the StripeExample here (http://ift.tt/1qJGpkD) to test the ApplePay functionality. I have set up Stripe and Parse accounts and followed the instructions on the Github page but cannot seem to get the app to communicate with my Stripe dashboard to display the test payments.


Any tips on how to troubleshoot this issue? Thanks in advance.



asked 1 min ago







Cannot get Stripe Example app to send test payment to Stripe account

Testing UCanAccess with Oracle SQL Developer -> ODBC error


Vote count:

0




Quite exciting to find this jdbc driver for ms access.


However, when I try to test it with Oracle SQL Developer, I got:



Status : Failure -Test failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified



Quoted from UCanAccess website:



Because it is a pure java implementation it run in both Windows and non-Windows Operative Systems(e.g., linux/unix). No ODBC needed.



What am I missing? Or I must configure ODBC in Windows environment?



asked 20 secs ago

wez

17






Testing UCanAccess with Oracle SQL Developer -> ODBC error

How to start java project's exe file as windows service?


Vote count:

0




hi i tried to start java project's exe file as a service from command sc create "ServiceName" binpath= "fullpath\Service.exe" start= auto it has been added to services but when i restart my PC it's status is stopped when i mannualy start it from services window it says Error 1053 : The service did not respond to the start or control request in a timely fashion i ve tried HKEY too but nothing happened any idea?



asked 1 min ago







How to start java project's exe file as windows service?

Using jQuery Tokeninput within a nested form partial


Vote count:

0




I'm using jQuery Tokeninput as shown in this Railscast. I'd like to combine this functionality in a nested form but get the error



undefined method `artists' for #<SimpleForm::FormBuilder:0x007febe0883988>


For some reason its not recognizing the track parameter in my form builder which is stopping me to get a hold of albums I have on record.



<div class="input">
<%= f.input :artist_tokens, label: 'Featured Artists', input_html: {"data-pre" => f.artists.map(&:attributes).to_json} %>
</div>


Keep in mind this works in my track form but just not in my album form since its nested. What should I do to get this to work?



class ArtistsController < ApplicationController
def index
@artists = Artist.order(:name)
respond_to do |format|
format.html
format.json {render json: @artists.tokens(params[:q])}
end
end
end


Models



class Artist < ActiveRecord::Base
has_many :album_ownerships
has_many :albums, through: :album_ownerships

has_many :featured_artists
has_many :tracks, through: :featured_artists


def self.tokens(query)
artists = where("name like ?", "%#{query}%")

if artists.empty?
[{id: "<<<#{query}>>>", name: "Add New Artist: \"#{query}\""}]
else
artists
end
end

def self.ids_from_tokens(tokens)
tokens.gsub!(/<<<(.+?)>>>/) {create!(name: $1).id}
tokens.split(',')
end
end

class Albums < ActiveRecord::Base
attr_reader :artist_tokens

accepts_nested_attributes_for :tracks, :reject_if => :all_blank, :allow_destroy => true

has_many :albums_ownerships
has_many :artists, through: :albums_ownerships

def artist_tokens=(ids)
self.artist_ids = Artist.ids_from_tokens(ids)
end
end

class Track < ActiveRecord::Base
attr_reader :artist_tokens

belongs_to :album

has_many :featured_artists
has_many :artists, through: :featured_artists

def artist_tokens=(ids)
self.artist_ids = Artist.ids_from_tokens(ids)
end
end


class AlbumOwnership < ActiveRecord::Base
belongs_to :artist
belongs_to :album
end

class FeaturedArtist < ActiveRecord::Base
belongs_to :artist
belongs_to :track
end


Album Form



<%= simple_form_for(@album) do |f| %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>

<h1>Tracks</h1>

<%= f.simple_fields_for :tracks do |track| %>
<%= render 'track_fields', :f => track %>
<% end %>
<div id='links'>
<%= link_to_add_association 'Add Field', f, :tracks %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<% end %>


Track Partial



<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>

<div class="input">
<%= f.input :artist_tokens, label: 'Featured Artists', input_html: {"data-pre" => f.artists.map(&:attributes).to_json} %>
</div>


JS



$(function() {
$('#track_artist_tokens').tokenInput('/artists.json', {
prePopulate: $("#track_artist_tokens").data("pre"),
theme: 'facebook',
resultsLimit: 5
});
});


asked 30 secs ago







Using jQuery Tokeninput within a nested form partial

Library for jQuery Parallax Videos


Vote count:

0




I'm trying to build a website that uses the jquery parallax plugin, but instead of using basic images / stock photography on each slide I want to use video footage. Since I want to use video footage instead of static images is there a specific library / plugin that I can use that is best suited to this type of requirement?


Thanks!



asked 38 secs ago







Library for jQuery Parallax Videos

PCI Compliant app, mobile banking


Vote count:

0




I am working with a client who wants an app for a refillable credit card, where users can login and refill their credit cards by depositing from their bank account directly. Of course I need to make sure this is PCI compliant. My question is : Whats the easiest way to accomplish this? use paypal / Venmo style? or develop it myself?



asked 43 secs ago

Huang

333






PCI Compliant app, mobile banking

Get the cluster size of a disk in C#--Get error on 'GetDiskFreeSpace'


Vote count:

0




I am trying to get the cluster size of a disk in C#. Everything I have found says to use "GetFreeDiskSpace," but I can't get it to work. It appears as if I am missing a using or something.


When I Google the "The name 'GetDiskFreeSpace' does not exist in the current context" it brings up everything except for this specific error. If I do an exact phrase search, Google says nothing is found and then displays the non-exact phrase search results.


I am trying to determine where the 'GetFreeDiskSpace' comes from, not how to fix the "The name 'UnknownKeyWord' does not exist in the current context" message.


I need to get the actual cluster size of a disk, not so I can determine the size on disk, but so I can populate a ComboBox.


NOTE: I am using VS 2010.


Here are the usings I have:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Globalization;
using System.Management;
using System.Runtime.InteropServices;


I also have the following:



// Pinvoke for API function
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]


The code (which is not finished...I need to parse out the information from GetFreeDiskSpace) I have to get the cluster size is:



private void btnRefreshDrives_Click(object sender, EventArgs e)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady)
{
strDriveInfo = d.Name + " " + d.VolumeLabel;
strCurrentFS = d.DriveFormat;
strDriveLetter = d.Name;
// The GetFreeDiskSpace has the red squiggly line under it in VS.
ClusterSize = SectorsPerCluster * BytesPerSector;
GetDiskFreeSpace(strDriveLetter, out SectorsPerCluster, out BytesPerSector, out NumberOfFreeClusters, out TotalNumberOfClusters);
}
}
}


asked 11 secs ago







Get the cluster size of a disk in C#--Get error on 'GetDiskFreeSpace'

Loop through and an array with conditions


Vote count:

0




I'm trying to count how many files are not empty in a text file. I can count the number of total files, I just having trouble with creating the loop for ONLY the files with data in them.



while(s != null)
{
array = s.split(delimiter);
if(!array[0].equals(Empty_Record))
{
int total = 0;
for(int i = 0; i < array.length; i++)
total +=i;
ATextField.setText(total);
}
s = reader.readLine();
}
reader.close();
}
catch(Exception e)
{
System.out.println("Message: " + e);
}
}


asked 1 min ago







Loop through and an array with conditions

Draggable circle in swing blinks when I drag it


Vote count:

0




I'm implementing a Swing program that draws shapes to the screen and then lets the user drag them around. I can draw a shape just fine, but once I click on a shape to drag it, that shape starts to blink as it is dragged.


This is my GUI class and my MouseAdapter class:



public class GUI extends JFrame {
private JMenu addShapeMenu = new JMenu("Add Shape");
private JLabel statusBar = new JLabel();
private List<Shape> _shapes;
private Shape chosenShape;
private boolean isShapeClicked = false;
private List<String> shapeSubclasses = new ArrayList<>();

public GUI() throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
super("DrawingBoard");
setSize(500, 500);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(addShapeMenu);

getContentPane().setLayout(new BorderLayout());

getLoadedShapes();
for(String shape : shapeSubclasses)
{
Class drawableShape = Class.forName("gui.Drawable" + shape);
addShapeMenu.add(((DrawableShape)drawableShape.newInstance()).getInstance().getMenuItem());
}

add(statusBar, BorderLayout.SOUTH);
statusBar.setText("Add a shape.");

MouseHandler mouseHandler = new MouseHandler();
addMouseListener(mouseHandler);
addMouseMotionListener(mouseHandler);

setVisible(true);
}

private void getLoadedShapes() throws ClassNotFoundException, NullPointerException {
String classPath = Shape.class.getResource("").getPath();
classPath = classPath.replaceAll("%20", " ");

File root = new File(classPath);
for (File file : root.listFiles()) {
if (!file.isDirectory()) {
if (file.getName().endsWith(".class")) {
String className = file.getName().substring(0, file.getName().length() - 6);
Class<?>[] interfaces = Class.forName("draw." + className).getInterfaces();
for(Class<?> classInterface : interfaces)
{
if(classInterface.getName().compareTo("draw.Shape") == 0)
shapeSubclasses.add(className);
}
}
}
}
}

public void setDrawing(Drawing drawing)
{
_shapes = drawing.getShapes();
AddShapeListener.getInstance().setDrawing(drawing);
AddShapeListener.getInstance().setGUI(this);
for (Component component : addShapeMenu.getMenuComponents()) {
((JMenuItem)component).addActionListener(AddShapeListener.getInstance());
}
}

public void paint(Graphics graphics)
{
super.paint(graphics);
for(Shape shape : _shapes)
try
{
Class painter = Class.forName("gui.Drawable" + shape.getClass().getSimpleName());
((DrawableShape)painter.newInstance()).getInstance().paint(getGraphics(), shape);
}

catch(Exception e)
{
JOptionPane.showMessageDialog(this, "Failed to load Drawable" + shape);
}
}

public void setStatusBar(String message)
{
statusBar.setText(message);
}

private class MouseHandler extends MouseAdapter implements MouseMotionListener {
public void mousePressed(MouseEvent event) {
_shapes.forEach(shape -> {
if(shape.isPointInside(event.getX(), event.getY()))
chosenShape = shape;
isShapeClicked = true;
});
}

public void mouseDragged(MouseEvent event) {
if (isShapeClicked) {
chosenShape.moveTo(event.getX(), event.getY());
repaint();
}
}

public void mouseReleased(MouseEvent event) {
isShapeClicked = false;
chosenShape = null;
}
}
}


where my DrawableCircle class has a method paint:



public void paint(Graphics graphics, Shape shape)
{
int radius = ((Circle)shape).getRadius();
graphics.fillOval(shape.getX() - radius, shape.getY() - radius, radius * 2, radius * 2);
}


the DrawRectangle class is similar.



asked 17 secs ago







Draggable circle in swing blinks when I drag it

Check if webpage is closed and run process


Vote count:

0




I have a function that needs to know if the user has closed a page (either by tab, or backing out, or whatever) and run a MVC Controller so I can run a few internal processes. Is this feasible with Javascript or AJAX or impossible? I have the following code:



$(window).bind('beforeunload', function (e) {
// code to execute when browser is closed
e.$.post("/Functions/Left" });

});


But its not doing anything as far as I can see. The Controller processes some database information, and yes it has HTTPPOST.



asked 33 secs ago







Check if webpage is closed and run process

How to Stop abroad connect.facebook. in tablet and mobile faster load time


Vote count:

0




the code this


function downloadJSAtOnload() {var element = document.createElement("script");element.src = "//connect.facebook.net/en_US/all.js#xfbml=1";document.body.appendChild(element);}if (window.addEventListener)window.addEventListener("load", downloadJSAtOnload, false);else if (window.attachEvent)window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload;


my blog and I want to do not downloading thos http://connect.facebook.net/en_US/all.js#xfbml=1 Is there any way;;very slow in tablet and i have ather bottom share



asked 30 secs ago







How to Stop abroad connect.facebook. in tablet and mobile faster load time

apt-get fails to continue running in a loop after one failed install in bash


Vote count:

0




I am trying to create a bash script that will automatically install stuff using apt-get. I am using the following methods for the installation:


Method 1


Install(){ for TempVar in "$1" do eval 'sudo apt-get install '$TempVar done }


Method 2


Install(){ eval 'sudo apt-get install '$TempVar }


for TempVar in "$1" do Install '(insert programs here separated by spaces)' done


In both cases when something failed to install apt-get refused to install anything else. Naturally, apt-get functioned normally in the same script after the for loop ended. I am under the impression that apt-get retains its error status until the loop it was executed in is fully terminated. Is there a way to get around this?



asked 1 min ago







apt-get fails to continue running in a loop after one failed install in bash

How to make button "send report" on Error MsgBox?


Vote count:

0




Error MsgBox Is there a way on this "errHandler" to place the button "send report" or something similarly, if someone gets an error that can be recorded somehow. This is the code that I use for errHandler:



On Error GoTo errHandler


....some code.....


errHandler: MsgBox "An Error has Occurred " & vbCrLf & _ "The error number is: " & Err.Number & vbCrLf & _ Err.Description & vbCrLf & "Please notify the administrator" End Sub



asked 1 min ago







How to make button "send report" on Error MsgBox?

Can't get the list to put on my tableView. JavaFX and Hibernate


Vote count:

0




i'm having some trouble with getting the list of person from my db and put in the tableview, here is the code:


FuncionarioViewController:


private static ObservableList listaFuncionarios = FXCollections.observableArrayList(); private FuncionarioController funcionarioController; private SessionFactory sessionFactory; private MainApp mainApp;



@FXML
private TableView<Funcionario> tableFunc;
@FXML
private TableColumn<Funcionario, String> nomeColumn;
@FXML
private TableColumn<Funcionario, Number> cpfColumn;
@FXML
private TableColumn<Funcionario, String> cargoColumn;
@FXML
private Button deleteBtn;
@FXML
private Button editBtn;
@FXML
private TextField txPesquisa;


public FuncionarioViewController() {

}
@FXML
private void initialize() {
nomeColumn.setCellValueFactory(cellData -> cellData.getValue().nomeProperty());
cpfColumn.setCellValueFactory(cellData -> cellData.getValue().cpfProperty());
cargoColumn.setCellValueFactory(cellData -> cellData.getValue().cargoProperty());
tableFunc.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue,newValue)-> handleFuncionarioClicado(newValue));
}


public void addFunc() {
List<Funcionario> funcionarios = funcionarioController.findAllFuncionario();
listaFuncionarios.clear();
listaFuncionarios.addAll(funcionarios);
tableFunc.setItems(listaFuncionarios);
}

private void handleFuncionarioClicado(Funcionario func) {
if(func == null) {
deleteBtn.setDisable(true);
editBtn.setDisable(true);
} else {
deleteBtn.setDisable(false);
editBtn.setDisable(false);
}
}


the code of creating a query in db



public List<Funcionario> findAllFuncionario() {
try {
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
List<Funcionario> funcionarios = session.createQuery("from funcionarios").list();
session.getTransaction().commit();
return funcionarios;

} catch (Exception e) {
e.printStackTrace();
return null;
}

}


mainApp class



public void showFunc() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("../view/Funcionarios.fxml"));
AnchorPane funcScreen = (AnchorPane) loader.load();
primaryStage.setTitle("EasySale - Funcionários");
rootLayout.setCenter(funcScreen);
FuncionarioViewController controller = loader.getController();
controller.setMainApp(this);
controller.setSessionFactory(sessionFactory);
controller.addFunc();

} catch (IOException e) {
e.printStackTrace();
}
}


And i'm getting these erros when i call showFunc()



Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.control.MenuItem.fire(Unknown Source)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(Unknown Source)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$324(Unknown Source)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer$$Lambda$365/1130772527.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
... 44 more
Caused by: java.lang.NullPointerException
at easysale.view.FuncionarioViewController.addFunc(FuncionarioViewController.java:58)
at easysale.main.MainApp.showFunc(MainApp.java:240)
at easysale.view.RootLayoutController.showFunc(RootLayoutController.java:26)
... 53 more


Have no idea of what is the problem here.



asked 18 secs ago







Can't get the list to put on my tableView. JavaFX and Hibernate

Redirect to URL then update menu ( Ajax) in asp.net


Vote count:

0




I have a problem when the user clicks on the link, it must redirect to the page then update the left-menu.


But when i put the url link in href. it update the menu then rediect to the page. Then, the menu disappear.


The code in the Layout Page



<a class="Tab" href="~/Default1" data-tabid='1'> Link1 </a>
<a class="Tab" href="~/Default2" data-tabid='2'> Link2 </a>
<a class="Tab" href="~/Default3" data-tabid='3'> Link3 </a>

<script type="text/javascript">
$('.Tab').click(function (e) {
// e.preventDefault(); alert($(this).data('taskid'));
$.ajax({
type: "POST",
cache: false,
url: "MenuItem/Menu",
data: { MenuId: $(this).data('tabid') },
dataType: "html",
async: true,
success: function (data) {
$("#menuContent").html(data);
alert('success');
},
error: function () {
alert('error');
}
});

});


</script>


Any help is highly appreciated.



asked 1 min ago







Redirect to URL then update menu ( Ajax) in asp.net

Corona SDK function that runs only after a specific collision?


Vote count:

0




In Corona SDK, is it possible to write a function that runs only when an object collides with another particular object, not just experiences a collision in general?



asked 1 min ago







Corona SDK function that runs only after a specific collision?

Powershell function creation with Set-Item and GetNewClosure


Vote count:

0




I am attempting to build a function that can itself create functions through the Set-Item command where I pass a scriptblock for the new function to the -Value parameter of Set-Item. I'm running into an issue where using GetNewClosure on the scriptblock doesn't seem to be working and I just don't know what I'm doing wrong.


In the code below, first I'm creating a function manually (testFunc) which works as intended, in that setting $x to 2 after the function creation will not cause the function to return 2; instead it returns 1 because that was the value of $x at the time the function was created. But when I try to do the same through the make-function function, the behavior changes.


I'm sure I'm overlooking something small.



> $x = 1
> $block = {$x}.GetNewClosure()
> Set-Item function:global:testFunc -Value $block
> testFunc
1

> $x = 2
> testFunc
1 # still 1 because of GetNewClosure - this is expected behavior

> $x = 1
> function make-function { $block2 = {$x}.GetNewClosure()
Set-Item function:global:testFunc2 -Value $block2
}
> make-function
> testFunc2
1

> $x = 2
> testFunc2
2 # Why is it not returning 1 in this case?


asked 28 secs ago







Powershell function creation with Set-Item and GetNewClosure

Should D. B. Johnson's "elementary circuits" algorithm produce distinct results?


Vote count:

0




Johnson's paper starts out describing distinct elementary circuits (simple cycles) in a directed graph:



A circuit is elementary if no vertex but the first and last appears twice. Two elementary circuits are distinct if one is not a cyclic permutation of the other. There are c distinct elementary circuits in G



I tried to cobble together something vaguely resembling the pseudo code, kind of badly cheating off of networkx and this Java implementation. I am apparently not getting distinct elementary circuits.


This is my code. It uses the goraph library, but doesn't really do too much with it, besides getting strongly connected components.



package main

import (
"fmt"
"http://github.com/gyuho/goraph/algorithm/scc/tarjan"
"http://github.com/gyuho/goraph/graph/gs"
)

func main() {

gr := gs.NewGraph()

a := gr.CreateAndAddToGraph("A")
b := gr.CreateAndAddToGraph("B")
c := gr.CreateAndAddToGraph("C")
d := gr.CreateAndAddToGraph("D")
e := gr.CreateAndAddToGraph("E")
f := gr.CreateAndAddToGraph("F")

gr.Connect(a, b, 20)
gr.Connect(b, c, 20)
gr.Connect(c, a, 20)

gr.Connect(d, e, 20)
gr.Connect(e, f, 20)
gr.Connect(f, d, 20)

sccs := tarjan.SCC(gr) // returns [][]string
for _, scc := range sccs {
if len(scc) < 3 {
continue
}
for _, v := range scc {
n := node(v)
circuit(n, n, gr)
}
}
fmt.Println(result)
}

type node string

var blocked = make(map[node]bool)
var B = make(map[node][]node)
var path []node
var result [][]node

func circuit(thisNode node, startNode node, g *gs.Graph) bool {
closed := false
path = append(path, thisNode)
blocked[thisNode] = true

adj := g.FindVertexByID(string(thisNode)).GetOutVertices().GetElements()
for _, next := range adj {
nextNode := node(next.(*gs.Vertex).ID)

if nextNode == startNode {
cycle := []node{}
cycle = append(cycle, path...)
cycle = append(cycle, startNode)
result = append(result, cycle)
closed = true
} else if !blocked[nextNode] {
if circuit(nextNode, startNode, g) {
closed = true
}
}
}

if closed {
unblock(thisNode)
} else {
adj = g.FindVertexByID(string(thisNode)).GetOutVertices().GetElements()
for _, next := range adj {
nextNode := node(next.(*gs.Vertex).ID)
inB := false
for _, v := range B[nextNode] {
if v == thisNode {
inB = true
}
}
if !inB {
B[nextNode] = append(B[nextNode], thisNode)
}
}
}
path = path[:len(path)-1]
return closed
}

func unblock(thisNode node) {
stack := []node{thisNode}
for len(stack) > 0 {
n := stack[len(stack)-1]
stack = stack[:len(stack)-1]
if blocked[n] {
blocked[n] = false
stack = append(stack, B[n]...)
B[n] = []node{}
}
}
}


This is the output:



[[C A B C] [B C A B] [A B C A] [F D E F] [E F D E] [D E F D]]


Graph theory is a spooky, dark forest full of magic for me, so I'm not sure what I'm missing. Am I misreading the paper? Is it implied that redundant permutations should be filtered out some other way? Did I screw up the code?



asked 1 min ago

Greg

3,254






Should D. B. Johnson's "elementary circuits" algorithm produce distinct results?

PL/SQL check if a row of table A exists in tables B or C


Vote count:

0




The following tables names are just an example...


Imagine that I have a table USER, a table SUB_USER_1 and a table SUB_USER_2. The tables SUB_USER_1(2) have a column ID and a column USER_ID, that connects them to the USERS table.


Now if I wanted to know if a user is of type 1 or 2, checking if it exists in table SUB_USER_1 or SUB_USER_2, what was the best way to do it?


Thanks in advance.



asked 1 min ago







PL/SQL check if a row of table A exists in tables B or C

PhantomJS strange behavior with table footer


Vote count:

0




I am using PhantomJS 1.9.7 to create PDFs from html. I have a problem with table footer ('tfoot' html teg). Rows in footer can desappeared or some times they can be splitting, it looks like: Footer in the end of pdf page


I expected to see table footer immedeatly after table on A4 page. What it can be ? Please help.



asked 42 secs ago







PhantomJS strange behavior with table footer

Could not open X display giggle: Cannot open display:


Vote count:

0




I'm completely new to Linux, I have installed in my computer (running on windows 7) a Virtual machine with Ubuntu desktop 14.04. I have installed some programs using "apt-get install NAME_OF_THE PROGRAM". The problem is that when I try to launch the GUI of these programs from a terminal, I'm always getting problems and I don't get to have the programs working. Now I have installed Giggle, the installation was ok but if I try to run "giggle" from the terminal I get:


** (giggle:8581): WARNING **: Could not open X display giggle: Cannot open display:


And this problem is for all the programs that I install.


For example if I try tu run xhost I get:


xhost: unable to open display "localhost:0"


What is the next step to fix these problems??


Any help or recommendation would be really appreciated.


Thanks!!



asked 54 secs ago







Could not open X display giggle: Cannot open display:

MATLAB Gauss-Seidel method - diverging solutions


Vote count:

0




I have to implement the Gauss-Seidel method into MATLAB, here is my code..



function [ x ] = gs( A, b, x0, k )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
n=length(A);
D = diag(diag(A));
L = tril(A-D);
U = triu(A-D);
B = L+D;
x=x0; %ADD COMMENTS!%

for j = 1:k;
for i = 1:n;
yk(i) = b(i) - U(i,1:n)*x;

%Now we solve B*x = yk by forward substitution%

x(i) = yk(i);
for m = 1:i-1
x(i) = x(i) - B(i,m)*x(m);
end
x(i) = x(i)/B(i,i);

end
end


A is an nxn matrix, b and nx1 vector, x0 is a starting 'guess' solution, and k is the number of iterations. If i set the number of iterations to k=1, i get a solution that is very close to the actual solution x = inv(A)*b. However, when i increase k, the solutions seem to just tend to infinity. The question also states that I am not allowed to calculated the inverse of (L+D) directly, so I have to use forward substitution to then find x.


I'm not too sure where my error lies, but i know that my algorithm should converge to x=inv(A)*b and I cannot see where the error is.



asked 32 secs ago







MATLAB Gauss-Seidel method - diverging solutions

Wordpress site not working after password change via phpMyAdmin


Vote count:

-2




I forgot my Wordpress site password,so I have changed it via PhpMyAdmin using MD5 encryption, after that on my first login attempt it gave me database error and since then site pages are not loading at all.



asked 52 secs ago







Wordpress site not working after password change via phpMyAdmin

XSL for-each to get contents of sibling element


Vote count:

0




I am learning XML and was going through some exercises I found online and am having difficulty with one small piece. I have the following XML that I want to use XSL to convert to into HTML. I am having trouble with the STAGEDIR element. It is a child element of SCENE and a sibling element to SPEECH and I would like it to appear in the HTML above the speaker's name and his or her line. What happens with the below code is that the same first contents of the STAGEDIR element is being repeated for each SPEECH element. Instead I want to return the contents of the preceding STAGEDIR element of its sibling SPEECH element.


Below is a snippet of the XML



<PLAY>
<TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
<FM>
<P>This work may be freely copied and distributed worldwide.</P>
</FM>
<ACT>
<TITLE>ACT I</TITLE>

<SCENE>
<TITLE>SCENE I. Elsinore. A platform before the castle.</TITLE>
<STAGEDIR>FRANCISCO at his post. Enter to him BERNARDO</STAGEDIR>

<SPEECH>
<SPEAKER>BERNARDO</SPEAKER>
<LINE>Who's there?</LINE>
</SPEECH>
<STAGEDIR>Enter HORATIO and MARCELLUS</STAGEDIR>

<SPEECH>
<SPEAKER>HORATIO</SPEAKER>
<LINE>Friends to this ground.</LINE>
</SPEECH>
</SCENE>
</ACT>
</PLAY>


Below is the XSL



<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

<xsl:template match="PLAY">
<html>
<head>
<!--Head title is the play title-->
<title><xsl:value-of select="TITLE" /></title>
</head>
<body>
<div class="act">
<xsl:for-each select="ACT">
<h2><xsl:value-of select="TITLE" /></h2>
<xsl:for-each select="SCENE">
<h3><xsl:value-of select="TITLE" /></h3>
<xsl:apply-templates select="SPEECH" />
</xsl:for-each>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>

<xsl:template match="SPEECH">
<xsl:for-each select=".">
<xsl:if test="../STAGEDIR"> <!--THIS IS WHERE THE PROBLEM OCCURS-->
<p><em><xsl:value-of select="../STAGEDIR" /></em></p>
</xsl:if>
<h4 style="color: red"><xsl:value-of select="SPEAKER" />:</h4>
<p><xsl:if test="STAGEDIR">
(<em><xsl:value-of select="STAGEDIR" /></em>)
</xsl:if>
<xsl:value-of select="LINE" /></p>
</xsl:for-each>
</xsl:template>


Below is a small subset of the HTML



<div class="act">

<h2>ACT I</h2>
<h3>SCENE I. Elsinore. A platform before the castle.</h3>
<p><em> FRANCISCO at his post. Enter to him BERNARDO</em></p>
<h4 style="color: red"> BERNARDO:</h4>
<p>Who's there? </p>
<p><em>FRANCISCO at his post. Enter to him BERNARDO </em></p>
</div>


As you can see <p><em>FRANCISCO at his post. Enter to him BERNARDO </em></p> is being repeated. In XSL, how can I loop through an element like I do in the XSL with the SPEECH element and return the contents of the preceding sibling element, in this case STAGEDIR.



asked 1 min ago

Kevin

422






XSL for-each to get contents of sibling element

libspotify failing to create playlists that can be loaded


Vote count:

0




I wrote a program using libspotify a year or two ago, it simply makes a playlist for me every night. It has been working great since I wrote it. About three days ago it stopped working. The playlists it creates always show in the UI (both my mobile and the desktop app) as 'Loading', but they never succeed in loading. Looking at the output from my program I see some channel errors, but can't find any info on what they mean to me or how to fix them:




Message: Logged in: 9:44 AM. Message: 17:44:19.533 E [c:/Users/spotify-buildagent/BuildAgent/work/1e0ce8a77adfb2dc/client/core/network/proxy_resolver_win32.cpp:215] WinHttpGetProxyForUrl failed


Message: 17:44:19.540 E [session:926] Not all tracks cached


Message: 17:44:19.621 I [ap:1752] Connecting to AP ap.gslb.spotify.com:4070


Message: 17:44:19.657 I [ap:1226] Connected to AP: 194.68.30.54:4070


Message: 17:44:20.595 E [ap:4172] ChannelError(5, 1, playlist)


Message: Playlist removed at index 1.


Message: 17:44:30.548 I [offline-mgr:2032] 0 files are locked. 0 images are locked


Message: 17:44:30.548 I [offline-mgr:2058] 0 files unlocked. 0 images unlocked


Message: 17:44:31.230 E [ap:4172] ChannelError(0, 1, playlist)


Message: 17:44:49.329 E [ap:4172] ChannelError(0, 1, playlist)


Message: Playlist added at index 1.


Message: 17:45:19.800 E [ap:4172] ChannelError(0, 1, playlist)


Message: 17:45:27.820 E [ap:4172] ChannelError(1, 1, playlist)


Message: 17:45:27.847 E [ap:4172] ChannelError(0, 1, playlist)


Message: 17:45:27.847 I [offline-mgr:2058] 0 files unlocked. 0 images unlocked


Message: Logged out: 9:45 AM.




The Message lines with no timestamps are from my program, the timestamped ones all come from libspotify.


I am using the latest libspotify version for Windows (12.1.51) and nothing has changed on my side in quite some time, it just stopped working.


Any help/ideas would be appreciated.



asked 43 secs ago







libspotify failing to create playlists that can be loaded

Check if number is divisible by 7 recurrence


Vote count:

0





static int Div(int[] array, int n)
{
if (n== 1)
{
return array[0];
}
return Div(array, n - 1);

}
static void Main(string[] args)
{
int[] array = new int[] { 3, 4, 8, 9,6};
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine(Div(array));
}`




asked 52 secs ago

iga

1






Check if number is divisible by 7 recurrence

Java code to capture each keyword in square bracket?


Vote count:

0




I am getting output of java code within brackets, i need to retrieve each keyword inside bracket?



This is output am getting now : [Eiwitten, 4,8, g]
from this i need to retrieve each keyword like : Eiwitten
4,8
g
So please me, how to code in java?

Thanks in advance!!


asked 33 secs ago







Java code to capture each keyword in square bracket?

Failed to install Cabal-1.20.0.2


Vote count:

0




I get this error when I'm trying to install Cabal-1.20.0.2:



$ cabal install Cabal-1.20.0.2.tar.gz
Resolving dependencies...
Configuring Cabal-1.20.0.2...
Failed to install Cabal-1.20.0.2
Last 10 lines of the build log ( /home/yonutix/.cabal/logs/Cabal-1.20.0.2.log ):
cabal: Error: some packages failed to install:
Cabal-1.20.0.2 failed during the configure step. The exception was:
user error (
/tmp/Cabal-1.20.0.2-11804/Cabal-1.20.0.2/Distribution/Simple/Utils.hs:386:31:
Warning:
In the use of ‘runGenProcess_’
(imported from System.Process.Internals):
Deprecated: "Please do not use this anymore, use the ordinary
'System.Process.createProcess'. If you need the SIGINT handling, use
delegate_ctlc = True (runGenProcess_ is now just an imperfectly emulated stub
that probably duplicates or overrides your own signal handling)."
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
)


I need to install this package because cabal-install depends on it.


What could be the problem? Thanks!



asked 13 secs ago







Failed to install Cabal-1.20.0.2

Far objects look bad


Vote count:

-1




I need some help with my basic game based on Wolfenstein 3D. Everything's all right, but I've got one question. Why my far objects look so bad? There're many shapes that aren't visible when I'm getting closer to them and fading color isn't fading well. Is there any fix, tip or trick to make it looks better? I don't want to show code to you, because it's huge and complicated.


Pictures: Further Closer


Thanks, jpowie01



asked 21 secs ago







Far objects look bad

Node Packages Manger(npm) error


Vote count:

0




**Hello, I have a problem with NPM. There is an error, could someone help me diagnose it? ** node-debug.log



asked 55 secs ago

Kot

1






Node Packages Manger(npm) error

SQL replace each occurrence of text with 1,2,3,4...etc


Vote count:

0




I have a text field in my database that is not displaying a numbered list correctly:



DECLARE @NOTE varchar(max) = 'This is a list: 1.Test1 1.Test2 1.Test3'


Each list item has a '1.' next to it but it really should be 1. 2. 3. like this:



'This is a list:

1. Test1
2. Test2
3. Test3'


Anyone think of a good way to correct the numbered list. I was thinking the STUFF and CHARINDEX Functions with a WHILE LOOP...?


I can get the position of the '1.' in the variable like so:



CHARINDEX('1.', @encounterNote)
CHARINDEX('1.',@encounterNote,CHARINDEX('1.', @encounterNote) + 1)
CHARINDEX('1.', @encounterNote,CHARINDEX('1.',@encounterNote,CHARINDEX('1.', @encounterNote) + 1))


not sure how I can replace the second and third 1. with 2. and 3 and so on.


Something I should also note would be that there might not be only 1,2,3 items in the list there could be lots more so I can't build it so its static and only handles 1,2,3 it should be able to wrok for any number of items in the list.



asked 43 secs ago

BS123

448






SQL replace each occurrence of text with 1,2,3,4...etc

Server client in c++


Vote count:

-1




I created an implementation of the tcpsocket in a class. but my code dosnt work and I dont know why. I'm not sure but I think it stops in the listen function. the code is long but pretty simple and basic so i hope you could help me.


Thank you!!!


main :http://hostcode.sourceforge.net/view/2677 tcpsocket : http://hostcode.sourceforge.net/view/2675 (there is a h file too)



asked 49 secs ago







Server client in c++

Foundation 5 Interchange html partial path


Vote count:

0




I'm trying to get Foundation 5's Interchange (with HTML partials) working but the partials are not loading in. Foundation5, jQuery and Interchange are located in


/bower_components/


index.html is located in


/src/


the small.html, medium.html and large.html partials are located in


/src/app/nav/




Here are the relevant files:


index.html included javascripts at bottom before </body>*



<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/jquery.cookie/jquery.cookie.js"></script>
<script src="bower_components/jquery-placeholder/jquery.placeholder.js"></script>
<script src="bower_components/foundation/js/foundation.js"></script>
<script src="bower_components/foundation/js/foundation/foundation.interchange.js"></script>
<!-- endbower -->
<!-- endbuild -->


interchange-test.html



<div data-interchange="[small.html, (small)], [medium.html, (medium)], [../large.html, (large)]">
<div data-alert class="alert-box secondary radius">
This is the default content.
</div>
</div>


app.scss



/* Define mobile styles */
@media only screen {
body {
background: red;
}
}

/* min-width 641px, medium screens */
@media only screen and (min-width: 40.063em) {
body {
background: orange;
}
}

/* min-width 1025px, large screens */
@media only screen and (min-width: 64.063em) {
body {
background: yellow;
}
}


Any ideas on what is wrong here? Thanks in advance.



asked 33 secs ago

s3z

1,365






Foundation 5 Interchange html partial path

Reduction from Subset Sum


Vote count:

0




trying to wrap my head around this one reduction problem.


Basically, given n amount of lists M, each consisting of {x1, x2...xn}{y1, y2...yn}, where each xi is linked with the corresponding yi, is there a list S = {(x1,y1),(x2,y2)....(xn,yn)} such that the sum of all x'es is atleast T, and the sum of all y at least W (or as large as possible?)


Basically you get to pick 1 tuple from each list and create a set of the same length as M, but with tuples instead of lists if you will. The y variables are tied to the corresponding x variables.


This problem is supposedly reducible from the known Subset-sum problem.


Do I need to combine two separate sub-set sum solutions in order to make this work? For example applying subset sum first to a subset S of x'es, checking that this subset is at least T, and then using this subset to check the corresponding y variables and verifying that their sum is at least W?


Any help would be greatly appreciated, will explain in more detail if asked.



asked 28 secs ago







Reduction from Subset Sum

Trying to make http client witch 'winhttp.h' in C++


Vote count:

0




I have a bit problem witch my code. I wanted to make a http client using winhttp.h. I checked it witch wireshark and it dont sent any post.. Can anybody help me? http://pastebin.com/0nATL59M



asked 41 secs ago







Trying to make http client witch 'winhttp.h' in C++

The Null Value -- different results in Sql syntaxes


Vote count:

0




I have 2 different queries (with different purposes) working perfectly but there is something I can not grasp yet about the Null value


Here is one query:



select NCLI , LOCALITE , CAT
from CLIENT
where CAT not in (’B1’,’C1’)
or LOCALITE not in (’Lille’,’Namur’);


It shows exactly what I want Including the rows where CAT has a null value. Now this seems perfectly logical to me.


The only thing that disturbs me is that the query below only worked when I specified I did wanted the null rows in CAT to show up


 select NCLI , LOCALITE , CAT from CLIENT where CAT <> ’C1’ or CAT is null or LOCALITE = ’Namur’;


When I don't add -- or CAT is null -- the null values don't show up. Could someone tell me what I'm not grasping here yet? Thanks.



asked 16 secs ago







The Null Value -- different results in Sql syntaxes

repalce just start of string in sql


Vote count:

0




i have 3 column in my table:



+-+-+-+-+-+-+-+-+-+-+-++
+ ID + Name + Cell +
++++++++++++++++++++++++
+ 1 + FB + /moon/ta +
+ 2 + GO + /ta/ta +
+ 3 + MO + /ta/mon +
+ 4 + SS + /ta +
+ 4 + SS + /ta/o/ta +
+-+-+-+-+-+-+-+-+-+-+-++


i want to replace all "/ta" with "/rr" in Cell Column that start of string, like:



+-+-+-+-+-+-+-+-+-+-+-++
+ ID + Name + Cell +
++++++++++++++++++++++++
+ 1 + FB + /moon/ta +
+ 2 + GO + /rr/ta +
+ 3 + MO + /rr/mon +
+ 4 + SS + /rr +
+ 4 + SS + /rr/o/ta +
+-+-+-+-+-+-+-+-+-+-+-++


do you any idea for it?



asked 21 secs ago







repalce just start of string in sql

sleekxmpp iq setting attrib to a result stanza


Vote count:

0




I want to answer a iq request with a 'result' iq. Everything's ok with iq.reply() and iq.send(), and i can build my answer with a iq.reply().setPayload(xxx).


But i also need to add some attribute to the result element of the iq.. And i couldn't find how to do this ?


I want to respond this :


<iq to='demo@im.demo.org/xxxx' id='9340:serviceTest' type='result' from='demo@im.demo.org/xanadu' xmlns='jabber:client'>

<result xmlns='urn:xmpp:test:0' ATTR1='150' ATTR2='temp'>

<payload>

xxxxxx ...


Payload is ok, but i can't create and set ATTR1 and ATTR2. (setattr, setitem, iq['result'] etc, don't work)


Thanks



asked 35 secs ago







sleekxmpp iq setting attrib to a result stanza

Edit pdf with Dynamic Controls


Vote count:

0




I am created a windows application where i created a toolbox contains tools like Button,label,textbox etc.My problem is that i have to show pdf file where i have to drag and drop these controls over pdf file so that these controls are fixed over pdf files.I don,t know which control is suitable for this problem so please suggest me the control to show pdf files with drag and drop functionality.


Thanks



asked 48 secs ago







Edit pdf with Dynamic Controls

How to update model using angularjs, Django,Django rest framework


Vote count:

0




I have such json representation of a post by its id:



{"title": "about me", "content": "I like program", "created": "2014-11-29T18:07:18.173Z", "rating": 1, "id": 1}


I try to update rating by button click:



<button ng-click="click(post.id)">Click me</button>


I have such javascript code:



<script>
var demoApp = angular.module('demoApp',['ngResource']);
demoApp.controller( 'AllPosts', function ($scope, $http)
{
$http.get('/blogpost/?format=json').success(function(data,status,headers,config)
{
$scope.posts = data.results;
$scope.predicate = '-title';

$scope.click = function(post_id, $resource){
var Post = $resource('/update/:PostId ',{PostId:post_id,salutation:'json'} );
post = Post.get({PostId:post_id}, function() {
post.rating = post.rating+ 1 ;
post.$save();
});
};

}).error(function(data,status,headers,config)
{} )
;})

</script>


Besides i have such view to have a json by certain post by its id:



class UpdateModel(generics.RetrieveUpdateDestroyAPIView):
lookup_field = 'id'
queryset = BlogPost.objects.all()
serializer_class = BlogPostSerializer
permission_classes = (AllowAny,)


asked 20 secs ago







How to update model using angularjs, Django,Django rest framework

Android: How to list mp3 albums


Vote count:

0




I want to try develop simple android music player. I have this method below to list album title, but it gives duplicate albums list.



public void getAlbumList() {
//query external audio
Activity a=getActivity();
ContentResolver musicResolver = a.getContentResolver();
Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
//String[] projection = null;

//String sortOrder = null;

String selectionMimeType = MediaStore.Files.FileColumns.MIME_TYPE + "=?";

String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension("mp3");

String[] selectionArgsMp3 = new String[]{ mimeType };
Cursor musicCursor = musicResolver.query(musicUri, null, selectionMimeType, selectionArgsMp3, null);
//iterate over results if valid

if(musicCursor!=null && musicCursor.moveToFirst()){
//get columns
int atitleColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.ALBUM);
int idColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.ALBUM_ID);
//int bitmap = musicCursor.getColumnIndex
// (android.provider.MediaStore.Audio.Albums.ALBUM_ART);
//add songs to list
while (musicCursor.moveToNext()){
long thisId = musicCursor.getLong(idColumn);
String thisaTitle = musicCursor.getString(atitleColumn);

albumList.add(new Album(thisId, thisaTitle));
}

}
}


I have tried this


but it doesn't work.



asked 35 secs ago







Android: How to list mp3 albums

C++11 How to store pointers-to-methods in std::unordered_map?


Vote count:

0




I want to store in std::unordered_map<object, std::vector<pointer>> pair of object and vector of pointers to methods of that object. object can refer to any class T and pointer must contain pointers to methods from T instance. I must be able to call those methods later. I tried to use boost::any, but I was not able to call methods later. How can I accomplish it?



asked 1 min ago







C++11 How to store pointers-to-methods in std::unordered_map?

how to print a tree in order by using stack and depth first search?


Vote count:

0





import java.util.LinkedList;
import java.util.Queue;

class Node {
public int iData; // data item (key)
public double dData; // data item
public Node leftChild; // this node's left child
public Node rightChild; // this node's right child
public int level;
public boolean flag;

public void displayNode() // display ourself
{
System.out.print('{');
System.out.print(level);
System.out.print(", ");
System.out.print(iData);
System.out.print(", ");
System.out.print(dData);
System.out.print("} ");
System.out.println(" ");
}
} // end class Node
// //////////////////////////////////////////////////////////////

class Tree {
private Node root; // first node of tree

// -------------------------------------------------------------
public Tree() // constructor
{
root = null;
} // no nodes in tree yet
// -------------------------------------------------------------

public void insert(int id, double dd) {
Node newNode = new Node(); // make new node
newNode.iData = id; // insert data
newNode.dData = dd;
if (root == null) // no node in root
root = newNode;
else // root occupied
{
Node current = root; // start at root
Node parent;
while (true) // (exits internally)
{
parent = current;
if (id < current.iData) // go left?
{
current = current.leftChild;
if (current == null) // if end of the line,
{ // insert on left
parent.leftChild = newNode;
return;
}
} // end if go left
else // or go right?
{
current = current.rightChild;
if (current == null) // if end of the line
{ // insert on right
parent.rightChild = newNode;
return;
}
} // end else go right
} // end while
} // end else not root
} // end insert()
// -------------------------------------------------------------

public void breadthFirstDisplay() {
Queue newQueue = new LinkedList();
int level = 0;
newQueue.add(root);
int temp = root.iData;
while (!newQueue.isEmpty()) {
Node theNode = (Node) newQueue.remove();
if (temp > theNode.iData)
level++;
theNode.level = level;
theNode.displayNode();
temp = theNode.iData;
if (theNode.leftChild != null) {
newQueue.add(theNode.leftChild);
}
if (theNode.rightChild != null) {
newQueue.add(theNode.rightChild);
}
}
}

public void depthFirstStackDisplay() {

}
// -------------------------------------------------------------
} // end class Tree
// //////////////////////////////////////////////////////////////

class TreeApp {
public static void main(String[] args){
Tree theTree = new Tree();

theTree.insert(5, 1.5);
theTree.insert(4, 1.2);
theTree.insert(6, 1.7);
theTree.insert(9, 1.5);
theTree.insert(1, 1.2);
theTree.insert(2, 1.7);
theTree.insert(3, 1.5);
theTree.insert(7, 1.2);
theTree.insert(8, 1.7);

theTree.breadthFirstDisplay();
theTree.depthFirstStackDisplay();

}// -------------------------------------------------------------
} // end class TreeApp
// //////////////////////////////////////////////////////////////


I want to write a function by depth first search so that the output is 1,2,3,4,5,6,7,8,9


Boolean flag is set in class Node and the i want that the function is similar to breadth first search.


I can't find relevant source to help me to complete it.



asked 38 secs ago







how to print a tree in order by using stack and depth first search?

Is there a way to interactively install suggested composer packages?


Vote count:

0




I would like to offer users of my composer package an interface to select and install any of the suggested packages. There seems to be no command line option, and in the API I can only find a getSuggests() method that lists the suggested packages.


Is there any way (native or with a third party installer), to give the user the choice to select suggested packages?



asked 52 secs ago







Is there a way to interactively install suggested composer packages?

How to make graphics created with CreateGraphics() always visible on control without flickering


Vote count:

0




I have custom control. I have OnPaint() event defined there. Let's say it's a text editing control. I want to display custom caret overlay. I created a Graphics object with CreateGraphics(). If on each blink timer tick I call the code which draws caret - it's visible. After some painting in OnPaint() my caret disappears. It can be redrawn, but when I tried to put DrawCaret() invocation at the end of main OnPaint() handler nothing happens. The caret is not drawn, or it's drawn and cleared.


Forcing DrawCaret() in various places in code causes ugly flickering at best, does nothing at worst. When I have DrawCaret() in blinkTimer_Tick() event handler - it's drawn, but it flickers irregularly.


And no, I don't want to use Win32 Caret - its color cannot be set. I need to draw my own caret and it has to blink.


If it has to blink, I assume I can't use control's OnPaint() event handler.



asked 21 secs ago

Harry

634






How to make graphics created with CreateGraphics() always visible on control without flickering

My Eclipse Just Display in Sdk 2.2 And Sdk 2.2 Above Blank Screen ...???


Vote count:

0




before I got missing emulator.exe in eclipse, I can display sdk 2.2 above after I download new sdk manager and I copy in my old sdk in eclipse it's fix but only display sdk 2.2, sdk 2.2 above got blank screen thank's



asked 32 secs ago







My Eclipse Just Display in Sdk 2.2 And Sdk 2.2 Above Blank Screen ...???

Solving the recurrence T(n) = T(n-1) + T(n-2) + 1


Vote count:

0




How will we solve this to the exact answer?


T(n) = T(n-1) + T(n-2) + 1


I know the answer is approx 2^(n/2) but how to get it exactly.



asked 1 min ago







Solving the recurrence T(n) = T(n-1) + T(n-2) + 1

Why can I not create a HashMap with 'long' types in Java?


Vote count:

0




Any reason that the following is not allowed?



HashMap<long, long> x = new HashMap<>();


asked 25 secs ago







Why can I not create a HashMap with 'long' types in Java?

Null when splitting a string


Vote count:

0




I need to create my own sort method for an array, and I begin my splitting the text file into an array filled with the words. The file format is: an integer n, followed by n words.


Here's an example: 4 hello hello world hello


However, my array prints: [null4, hello, hello, world, hello]


WHY! I don't understand why there is a null before. And, if I remove the number 4 (which plays no role in my program at the moment) I get: [nullhello, hello, world, hello]


Can you please help me remove this null? Thanks in advance!



public static void main(String[] args) throws FileNotFoundException {
filePath = "***TEXT FILE HERE***";

fileInput = new Scanner(new File(filePath));
convertFile(fileInput);
}

public static void convertFile(Scanner file) {

String line;

while (fileInput.hasNextLine()) {
line = fileInput.nextLine();
fileData = fileData + line;
}

String[] array = createArray(fileData);
System.out.println(Arrays.toString(array));
}

public static String[] createArray(String data) {
String[] dataArray = data.split("\\s+");

return dataArray;
}


asked 17 secs ago







Null when splitting a string