Posts

Showing posts from September 2, 2018

Android studio compiler errors

Image
Clash Royale CLAN TAG #URR8PPP Android studio compiler errors I've been following a tutorial on youtube, i dont seem to have any mistyped code but i've been having errors when running it. Here's the error that shows. org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:compileDebugJavaWithJavac'. at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139) at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100) at org.gradle.int

scene does not want to work in unity

Image
Clash Royale CLAN TAG #URR8PPP scene does not want to work in unity I keep having this problem with unity were the scene is not loading and all the elements side bar says (not loading) here is a picture: not loading picture my scene contains lots of things here is a list: 1.terrian 2.light 3.model table 4.fpscontraler 5.windzone 6.cube 7. four more cubes that are exactly the same with script that checked if they been clicked and change the scene when clicked. I'm loading it in the unity editor. Can you please give more information on what you are doing? What are you loading, exactly (what does the scene contain)? How are you loading it? – user650261 Aug 11 at 20:15 I feel like a idiot but I just fix the problem by switching the scene don't know what that did but it worked. 😁(: – Mikah Shattuck Aug 16 at 14:50 I'm glad that "it works" but does that meant he scene you wanted to load loads fine? – user650261 Aug 16 at 18:28 By clickin

Issue with Java GridBagConstraints

Image
Clash Royale CLAN TAG #URR8PPP Issue with Java GridBagConstraints For part of my personal project, I want to add a music player to my program. However when I try using the GridBagConstraintsLayout to make the 3 buttons (Play, Pause, and Stop) directly under the label, the layout just looks weird like the picture that I attached. I don't want to have the play button be really long. I want all 3 buttons to be equal length and directly under the label. Can someone help me with this and maybe post the code to help me? The picture to what I have now is attached and I also included some of my code. panel = new JPanel(new GridBagLayout()); add(panel); GridBagConstraints c = new GridBagConstraints(); label1 = new JLabel("This is the MaryLand State Song. After exiting, press enter"); c.gridx = 0; c.gridy = 0; panel.add(label1,c); play = new JButton("Play"); c.gridx = 0; c.gridy = 2; c.fill = GridBagConstraints.HORIZONTAL; panel.add(play,c); pause = new JBu

connecting mongodb model to apollo-server 2.0

Image
Clash Royale CLAN TAG #URR8PPP connecting mongodb model to apollo-server 2.0 I am following a tutorial which uses mongo database with graphql, currently the tutor uses apollo-server v1 but I am using apollo-server v2, the problem I'm having is where do i make the connection of my models to graphql, const express = require("express"); const mongoose = require("mongoose"); const bodyParser = require("body-parser"); const cors = require("cors"); require("dotenv").config( path: "variables.env" ); const Recipe = require("./models/Recipe"); const User = require("./models/User"); // Bring in GraphQL-Express middleware const graphiqlExpress, graphqlExpress = require("apollo-server-express"); const makeExecutableSchema = require("graphql-tools"); const typeDefs = require("./schema"); const resolvers = require("./resolvers"); // Create schema const schema = makeExecutable

How can I prevent a Shopify Polaris React app from connecting to Shopify service too soon?

Image
Clash Royale CLAN TAG #URR8PPP How can I prevent a Shopify Polaris React app from connecting to Shopify service too soon? I'm new to react and I'm trying to build a basic Shopify app using React and the Polaris React suite. TL:DR; How can I prevent a React component from rendering until data has been fetched asynchronously from the server? OR What is the correct method to get a Polaris app to connect to the shopify service? Full Explanation The problem is the render function should add the store domain to an attribute on the <AppProvider/> element. Ie. <AppProvider shopOrigin="https://user-store.myshopify.com"/> However, the domain differs depending on the store using the app. <AppProvider/> <AppProvider shopOrigin="https://user-store.myshopify.com"/> Given that React is rendered on the client side, I need to send a request to the server to retrieve the current store domain. But this happens after the app has rendered: rende

PHP can't find MySQL server in Docker

Image
Clash Royale CLAN TAG #URR8PPP PHP can't find MySQL server in Docker So I have a set of Docker services (running on Ubuntu) that are almost working at the moment: I have them set up in the docker-compose defined below, and the PHPMyAdmin is able to interface with the SQL server, but using the PHP connection script below, and calling db_connect() , gives the following error page: db_connect() Warning: mysqli::__construct():(HY000/2002): No such file or directory in /var/www/html/api/sql_db.php on line 12 MySQLi Connection failed: No such file or directory SESSION: Array ( [sql_server] => db [username] => root[password] => test [dbname] => bravo File containing db_connect() : db_connect() <?php session_start(); $servername = "db"; $username = "root"; $password = "test"; $dbname = "bravo"; $_SESSION['sql_server'] = $servername; $_SESSION['username'] = $username; $_SESSION['password'] = $password; $_SESS

How to create a StdClass with multiple similar elements

Image
Clash Royale CLAN TAG #URR8PPP How to create a StdClass with multiple similar elements I have this code generating a request passed to a SoapClient(). This is just a portion of a much larger request object. //OPTIONAL DAMAGE AND TRAVEL INSURANCE HANDLING if ( $fee_insurance != 0 || $fee_damage != 0 ) $tmp_node->UnitStays->UnitStay->UnitRates->UnitRate->Rates->Rate->AdditionalCharges = new StdClass(); //TRAVEL INSURANCE if ($fee_insurance != 0) $AdditionalChargeINS = array( 'Quantity' => '1', 'ChargeTemplateID' => $ChargeTemplateID_INS, 'Amount' => array( 'AmountBeforeTax' => $fee_insurance, 'Taxes' => array( 'Amount' => '0.00' ) ) ); //DAMAGE INSURANCE if ($fee_damage != 0) $AdditionalChargeDAM = array( 'Quantity' => '1', 'ChargeTemplateID' => $ChargeTemplateID_DAM, 'Amount' => array( 'AmountBeforeTax' => $fee_

Output features of a file based on its longest line

Image
Clash Royale CLAN TAG #URR8PPP Output features of a file based on its longest line I want to write a program file_stats.py that when run on the command line, accepts a text file name as an argument and outputs the number of characters, words, lines, and the length (in characters) of the longest line in the file. Does anyone know the proper syntax to do something like this if I want the output to look like this: Characters: 553 Words: 81 Lines: 21 Longest line: 38 Are you just looking for how to find the longest line, or all of those values? – The Tesseract's Shadow Aug 12 at 1:21 An explainer on how to find the values. – user10200421 Aug 12 at 1:34 2 Answers 2 Assuming your file path is a string, something like this should work file = "pathtofile.txt" with open(file, "r") as f: text = f.read() lines = text.split("n") longest_line = 0 for l in lines: if len(l) > longest_line: longest_line = len(l) print("Longest line:

How to implement Python functools.wraps equivalent in Go?

Image
Clash Royale CLAN TAG #URR8PPP How to implement Python functools.wraps equivalent in Go? I know I can wrap functions in Go through returning function, bug how to implement Python functools.wraps equivalent in Go? How to attach attribute to functions in Go? Like the code below in Python. from functools import wraps def d(f): def wrapper(*args): f(*args) return wrapper def d_wraps(f): @wraps(f) def wrapper(*args): f(*args) return wrapper @d def f(a=''): print a @d_wraps def g(a=''): print a if __name__ == '__main__': print 'function name: ', f.__name__ f('abc') print 'function name: ', g.__name__ g('abc') d does not change function name, d_wraps changes function name. The result is d d_wraps function name: wrapper abc function name: g abc I want to use the wrapped function as key at runtime. So I want to keep the function name unchanged after wrapped. How to implement the job that d_wraps does in Go? d_wraps 1

Make a function in javascript that returns the array and elements in reverse order

Image
Clash Royale CLAN TAG #URR8PPP Make a function in javascript that returns the array and elements in reverse order As I said in the title, I want to make a function that receives an array and return all the elements in reverse order. I studied a lit bit of javascript, but this is bugging me for some time. I made two functions to make it clear, as even my friends didn't understand the concept, the second is the one who is bugging me. const reverse = (pal) => var aux = ""; for(var i in pal) aux = pal[i] + aux; return aux; console.log(reverse("are")); //=> returns "era" This function above works fine and returns only one word, the next needs to return the array and all the words in reverse (just in case if someone didn't understand) const reverPal = (pal) => let aux = ""; let aux1 = ""; for (var i in pal) aux += pal[i] for (var i in aux.length) //I think the problem starts here aux.forEach((word) => wo

Summary data using csv file

Image
Clash Royale CLAN TAG #URR8PPP Summary data using csv file I would like to add more details in the desired output file. Is there please the option to improve the code below to get the desired file. code awk -F, 'a[$2$7]+=$4b[$2$7]+=$5c[$2$7]+=$6ENDfor(i in a)print i,a[i],b[i],c[i]' tmp3 | sort -t, -k1n | awk 'BEGIN print ("tCODE-1T COD-Area CODE-1 CODE-S CODE-T") printf ("t------------------------------------------------------------n") sum2 += $2; sum3 += $3; sum4 += $4; sum5 = sum2 + sum3 + sum4; printf ("t%9s%10s%12s%12d%16dn",substr($0,1,9),substr($0,10,5),$2,$3,$4) END { printf ("t------------------------------------------------------------------------n") printf ("tTotal:t%23dt%11dt%11dt%4dn",sum2,sum3,sum4,sum5) printf ("t------------------------------------------------------------------------n") input file 032118,333000004,3213,11,10,142,SS/RR 032118,333000004,3214,11,0,42,AS/RR 032118,333000004,3215,11,