Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2018-02-21T10:21:19Z
Updated: 4 hours 27 min ago

SKScene superclass doesn't have a didMove method

Mon, 02/19/2018 - 22:13

Finally cracked open SpriteKit and Swift, but have fallen at first hurdle.

The Xcode linter/compiler is telling me that I'm trying to override a superclass method that doesn't exist. It's protesting that SkScene does not have a didMove() method, even though the documentation seems to say otherwise.

Tried researching but I'm guessing it's a pretty popular error message that's easily resolved with a bit of research on the class hierarchies. I've not seen anything involving this specific context, though.

I'm using Xcode 7.3 and I initiated the boilerplate code by choosing 'Game' in the new project wizard.

MATLAB showing values to create a graph

Mon, 02/19/2018 - 22:13

I am trying to create a graph with mantissa m with 4 possible value, exponent range -2 to 3 and base 2. I have problem with how to show it in matlab. The y value is given. just need to work on x1 to do it.

Migration from Adwords PHP Sdk 19 to 32 - How to dynamically call services

Mon, 02/19/2018 - 22:13

I am facing the challenge to migrate a whole application based on the now outdated Adwords PHP Sdk 19 to the new 32 version.

One of the cores of my application is that I dynamically call the Adwords services as they are needed.

$customerService = $adwordsClient->GetService($nameOfTheService);

that would translate to, for ex:

$customerService = $this->GetService('CustomerService');

This also gave me the convenience of not needing to import all the classes on my code. But with the new SDK, it works like this:

$customerService = $this->adWordsServices->get($this->adWordsSession, CustomerService::class);

So it is not possible to write

$nameOfTheService::class

Because dynamic class names are not allowed in compile-time in php. Also, PHP will force me to import before hand every class that will be invoked like this.

Any ideas on how to make this work in an elegant and efficient way?

docker-compose cannot start service: "exec: \"python3\": executable file not found

Mon, 02/19/2018 - 22:13

(I'm not deeply experienced with docker, fwiw)

I have a django appication I'm containerizing. Currently when I run docker-compose up the redis service starts up, but apiexits with error: ERROR: for api Cannot start service api: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"python3\": executable file not found in $PATH": unknown

#docker-compose.yaml version: '3' services: redis: image: redis ports: - 6379 api: build: context: ../backend/ dockerfile: ../backend/Dockerfile env_file: .env volumes: - ../backend:/code/ ports: - "8001:8001" depends_on: - redis

with

#../backend/Dockerfile FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code ADD . /code/ WORKDIR /code/ RUN pip install -r requirements.txt CMD python manage.py runserver

and

#./.env DJANGO_SETTINGS_MODULE=backend.settings.dev DJANGO_SECRET_KEY=<redacted> SENTRY_URL=<redacted>

I've also, based on other issues, tried using both CMD and RUN with their differing argument types, i.e. in the existing shell and without, but the output hasn't changed.

I should also acknowledge that it's possible I'm not restarting actually catching the updates to docker-compose.yaml or Dockerfile. My workflow has been $ docker-compose down followed by $ docker-compose up.

MySQL - expanding a date range into individual dates

Mon, 02/19/2018 - 22:13

I have a table with a start date and repeat counts (simplified):

CREATE TABLE tblSchedule ( schedStart timestamp, schedRepeatMonth tinyint, schedRepeatDays tinyint, schedOpen bit );

So, in a simplifed example, "open every Tuesday" would have a start date on a Tuesday and repeat every 7 days. The third Friday would start on a Friday and repeat once a month and 21 days. Closed on Christmas would have a date of Dec. 25th, no repeats, closed.

There are two types of queries it has to handle - "are we open on this date" and "how many times are we open between these dates". If the table were populated without repeats, these would be totally mundane queries and what I would like to do is create a select that produces rows as if they had been entered long-hand without repeats ie:

SELECT * from ( SELECT schedStart, schedEnd from tblSchedule where schedStart between ('2001-01-01', '2001-12-31') and *expand_ranges_into_non_repeating_rows_here*) )

The trouble is that SQL is about filtering information out, not expanding it so creating several rows from a single one is not exactly normal. I could use a while loop to create a temporary table but this is the schedule for multiple items across the entire system so it's going to be commonly run a lot, albeit with some date ranges being more common than others.

Any ideas? Bonus if we can keep the solution as standard-sql as possible.

Cannot satisfy the following dependencies for packagegroup-core-boot

Mon, 02/19/2018 - 22:12

I'm trying to add a custom kernel module (comedi) to my Yocto image. I've added this bitbake recipe:

SUMMARY = "Comedi is a collection of drivers for a variety of common data acquisition plug-in boards. The drivers are implemented as a core Linux kernel module providing common functionality and individual low-level driver modules." LICENSE = "GPLv2" HOMEPAGE = "http://www.comedi.org" LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833" PR = "r1" SRC_URI = "git://github.com/Linux-Comedi/comedi.git;protocol=git" SRCREV = "af69459809c295699593604ef95b215189b3623f" S = "${WORKDIR}/git" inherit module # The Linux kernel needs to be built before comedi DEPENDS = "linux-yocto-rt" do_configure() { cd ${WORKDIR}/git/ ./autogen.sh echo "" ./configure --target=${TARGET_SYS} --host=${HOST_SYS} --with-machine=${TARGET_ARCH} --with-linuxdir=${STAGING_KERNEL_BUILDDIR} --with-linuxsrcdir=${STAGING_KERNEL_DIR} } EXTRA_OEMAKE = "-C ${S}" do_install() { install -m 0755 -d ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/extra install -m 0755 -d ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/extra/comedi install -p -m 644 ${S}/comedi/comedi.ko ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/extra } FILES_${PN} = "${nonarch_base_libdir}/modules" FILES_${PN} += "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/extra/comedi/*"

Comedi has a lot of kernel drivers, but I'm just trying to resolve this error for one. The kernel object is being build fine. However I get the following error during do_rootfs step:

Collected errors: * calculate_dependencies_for: Cannot satisfy the following dependencies for packagegroup-core-boot: * kernel-module-comedi * * opkg_solver_install: Cannot install package packagegroup-core-boot. guring kernel-module-xt-hashlimit.

What is the way to resolve it?

How does linked list works ? And how to remove first element

Mon, 02/19/2018 - 22:05

hello my remove method is confusing me, I have no idea how it actually works

public void remove(int n) { Pokeball current = this; while (n > 2) { current = current.next; n = n - 1; } current.next = current.next.next; } }

My list looks like this :

Bulbasaur -> Squirtle -> Charmander -> awawawa

If I go step by step through my remove method :

current is : Bulbasaur

Then we enter the loop :

n : 4

current = current.next so current is now Squirtle

n : 3

current = current.next so current is now Charmander

Exit the loop then current.next = current.next.next;

current.next(awawawa) = null

Up to here, I know why when displaying, awawa is not there anymore but

I don't know how Bulbisaur remain unmodified since current was referring to Bulbisaur and throught the loop we've been modifying it to something else

shouldn't my list looks like this ? :

Charmander Squirt Charmander awawawa ??

and another problem is, when I try to remove index(0) it removes my last index (awawawa)

public class test { public static void main(String[] args) { Pokemon p1 = new Pokemon("Bulbasaur", "grass"); Pokemon p2 = new Pokemon("Squirtle", "water"); Pokemon p3 = new Pokemon("Charmander", "fire"); Pokemon p4 = new Pokemon("awawawa", "fire"); Trainer d1 = new Trainer("Pierre"); d1.addPokemon(p1); d1.addPokemon(p2); d1.addPokemon(p3); d1.addPokemon(p4); d1.display(); //Pierre : Bulbasaur Squirtle Charmander awawawa d1.remove(1); //Pierre : Bulbasaur Charmander awawawa System.out.println(); d1.display(); d1.remove(0); System.out.println(); d1.display(); //Pierre : Bulbasaur awawawa } } public class Pokemon { private String name; private String type; private int niveau; public Pokemon(String name, String type) { this.name = name; this.type = type; this.niveau = (int) (Math.random() * (1 * 1 - 100) + 100); } public void display() { System.out.print(this.name); } } public class Trainer { public final String name; private Pokeball premiere; public Trainer(String name) { this.name = name; } public void display() { System.out.print(this.name + " : "); this.premiere.display(); } public void addPokemon(Pokemon pok) { if (this.premiere != null) { this.premiere.addPokemon(pok); } else { this.premiere = new Pokeball(pok); } } public void remove(int n) { this.premiere.remove(n); } } public class Pokeball { private Pokemon pok; private Pokeball next; public Pokeball(Pokemon pok) { this.pok = pok; } public Pokeball(Pokemon pok, Pokeball next) { this.pok = pok; this.next = next; } public void display() { Pokeball current = this; while (current != null) { current.pok.display(); System.out.print(" "); current = current.next; } } public void addPokemon(Pokemon pok) { Pokeball current = this; while (current.next != null) { current = current.next; } current.next = new Pokeball(pok); } public void remove(int n) { Pokeball current = this; while (n > 2) { current = current.next; n = n - 1; } current.next = current.next.next; } }

Python - regex - how to find ONLY four letter words?

Mon, 02/19/2018 - 22:04

I am working with a string of text that I want to search through and only find 4 letters words. It works, except it also finds 4+ letter words as well.

import re test ="hello, how are you doing tonight?" total = len(re.findall(r'[a-zA-Z]{3}', text)) print (total)

It finds 15, although I am not sure how it found that many. I thought I might have to use \b to pick the beginning and the end of the word, but that didn't seem to work for me.

pandas rolling window: variable length from start to x

Mon, 02/19/2018 - 22:04

For a pandas.DataFrame.rolling window I can set a window size that describes a fixed width (fixed number of elements or fixed offset).

How can I get a window that always begins at the first entry and rolls forward to each entry? For example having a series x in the DataFrame, I want to get the following windows per row:

x intended_window 0 10 [10] 1 11 [10,11] 2 12 [10,11,12] 3 13 [10,11,12,13] 4 14 [10,11,12,13,14]

How to map yaml keys to structs in golang?

Mon, 02/19/2018 - 22:04

I'm looking to write a go script that can parse through a yaml file. I created a test yaml file with the following:

Dog: - name: "Dog" - secrets: username: "Shiba" password: "inu" color: "yellow" Cat: - name: "Cat" - secrets: words: "meow" color: "black"

What would the mapping to a struct look like in go?

I've tried along the lines of:

package main import ( "fmt" "log" "github.com/spf13/viper" ) type Animal struct { Animal []string Name string Secrets []map[string]string } func main() { viper.SetConfigName("demo") viper.AddConfigPath(".") viper.SetConfigType("yaml") err := viper.ReadInConfig() if err != nil { log.Fatal(err) } var animal Animal err = viper.Unmarshal(&animal) if err != nil { log.Fatal(err) } fmt.Println(animal.Name) }

But nothing is returned

Any help would be much appreciated

Thanks

How to make the content1/2 divs resizable?

Mon, 02/19/2018 - 22:02

I have the following layout:

I want to make it so that the user can put their cursor in the middle of content1 and content2 and be able to drag it left and right to resize it (making content1 bigger/content2 smaller. Is there a way to do this with my current code?

CSS

body{ height: 100%; width: 100%; } .main-wrapper{ background-color: #f5f5f5; height: 100%; left: 0; padding-bottom: 50px; padding-top: 50px; position: fixed; top: 0; width: 100%; } @media (max-width: 991px){ .main-wrapper{ overflow-x: hidden; overflow-y: auto; } } .header-wrapper{ background-color: #009688; color: white; height: 50px; width: 100%; } .footer-wrapper{ background-color: #121212; color: white; height: 50px; width: 100%; } .body-wrapper{ background-color: #f0f0f0; width: 100%; } .content-1{ background-color: #2DC050; color: white; padding: 30px; width: 100%; } .content-2{ background-color: #1FA325; color: white; padding: 30px; width: 100%; } @media (min-width: 992px){ .content-1, .content-2{ overflow-x: hidden; overflow-y: auto; } }

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" /> <div class="main-wrapper d-flex flex-row"> <div class="header-wrapper fixed-top d-flex flex-row align-items-center justify-content-center"> I'm fixed header. I will be alwase visible on top. I'm fixed height. </div> <div class="body-wrapper d-flex flex-row flex-wrap"> <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0"> <div class="content-1 d-flex flex-column text-center"> <h1>I'm content One. My position is left. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> </div> </div> <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0"> <div class="content-2 d-flex flex-column"> <h1>I'm content Two. My position is right. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> </div> </div> </div> <div class="footer-wrapper fixed-bottom d-flex flex-row align-items-center justify-content-center"> I'm fixed footer. I will be alwase visible on bottom. I'm fixed height. </div> </div> Run code snippetExpand snippet Header and Footer always fixed. Content 1 and Content 2 will be scroll-able if browser min-width is 992px. Entire page will be scroll-able if browser max-width is 991px. Edit for Ronaldo comments. Answer is yes it's possible. Check the bottom snippet. body{ height: 100%; width: 100%; } .main-wrapper{ background-color: #f5f5f5; height: 100%; left: 0; padding-bottom: 50px; padding-top: 50px; position: fixed; top: 0; width: 100%; } .header-wrapper{ background-color: #009688; color: white; height: 50px; width: 100%; } .footer-wrapper{ background-color: #121212; color: white; height: 50px; width: 100%; } .body-wrapper{ background-color: #f0f0f0; width: 100%; } @media (max-width: 991px){ .body-wrapper{ overflow-x: hidden; overflow-y: auto; } } .content-1{ background-color: #2DC050; color: white; padding: 30px; width: 100%; } .content-2{ background-color: #1FA325; color: white; min-height: 700px; padding: 30px; width: 100%; } @media (min-width: 992px){ .content-1{ overflow-x: hidden; overflow-y: auto; } } .content-2-1{ background-color: #0D420F; padding: 20px; width: 100%; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" /> <div class="main-wrapper d-flex flex-row"> <div class="header-wrapper fixed-top d-flex flex-row align-items-center justify-content-center"> I'm fixed header. I will be alwase visible on top. I'm fixed height. </div> <div class="body-wrapper d-flex flex-row flex-wrap"> <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0"> <div class="content-1 d-flex flex-column text-center"> <h1>I'm content One. My position is left. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> </div> </div> <div class="col-12 col-lg-6 d-flex flex-row pl-0 pr-0"> <div class="content-2 d-flex flex-column"> <h1>I'm content Two. My position is right. I'm alwase fit with any browser window except header and footer height. Also I'm scrollable if content isn't fit.</h1> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> </div> </div> </div> <div class="footer-wrapper fixed-bottom d-flex flex-row align-items-center justify-content-center"> I'm fixed footer. I will be alwase visible on bottom. I'm fixed height. </div> </div>

removing extra caracter from a string

Mon, 02/19/2018 - 22:02

Hello guys i am having issue using a token , since on my Api i get a token like this "A58986587" , so in my Ajax call the url look like that and it not working

http://localhost/api/summary?csrf="A58986587"

it need to be like this one : http://localhost/api/summary?csrf=A58986587 without double quote on the tokken

i am trying to find a work around unfortunately i wasn't able

If / Else statement using Get-WMIObject

Mon, 02/19/2018 - 21:57

I am new to PowerShell and I cannot for the life of me figure out why the script below is not working properly. I have very similar scripts but they are not calling any WMIObjects As soon as I attempt to “Get-WMIObject” I have run into problems.

If I run the script it outputs in a red text, not green as it should based on the if/else statement. Furthermore, after the script has run if I type $PredictFailure it shows that $PredictFailure is in fact “False”. Have included a screenshot below to show you what is going on.

Thanks in advance for any and all suggestions

$PredictFailure = Get-WmiObject -namespace root\wmi –class MSStorageDriver_FailurePredictStatus | Select-Object PredictFailure

Foreach ($D in $PredictFailure)

{

$PredictFailure = $D.PredictFailure

If ($D.PredictFailure -eq "False") {Get-WmiObject -namespace root\wmi –class MSStorageDriver_FailurePredictStatus -ComputerName $env:computername | Select-Object PSComputerName, Active, PredictFailure, Reason | Format-Table -AutoSize | Out-String | Write-Host -ForegroundColor Green}

Else

{Get-WmiObject -namespace root\wmi –class MSStorageDriver_FailurePredictStatus -ComputerName $env:computername | Select-Object PSComputerName, Active, PredictFailure, Reason | Format-Table -AutoSize | Out-String | Write-Host -ForegroundColor Red}

} enter image description here

Utilizing local variables of a function and setTimeout

Mon, 02/19/2018 - 21:50

I have hit a snag in a website I am building. I have a function which adds a specific class to different ids. The end result is to have images fade out one at a time on the home page. I used the local variable a so that I can easily code the different id's without having to write 3 separate functions. However I am having trouble using setTimeout. I cannot seem to get setTimeout to work at all. Any help would be greatly appreciated. The classes get added to the ids with no problem, I am just having trouble with the setTimeout function. I've used multiple methods I've seen on here but I don't really understand them. Any help would be greatly appreciated. Here is my code:

window.onload; var fetchOne =document.getElementById('picOne'); console.log(fetchOne); var fetchTwo =document.getElementById('picTwo'); var fetchThree =document.getElementById('picThree'); function AttachClass (a){ a.className ='opacity'; } setTimeout(AttachClass.bind(null,a),8000); AttachClass (fetchOne); AttachClass (fetchTwo); AttachClass (fetchThree); #picOne{ opacity: 1; transition: opacity 2s ease-in-out } #picOne.opacity{ opacity: 0; } #picTwo{ opacity: 1; z-index: -1; transition: opacity 2s ease-in-out } #picTwo.opacity{ opacity: 0; } #picThree{ opacity: 1; z-index: -2; transition: opacity 2s ease-in-out } #picThree.opacity{ opacity: 0; } <div class="landscape_pics"> <img id="picOne" src="media/Photographs/BK3U8791.JPG"> <img id="picTwo" src="media/Photographs/2014Feb%20-%20Vacation%20-%20Sao%20Paulo%20-%200071a.jpg"> <img id="picThree" src="media/Photographs/2014Aug06%20-%20Stadium%20-%20001.JPG"> </div>

editable div dont duplicate emoji image (or code) in input

Mon, 02/19/2018 - 21:50

I'm creating an EmojiPicker for my website, but I'm having problems with passing the editable div data to an input to validate it later in a form.

<div class='emoji_picker'> <input type=image value='--1--' src='emojis/1.png' class=emoticon /> <input type=image value='--2--' src='emojis/2.png' class=emoticon /> <input type=image value='--3--' src='emojis/3.png' class=emoticon /> <input type=image value='--4--' src='emojis/4.png' class=emoticon /> <input type=image value='--5--' src='emojis/5.png' class=emoticon /> </div> <div contentEditable="true" id='myPost'></div> <input type=text id=copytoInput >

I'm using the next Jquery codes

1) this is to paste an emoji into the div

$(".emoticon").click(function(){ var div_val = jQuery.trim($("#myPost").html()); var emoticon_val = $(this).attr("value"); if(emoticon_val=="--1--"){emoticon_val="<img src='emojis/1.png' />";} if(emoticon_val=="--2--"){emoticon_val="<img src='emojis/2.png' />";} if(emoticon_val=="--3--"){emoticon_val="<img src='emojis/3.png' />";} if(emoticon_val=="--4--"){emoticon_val="<img src='emojis/4.png' />";} if(emoticon_val=="--5--"){emoticon_val="<img src='emojis/5.png' />";} //show in div $("#myPost").focus().html(div_val + '&nbsp;' + emoticon_val + '&nbsp;'); });

2) this is for copying from the div to the input

$('#myPost').keyup(function() { $('#copytoInput').val($(this).text()); });

the problem is that the emojis pastes in the div but not in the input, because I'm using keyUp and the code doent recognize it the paste, so I have no way to save them (or a textual code of them) in my database.

For example if an user writes: " Hi everyone --1--, how is everythin going" I would like it to be duplicated like that in the input so that once Its retrieved from the database, the --1-- be replaced by a happy fac image. But while the user is writing the post the --1-- code be shown as the happy face for a best user experience.

Find pairs in two columns table and join into three columns table

Mon, 02/19/2018 - 21:22

I'm trying to figure out solution for the following, I need to find pairs employee > manager and print it out.

The given table is:

employee manager ---------------------------------- Bryce Posada Antony Real   Sung Hosey Aurelio Havlik   Joan Strother Aurelio Havlik   Irwin Fulks Barton Rose   Rocco Keplin Benito Cowboy   Efrain Ricketson Benito Cowboy   Patricia Hackenberg Benito Cowboy   Paris Sigala Chuck Lawson   Alva Kaul Ernest Divens   Eli Bielecki Ernest Divens   Walton Virden Ernest Divens   Raphael Montesino Ernest Divens   Dewayne Biggs Lonny Meller   Josef Bakken Marc Margulies   Everett Gresham Marc Margulies   Zachariah Yochum Otto Brannum  

Now, I need to get the results as follows, for example:

  • Anthony Real manages only one person, so there will be null as a pair.
  • Aurelio Havlik manages two people, so there will be pair.
  • Benito Cowboy manages three people, so there will be one pair and one record with null.

See below:

employee_paired1 employee_paired2 manager --------------------------------------------------------- Bryce Posada null Antony Real   Sung Hosey Joan Strother Aurelio Havlik   Irwin Fulks null Barton Rose   Rocco Keplin Efrain Ricketson Benito Cowboy   Patricia Hackenberg null Benito Cowboy   Paris Sigala null Chuck Lawson   Alva Kaul Eli Bielecki Ernest Divens   Walton Virden Raphael Montesino Ernest Divens   Dewayne Biggs Dewayne Biggs Lonny Meller   Josef Bakken Everett Gresham Marc Margulies   Zachariah Yochum Zachariah Yochum Otto Brannum  

So far my code generates results but they overlap...

Iterating through list creating new unique list

Mon, 02/19/2018 - 20:56

I know that some would mark this is a duplicate, but in my case (and my limited knowledge) i still haven't found any similar example which i can relate to.. Therefore i say sorry upfront :)

It's pretty straight forward for an experienced JS dev i assume..

I just cannot figure out how to match on a arrays property :

if (!uniqueEnts.includes(ent.entity)) { // how do i match on uniqueEnts.entityName ?

Current approach results in too many hits in the new list, and the check (look above) doesn't provide with the correct check against uniqueEnts.entityName

JSON Input :

Desired output : new list (uniqueEntities) with the following two properties

  • entityName (unique)
  • entityColor (randomly generated)

Code :

uniqueEntities() { let uniqueEnts = [] this.nluDataUnfiltered.forEach(function (i) { i.entities.forEach(function (ent) { if (!uniqueEnts.includes(ent.entity)) { let obj = { entityName: ent.entity, entityColor: Util.getRandomColor() } uniqueEnts.push(obj) obj = null } }) }) return _uniqueEnts.entityName.sort().value() // earlier tryout --> return _(uniq(uniqueEnts.entityName)).sort().value() },

UPDATED WITH LATEST TRYOUT :

uniqueEntities() { let uniqueEntityObj var uniqueEntity = Array.from(new Set( data.map(el => this.nluDataUnfiltered.entities[0].entity) )); uniqueEntityObj = uniqueEntity.map(el => { entityName:el, entityColor: Util.getRandomColor() }); return uniqueEntityObj },

Error :

How to read photoshop .act files with Python

Mon, 02/19/2018 - 20:33

I was looking for a way to read the Photoshop's color palette files.

As of yet there is no answer here, so I'd like to share my solution.

Android/Kotlin unresolved reference 'Intent' : val intent = Intent

Mon, 02/19/2018 - 20:20

I am sure there is something obvious but have not been able to find a solution to this simple problem. The error is in a main activity attempting to start another activity when a user guesses the correct answer:

Error:(85, 23) Unresolved reference: Intent

The code is from the High/Low Android app in the book 'Kotlin Development for Android'.

val intent = Intent("com.example.user.highlow2.CorrectGuessActivity") startActivity(intent)

The manifest has the following intent-filter for the called activity:

<intent-filter> <action android:name="com.example.user.highlow2.CorrectGuessActivity"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter>

.Net model properties not being rendered in view [duplicate]

Mon, 02/19/2018 - 19:44

This question already has an answer here:

I am at a loss here, here is my code in my Model

public class Movie { public int Id { get; set; } public string Name { get; set; } }

here is the code in my controller

public class MoviesController : Controller { public ActionResult Random() { var movie = new Movie(); movie.Name = "Kevin"; return View(); } }

here is the code in my view

@model Vidly.Models.Movie @{ ViewBag.Title = "Random"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>@Model.Name</h2>

Please help guys, I have no idea what I am doing wrong?

Pages