Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-12-16T19:14:26Z
Updated: 10 hours 38 min ago

Pygame: Change in noise

Sat, 12/16/2017 - 19:13

I'm creating an experiment where the noise increases each trial. I've been using square with/without alias and sine noises that I create from audacity. Problem is that the noise gets louder but it also sounds like the pitch/frequency is changing. Sometimes it even gives off a whining sound. Any ideas why this might be happening?

Python increment float by smallest step possible predetermined by its number of decimals

Sat, 12/16/2017 - 19:13

I've been searching around for hours and I can't find a simple way of accomplishing the following.

Value 1 = 0.00531 Value 2 = 0.051959 Value 3 = 0.0067123

I want to increment each value by its smallest decimal point (however, the number must maintain the exact number of decimal points as it started with and the number of decimals varies with each value, hence my trouble).

Value 1 should be: 0.00532 Value 2 should be: 0.051960 Value 3 should be: 0.0067124

Does anyone know of a simple way of accomplishing the above in a function that can still handle any number of decimals?

Thanks.

Monster.recover()': cannot override inherited member 'entity.recovery()'

Sat, 12/16/2017 - 19:13

I need some help integrating my script to my mmorpg build. i only have 1 error, and its this one..

Monster.recover()': cannot override inherited member 'entity.recovery()' because it's not marked virtual, abstract or override. ?

Well there's the code:

public partial class Monster { // recover ///////////////////////////////////////////////////////////////// public override void Recover() { // base recovery base.Recover(); // additional buff recovery if (enabled && health > 0) { // health percent #if _SpellExtended float buffHealthPercent = (from skill in effects where skill.BuffTimeRemaining() > 0 select skill.buffsHealthPercentPerSecond).Sum(); health += Convert.ToInt32(buffHealthPercent * healthMax); // mana percent float buffManaPercent = (from skill in effects where skill.BuffTimeRemaining() > 0 select skill.buffsManaPercentPerSecond).Sum(); mana += Convert.ToInt32(buffManaPercent * manaMax); #else float buffHealthPercent = (from skill in skills where skill.BuffTimeRemaining() > 0 select skill.buffsHealthPercentPerSecond).Sum(); health += Convert.ToInt32(buffHealthPercent * healthMax); // mana percent float buffManaPercent = (from skill in skills where skill.BuffTimeRemaining() > 0 select skill.buffsManaPercentPerSecond).Sum(); mana += Convert.ToInt32(buffManaPercent * manaMax); #endif // addon system hooks Utils.InvokeMany(typeof(Monster), this, "Recover_"); } } } public partial struct Skill { public float MovementSpeedBonus { get { return template.levels[level - 1].movementSpeedBonus; } } public bool Snare { get { return template.levels[level - 1].snare; } } public bool Stun { get { return template.levels[level - 1].stun; } } public bool Fear { get { return template.levels[level - 1].fear; } } public bool Slience { get { return template.levels[level - 1].slience; } } public float AffectDistance { get { return template.levels[level - 1].affectDistance; } } public float ReflectRatePercent { get { return template.levels[level - 1].reflectRatePercent; } } public float LifeStealPercent { get { return template.levels[level - 1].lifeStealPercent; } } public float ManaStealPercent { get { return template.levels[level - 1].manaStealPercent; } } public float LifeGainPercent { get { return template.levels[level - 1].lifeGainPercent; } } public float ManaGainPercent { get { return template.levels[level - 1].manaGainPercent; } } public float LifeOnHit { get { return template.levels[level - 1].lifeOnHit; } } public float ManaOnHit { get { return template.levels[level - 1].manaOnHit; } } } public partial class SkillTemplate { public partial struct SkillLevel { [Header("CG Spell Extanded")] public float movementSpeedBonus; public bool snare; public bool stun; public bool fear; public bool slience; public float affectDistance; public float reflectRatePercent; public float lifeStealPercent; public float manaStealPercent; public float lifeGainPercent; public float manaGainPercent; public float lifeOnHit; public float manaOnHit; } } public partial struct Item { public float ReflectRatePercent { get { return template.reflectRatePercent; } } public float LifeStealPercent { get { return template.lifeStealPercent; } } public float ManaStealPercent { get { return template.manaStealPercent; } } public float LifeGainPercent { get { return template.lifeGainPercent; } } public float ManaGainPercent { get { return template.manaGainPercent; } } public float LifeOnHit { get { return template.lifeOnHit; } } public float ManaOnHit { get { return template.manaOnHit; } } void ToolTip_SpellExtended(StringBuilder tip) { tip.Replace("{REFLECTRATE}", ReflectRatePercent.ToString()); tip.Replace("{LIFESTEALRATE}", LifeStealPercent.ToString()); tip.Replace("{MANASTEALRATE}", ManaStealPercent.ToString()); tip.Replace("{LIFEGAINRATE}", LifeGainPercent.ToString()); tip.Replace("{MANAGAINRATE}", ManaGainPercent.ToString()); tip.Replace("{LIFEONHIT}", LifeOnHit.ToString()); tip.Replace("{MANAONHIT}", ManaOnHit.ToString()); } } public partial class ItemTemplate { [Header("CG Spell Extanded")] public float reflectRatePercent; public float lifeStealPercent; public float manaStealPercent; public float lifeGainPercent; public float manaGainPercent; public float lifeOnHit; public float manaOnHit; }

Would be great if someone could help me to get trought this, i know this is simple, but if i try to change the , override to virtual it gives me more errors...

[Angularjs]How to dynamic add a service to angular module?

Sat, 12/16/2017 - 19:13

I want to dynamically add some service to my Angularjs module. I wonder if there is any method to do so?

// Senarios config for dev let scenarioConfig1 = require(`./${env}/scenarios_config_files/scenario1.config`); let scenarioConfig2 = require(`./${env}/scenarios_config_files/scenario2.config`); let scenarioConfig3 = require(`./${env}/scenarios_config_files/scenario3.config`); let scenarioConfig4 = require(`./${env}/scenarios_config_files/scenario4.config`); let scenarioConfig5 = require(`./${env}/scenarios_config_files/scenario5.config`); let scenarioConfig6 = require(`./${env}/scenarios_config_files/scenario6.config`); //I wonder if there is any way, I can add these 6 service dynamically to my Angularjs //Module instead adding them one by one module.exports = angular.module('myApp', []) //scenarios config service for dev and prod .service('scenarioConfig1', [ scenarioConfig1]) .service('scenarioConfig2', [ scenarioConfig2]) .service('scenarioConfig3', [ scenarioConfig3]) .service('scenarioConfig4', [ scenarioConfig4]) .service('scenarioConfig5', [ scenarioConfig5]) .service('scenarioConfig6', [ scenarioConfig6]);

How to move files in a folder to a different folder in c++

Sat, 12/16/2017 - 19:12

I have a lot of .jpg images in my folder called "pics" and I want to copy all of these pictures and move them to my new folder I made called "PicsSelected".I have researched ways to do this and the easiest method to do this is by using the rename() function. For visual purposes, this is what I want to do (I'm working in Netbeans):

So far, this is what I have in my main method:

int main(int argc, char** argv) { string copyFrom = "C:\\Users\pwhit\OneDrive\Documents\NetBeansProjects\MoveFiles\pics"; string pasteTo = "C:\\Users\pwhit\OneDrive\Documents\NetBeansProjects\MoveFiles\PicsSelected"; rename(copyFrom.c_str(), pasteTo.c_str()); return 0; }

The project runs but when I check the 'PicsSelected' folder, it remains empty. Why are the contents of my 'pics' folder not being moved to the destination folder? Am I using the wrong syntax? Any help is much appreciated.

Java Random Password Generator?

Sat, 12/16/2017 - 19:12

How can I write a program like this in Java? The program that generates a random password and writes it to the screen according to how many characters the user will use in upper case, lower case, signs and numbers, how many characters to use and how long the total length will be

Execute Javascript Function Inside Specific Div

Sat, 12/16/2017 - 19:12

I'm trying to execute javascript function only in specific div, but I'm stuck, so if someone can help me, please. Thank you very much in advance

function dropsFall() { } .drop { display: block; min-height: 280px; overflow: hidden; } <div class="row"> <div class="col-xl drop"></div> </div>

Running multiple websites - docker compose

Sat, 12/16/2017 - 19:11

I have a docker-compose.yml file that looks something like this

version: "3.0" volumes: dbdata: .: services: api: build: context: ./api args: - APP_NAME=${APP_NAME} dockerfile: dockerfile depends_on: - database - webserver volumes: - ./api:/usr/local/share/${APP_NAME} database: image: mysql:5.7 volumes: - ./dbdata:/var/lib/mysql restart: always ports: - ${COMPOSE_DB_PORT}:3306 webserver: build: context: . dockerfile: webserver.dockerfile working_dir: "/usr/local/share/${APP_NAME}" volumes: - ./api:/usr/local/share/${APP_NAME} restart: always ports: - ${COMPOSE_APP_PORT}:80

It has 3 services. a website, a database and a web server which works as expected.

Now I have another separate web project which is a CMS that uses the same database as the API project and I want to add it to this docker compose file but I can't figure out how to configure the web server service to handle requests from said 2 web sites. Should I add another web server for the cms?

I searched on google but I couldn't find something clear and most results were using old docker-compose version which I'm not familiar with.

Thanks in advance.

Oracle endeca partial update changes not reflecting in endeca ref app

Sat, 12/16/2017 - 19:11

I am trying to implement oracle endeca partial update . My changes are visible in the forge output file which is placed in the dgraph_input/updates directory but the change is not reflecting in the endeca reference app.

Can anyone help me in this. I am using MDEX 6.2.2 . The Dgraph configuration is as follows :

<!-- ######################################################################## # Dgraphs # --> <dgraph id="Dgraph1" host-id="ITLHost" port="15000"> <properties> <property name="restartGroup" value="A" /> <property name="updateGroup" value="a" /> <property name="DgraphContentGroup" value="Test" /> </properties> <log-dir>./logs/dgraphs/Dgraph1</log-dir> <input-dir>./data/dgraphs/Dgraph1/dgraph_input</input-dir> <update-dir>./data/dgraphs/Dgraph1/dgraph_input/updates</update-dir> <args> <arg>--updatedir</arg> <arg>./data/dgraphs/Dgraph1/dgraph_input/updates</arg> </args> </dgraph>

Thanks in advance.

How do I implement something after a series of button clicks in a certain order and within a certain time period in Android studio if I had 2 buttons

Sat, 12/16/2017 - 19:08

If i had 2 buttons in android studio and if i wanted to implement something when the 2 buttons are pressed in a certain order and within a certain time period, how would the code be like. Supposing 2 buttons, button1 and button2 and if pressed in the order button1, button2, button2, button1 implements some activty. button1.onClick ----(within 1 second)---> button2.onClick ----(within 1 second)---> button2.onClick ----(within 1 second)---> button1.onClick -----> Then do some activity. I hope this explains what i'm trying to achieve. Any help is much appreciated. :)

Java cant get if statment to work in 2d array

Sat, 12/16/2017 - 19:06

I have a project where i have to use a 2d array to get the grades of 5 students. I have the grid layed out fine and i can get the highest average of all of them. but i cant seem to get the lowest average outputed correctly. it seems that in my if statment it goes through each column to see if its below 50. but i just want it to take the sum like i had before. thanks in advance

public static void main(String[] args) { grade = new String[5][6]; // Set the values for the first row and column //row 1 grade[0][0]="Students "; grade[0][1]="Grade 1 "; grade[0][2]="Grade 2 "; grade[0][3]="Grade 3 "; grade[0][4]="Grade 4 "; grade[0][5]="Grade 5 "; //Column 1 grade[0][0]="Students"; grade[1][0]="Ryan Miller"; grade[2][0]="Timothy LoPapa"; grade[3][0]="Hashim Razak"; grade[4][0]="Evan Vanderheide"; //call methods populateGradesArray(); displayGrades(); getAverage(); } //populate grades to the board start at row 1 and row 2 to stop the constants from being written over for(int row = 1; row< grade.length; row++){ for(int col=1; col<grade[row].length; col++){ int rand = rng.nextInt(90)+10 ; // have a inital grade of 0-90 then add 10 to avoid getting grades that are unlikely to below but still creating possiblity of high grades String randi = Integer.toString(rand); grade[row][col]=randi; } } } //Method to display grades to console public static void displayGrades(){ //print out grades to board for(int row =0; row< grade.length; row++){ for(int col=0; col<grade[row].length; col++){ grade[row][col] = grade[row][col]; if(col <1) System.out.printf("%-18s",grade[row][col]);// Have the first column have enoughspacing for large names else System.out.printf("%-10s",grade[row][col]); //keep everything after first column from having to large of a spacing } System.out.println(" "); } } public static void getAverage(){ int col = 0; double ave= 0; double ave2= 0; double ave3= 0; double ave4= 0; double badave4= 0; double highestAve =0; String studentName = null; for(int row=1; row<grade[col].length; row++){ // get the Double vaulue of each row ave+= Double.valueOf(grade[1][row])/5; ave2+= Double.valueOf(grade[2][row])/5; ave3+= Double.valueOf(grade[3][row])/5; ave4+= Double.valueOf(grade[4][row])/5; //Sort out the highest value of each row highestAve = Math.max( ave, Math.max( ave2, Math.max( ave3, ave4 ) ) ); // Assign names to each row average if(highestAve == ave) studentName = grade[1][0]; else if(highestAve == ave2) studentName = grade[2][0]; else if(highestAve == ave3) studentName = grade[3][0]; else if(highestAve == ave4) studentName = grade[4][0]; if(ave < 50) System.out.printf("%n%s is struggling with an average of %.2f",grade[1][0], ave); else break; if(ave2 < 50) System.out.printf("%n%s is struggling with an average of %.2f",grade[2][0], ave2); else break; if(ave3 < 50) System.out.printf("%n%s is struggling with an average of %.2f",grade[3][0], ave3); else break; if(ave4 < 50) System.out.printf("%n%s is struggling with an average of %.2f",grade[4][0], ave4); else break; } System.out.printf("%nThe student with the highest Average of %.2f is %s", highestAve, studentName); } }

PHP tag within a form opening tag getting error

Sat, 12/16/2017 - 19:05

When I'm putting some code within a html a form tag it's not working as it should be.

<form action = "update.php?id= <?php echo $id; ?>" method="post">

The form open tag above is taking the php closing tag as it's closing tag. Why is this happening? It should take the last closing tag as it's closing tag.

get number into string with javascript/regex

Sat, 12/16/2017 - 19:00
  • MyString1 = "big BANANA: 5 , small Apples_juice 1,5_, oranges* juice 20 "
  • MyString2 = "big bananas : 5 , small apple_juice_3.5_, oranges juice 20 "

I'd like to get the number of apples 1,5 for MyString1 and 3.5 for MyString2

The code I've tried:

function getValue(string, word) { var index = string.toLowerCase().indexOf(word.toLowerCase()), part = string.slice(index + word.length, string.indexOf(',', index)); return index === -1 ? 'no ' + word + ' found!' // or throw an exception : part.replace(/[^0-9$.,]/g, ''); }

Set the Android notifications from Specific date and time like fire date int IOS

Sat, 12/16/2017 - 18:59

I've game in Unity 3D.

I have successfully coded the IOS Notifications, my notifications is in specific DateTime like this :

var notif = new UnityEngine.iOSLocalNotification(); notif.alertBody = body; notif.applicationIconBadgeNumber = 1; notif.repeatInterval = repeatInterval; notif.soundName = LocalNotification.defaultSoundName; notif.fireDate = FireDate; NotificationServices.ScheduleLocalNotification(notif);

Now I have downloaded plugin for android notifications and I didn't not found a method to schedule the notifications with DateTime because I have input in my app the user will select the time to receive the notifications.

I have only tow values to set in this case Delay,Interval from DateTime but how?

In my app I have 5 different notifications every one have DateTime to push it and repeats every week.

I hope find a solution.

How to override a virtual base class property with a derived class property

Sat, 12/16/2017 - 18:46

I can't use override since the types don't match and I've read I shouldn't use new to hide it, so how would I accomplish this?

SearchBase and ResultBase will work for 80% of my entities but a few will need specific implementations.

This main problem I see is when I do use new it's all typed during compile time and looks good in the debugger but passing this object to System.Web.Mvc.Controller.Json() seems to have a problem serializing it and they come out null.

public class SearchBase<T> { public virtual ResultBase result { get; set; } } public class SearchImp : SearchBase<SearchImp> { public override ResultImp result { get; set; } } public class ResultBase { } public class ResultImp : ResultBase { }

having an issue with my bash script

Sat, 12/16/2017 - 18:42

im writing a script that allows the user to create a backup of a file they choose by allowing them to input the file name. the file will then have backup followed by being date stamped at the end of it's name and saved on the home drive. but whenever i try to run it i get an error: cp: missing destination file operand after '_backup_2017_12_16'

here's my code:

title="my script 3" prompt="Enter:" options=("create a backup of a file") echo "$title" PS3="$prompt " select opt in "${options[@]}" "Quit"; do case "$REPLY" in esac cp "$filename""${file}_backup_$(date +%Y_%m_%d)" done

Is there a way to delete similar words from array's elements?

Sat, 12/16/2017 - 18:38

Is there a way to delete similar words from array's elements?

Initial array:

var arr = ["element first", "element second", "element third"];

Desired result:

var result = ["fisrt", "second", "third"];

Thanks!

List or Arraylist

Sat, 12/16/2017 - 18:35

How to write an arraylist containing

ticket no.:______ movie name:___ seatno:________ showtimes:____

and generate these as arraylist

How to use addValueEventListener in a first time for Android

Sat, 12/16/2017 - 18:22

It's very confusing Firebase Database api for android. I would like to update some part of json objects, but I can't. This is firebase database.

First of all the user create vocabulary, following this code

/* reference of /vocabulary/{user_id}/*/ final DatabaseReference vocabularyRef = FBDatabaseReference.getAllVocabulary(user); if (!TextUtils.isEmpty(oldName)){ // if vocabulary renamed remove preview vocabularyRef.child(oldName).removeValue(); } // set user vocabulary vocabularyRef.child(String.valueOf(userVocabulary.name())). setValue(new FBVocabulary(userVocabulary), completionListener);

If vocabulary had created successfully user can add words into them. But after adding words, user can modify vocabulary name or color etc.. In that time I lose all words, because the vocabulary object has recreate.

According of Firebase doc for updating a child I should addListenerForSingleValueEvent or addValueEventListener When I use addListenerForSingleValueEvent instead of previews code, User can not create vocabulary.

Each time called onCancelled(DatabaseError databaseError) with exception: Permission denied. As far as I understand is is because the reference is null.

1. Can I check if reference exist or not ? then update data.

2. How can I use addValueEventListener in a first time ?

Trying to save notes for each day of a calendar year android studio

Sat, 12/16/2017 - 18:13

I don't get any errors but this doesn't work every time I try to change date in the calendar my app stops working and even when I press the save button it also keeps stop working before I add the code with the array it was working properly

public class Calendar extends AppCompatActivity {

private CalendarView calendarView; private TextView currentDate; private Button btnsavenote; private EditText newNote, showNote; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calendar); calendarView = (CalendarView) findViewById(R.id.calen_v); currentDate = (TextView) findViewById(R.id.currentDate); btnsavenote = (Button) findViewById(R.id.save_note); newNote = (EditText) findViewById(R.id.newNote); showNote = (EditText) findViewById(R.id.shownote); final String [][] array = new String[31][12]; calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() { @Override public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) { String tDate = (dayOfMonth) + "/" + month + "/" + year; currentDate.setText(tDate); } }); btnsavenote.setOnClickListener(new View.OnClickListener() { String MytextMessage = newNote.getText().toString(); @Override public void onClick(View v) { int a; int b; a = Integer.parseInt(array [30][2]); b = Integer.parseInt(array [31][2]); array[a][b] = MytextMessage; } }); }

}

Pages