2018-10-22         Susie

Preserve new lines in YAML

How do I format a YAML document like this so that PyYAML can parse it properly?Data: Some data, here and a special character like ':' Another line of data on a separate lineI know that the ':' character is special so I have to surround the whole thing in quotations like so:Data: "Some data, here and a special character like ':' Another line of data on a separate line"And in order to add a new line, I have to add '\n':Data: "Some data, here and a special character like ':'\n Another line of data on a separate line"Is there anyway to format the YAML document so...

 yaml                     2 answers                     61 view
 2018-10-22         Susie

Image overlay when scrolling (javascript)

I want to use image overlay when a page is scrolled like here (see how raindrops and fish appear and a man disappears when scrolling).I tried to make it with parallax effect using CSS only, but it's not what I need, because it doesn't work on mobiles like the example above.I will be thankful if you advise me some javascript hacks with 'onscroll' or something else.My codeHTML<body><div class="parallax"> <div class="bg_one"></div> <div class="bg_two"></div></div></body>CSS.parallax [class*="bg_"] { position: relative; heig...

 javascript                     1 answers                     12 view
 2018-10-22         Susie

javascript es6 class prototype chain modify

I am trying to add class C to the prototype chain of class Bclass A { constructor() { this.a = 'a'; }}class B extends A { constructor() { super(); this.b = 'b'; }}class C extends A { constructor() { super(); this.c = 'c'; }}Object.setPrototypeOf(B.prototype, C.prototype);var a = new A();var b = new B();console.log(b instanceof C);console.log(b instanceof A);console.log(b.c);super in the constructor is based on the classes prototype (not the classes prototype property's prototype): Object.setPrototypeOf(B.prototype, C.prototype); Object.setPrototypeOf(B,...

 javascript                     1 answers                     85 view
 2018-10-22         Susie

python 3 - rounding a Decimal with negative ndigits results in Decimal with scientific notation

I noticed a strange behaviour when using the round() function with a negative rounding factor (the parameter ndigits) and with the decimal module.I'm using Python 3 (specifically 3.6.3, but I don't know if the specific minor version matters for this case).With float it looks normal:>>> round(10000 / 3, 2)3333.33>>> round(10000 / 3, 1)3333.3>>> round(10000 / 3, 0)3333.0>>> round(10000 / 3, -1)3330.0>>> round(10000 / 3, -2)3300.0With Decimal the result is correct, but it changes to scientific notation when using a negative rounding...

 python                     1 answers                     95 view
 2018-10-22         Susie

Python url template tags giving only part of a absolute url.. ..Must be a lack of sleep

I must be suffering from a serious lack of sleep but I am stumped. I can't seem to figure out how to get the {% url %} directive to give me the right url. So let's start with the basics..urls.pyfrom people.views import employee_detailurlpatterns = patterns("", url(r'/uid/(?P<id>[0-9]+)/$', employee_detail, {'template_name' : 'people/single.html'}, name = 'employee_view'),)views.pyfrom django.shortcuts import render_to_response, get_list_or_404from django.template import RequestContextfrom people.models import Employee, OfficeLocationdef employee_detail(request, i...

 django                     1 answers                     87 view
 2018-10-22         Susie

Button function in python with not working self.clicked

Been writing a button function however self.clicked does not keep its value after MOUSEBUTTONUP, is there a better method or a way to keep self.clicked value?code:def check_clicked(self,event): if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: if self.rect.collidepoint(event.pos): self.clicked = True elif event.type == pg.MOUSEBUTTONUP: if self.clicked == True: return True else: return False Your indentation is off, although that should throw an error;def check_clicked(self,event...

 python                     2 answers                     90 view
 2018-10-22         Susie

How could I use Google Apps Script (Advanced Services) to create a Google BigQuery Dataset?

The Google Apps "advanced services", as explained in the docs, are just wrappers to the associated Google APIs. So for Create dataset APIhttps://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insertIt takes one parameter: project_idIt also takes a request body:{ "datasetReference": { "datasetId": "dataset_id" }}So my Google Apps script would use the following code to pass the project_id in parameterBigQuery.Datasets.insert(project_id);But how could I pass the following request body to BigQuery.Datasets.insert?{ "datasetReference": { "datasetId": "dataset...

 google-apps-script                     1 answers                     71 view
 2018-10-22         Susie

Finding Unequal Rows in Two Tables

This question is an exact duplicate of: How to find Unequal Values from Two Tables 1 answer SELECT statement.f1, iif([allocation_final].sumoff6 = statement.f9, statement.f9, [allocation_final].sumoff6 - statement.f9)FROM statement LEFT JOIN allocation_final ON statement.[f1] = allocation_final[f1] [XXX]SELECT switch(t1.[sumoff6] is null,t.[f9] - t.[sumoff6],t1.[sumoff6] is not null, t.[f9])FROM statement LEFT JOIN allocation_final t ON statement.[f1] = allocation_final[f1] LEFT JOIN ...

 sql                     2 answers                     12 view
 2018-10-22         Susie

Write a Query to get desired transformed output from given table

I want a query with can give output as shown in the second photo, as the data is given in the first table(photo) This transformation of converting columns to rows is called Pivot in SQL. SELECT Region,[2010],[2011],[2012],[2013],[2015] FROM (SELECT * FROM SalesTable) AS SourceTable PIVOT ( Avg(Sales) FOR Year in ([2010],[2011],[2012],[2013],[2015]) ) as pvt; [XXX]try this:with tmp as (select f1.region, f1.Year, sum(f1.Sales) Sales from dbo.sales f1group by f1.region, f1.Year)select distinct f1.Region, f2.Sales as [2010]...

 sql                     3 answers                     31 view
 2018-10-22         Susie

Spark doesnt print outputs on the console within the map function

I have a simple Spark application running on cluster mode.val funcGSSNFilterHeader = (x: String) => { println(!x.contains("servedMSISDN") !x.contains("servedMSISDN")}val ssc = new StreamingContext(sc, Seconds(batchIntervalSeconds))val ggsnFileLines = ssc.fileStream[LongWritable, Text, TextInputFormat]("C:\\Users\\Mbazarganigilani\\Documents\\RA\\GGSN\\Files1", filterF, false)val ggsnArrays = ggsnFileLines .map(x => x._2.toString()).filter(x => funcGSSNFilterHeader(x))ggsnArrays.foreachRDD(s => {println(x.toString()})I need to print !x.contains("serv...

 scala                     2 answers                     45 view
 2018-10-22         Susie

Can I build object json in serialization (newton) from a method?

I have a base abstractpublic abstract class absBase{ public int A {get;set;} public string B {get;set;} public abstract string Generate()}public class FirstClass : absBase{ public override string Generate() { //Mapping of certain properties and some calcs return ObjectRepresentationInStringOrObject; }}Now what I would like to do is var a = new FirstClass(); string jsonRep = JsonConvert.Serialize(a);and to have jsonRep be the string that returns from Generate().the Idea is to build a tree of objects for serialization but the leaves would b...

 c#                     1 answers                     34 view
 2018-10-22         Susie

FullCalendar end daily event

How can I know the first and last day of a daily event?For example, I have an event every day at 8am, from the 15-08-2018 until the 17-08-2018, when clicking on the event in the calendar, I want to know the date of the last day of the event, the 08-17-2018Thanks a lot. You can use the eventClick event for the clicking of the event then you access the event data inside that function.For more info read: https://fullcalendar.io/docs/eventClick$(function() { $('#calendar').fullCalendar({ events: [ { "title": "Event 1", "start": "2018-08-10T08:00:00+08:...

 javascript                     1 answers                     29 view
 2018-10-22         Susie

Creating CSP AAD and change user password

BackgroundI create an CSP Customer (Azure Active Directory) through the REST API and then connect this customer to my Azure Stack. In order to automatically connect their account with the Azure Stack I need to grant this from both sides, customer account and my Stack.Hence, I need to use the customers password to login and grant Azure Stack access from the customers side.ProblemI create a CSP customer (password cannot be set during creation) and the password is returned when successful (using the CSP REST API). The password is automatically set to be changed at next login. ...

 azure                     1 answers                     57 view
 2018-10-22         Susie

How to connect to mirrored SQL Server after failover?

I set up a database mirroring and then used this connectionstring to connect to it: Data Source={0};Failover Partner={1};Initial Catalog=AdventureWorks; Integrated Security=True;After adding some data into database, I shutdown the principal server, so the mirror server becomes the principal server. I open the connection again, an get this error: System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)I thought that with ...

 sql-server                     4 answers                     51 view
 2018-10-22         Susie

Employee table - hierarchy with some caveats

I've got an issue with a sort of standard employee table. In my example I have done self joins to the source however I don't get the end structure that I would like.The hierarchy is a few levels up.In a simple form the code is like:select e.employee_name , e.teamlead_name , e1.teamlead_name 'manager_name' , e2.teamlead_name 'senior_manager_name' , e3.teamlead_name 'director_name'from employees eleft join employees e1 on e.teamlead_id = e1.employee_idleft join employees e2 on e1.teamlead_id = e2.employee_idleft join employees e3 on e2.teamlead_id...

 sql                     1 answers                     32 view
 2018-10-22         Susie

Alamofire - Bad request

I am afraid I cannot share the API url. But I have checked on Postman, it works. It is a POST request and following is the response : { "user_key": "b0aebdedb15e2beaaf479ca3c4f8227e8e970681"} Postman screenshot : In code, this is the request I am making using Alamofire : Alamofire.request("some url", method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: ["Content-Type":"application/json"]) .responseObject { (response: DataResponse<User>) in let userResponse = response.result.value print("") }Bu...

 ios                     1 answers                     78 view

Page 1 of 143  |  Show More Pages:  Top Prev Next Last