2018-10-22         Edwiin

Handling null strings and ints in Json

JSON ignores any parameters with null values. So, when I create a string using JsonConverter.ExportToString these properties are missing. Also any integers with null values are replaced with -2147483648This becomes an issue when I try to deserialize this string (I am writing my own deserializer and not using Json.Import)What's the best way of handling this? I am not sure that I understand the question. JSON is just a subset of javascript and properties with null values can be represented like so:{"property1": 1, "property2": null}In this case, property1 is a numeric and ...

 asp.net                     2 answers                     3 view
 2018-10-22         Edwiin

SVN Weirdness: Is It Possible It's Not My Fault

(I don't really care if it's my fault but rather why things are happening, of course...)I have a rails site in SVN on a remote server. On my local copy I do a switch (svn switch http://whatever/branch .), and then things are totally bizarre and the site doesn't work. I finally track it down and it turns out that part of the build (particularly, the app/config directory) is pointing to the wrong branch. Please note:I never switch using anything other than the SVN command lineI only switch at the root of the installationI always switch as root (sudo -s) and I'm sure that the ...

 ruby-on-rails                     2 answers                     79 view
 2018-10-22         Edwiin

Is there a way to have a secondary storage or backup for data blocks in Hadoop?

I have Hadoop running on a cluster that has non-dedicated nodes (i.e. it shares nodes with other applications/users). When the other users are using a cluster's node, it is not allowed to run Hadoop jobs in that node. Thus, it is possible that only a few nodes are available in a given moment, and that this few nodes do not have all data blocks (replicas) need by the Hadoop job. I also have a big Network-Attached Storage that is used for backup. So, I am wondering if there is a way to use it as a secondary storage for Hadoop. For example, if some data block is missing in the...

 hadoop                     1 answers                     102 view
 2018-10-22         Edwiin

Better way to join data frames nested in a list within R

I have a list object that contains nested lists, each includes a data frame. The code below simulates my data structure:## simulate my data structure -- list of data framesmylist <- list()for (i in 1:5) { tmp <- list(data = data.frame(x=sample(1:5, replace=T), y=sample(6:10, replace=T))) mylist <- c(mylist, tmp)}I am looking to row bind all of my dataframes in order to create one master data frame. Currently I use a for loop to complete this action:## goal: better way to combine row bind data frames## I like rbind.fill because sometimes my data are not as clean a...

 r                     1 answers                     18 view
 2018-10-22         Edwiin

Bacteria on fingers. Syntax for crossed random effects with random slopes but not intercepts in MASS::glmmPQL

I have non-normal data (bacteria on fingers after touching surfaces with and without gloves) so using glmmPQL from the MASS package. I have one categorical predictor (Gloves), a repeated measurement variable (NumberContacts) and Participants who did the experiment gloved and ungloved so are crossed. I'd like to use the Participant variable as a random effect with random slope (but not intercept as they have 0 bacteria to start with). I can't figure out the syntax for random effects with random slope but not random intercept. Could you show me how to do this please? So far I...

 r                     1 answers                     88 view
 2018-10-22         Edwiin

Detect mobile browser (not just iPhone) in python view

I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code:def(myView) do some stuff if user-is-on-a-mobile-device: do some stuff return (my mobile template) else: do some stuff return (my normal template)I don't have a huge amount of time and I'm pretty early on in my coding learning curve :) - I found what looks to be a very powerful pluggable app called bloom for getting mobile device capablities ...

 python                     3 answers                     93 view
 2018-10-22         Edwiin

IndexError: list index out of range - CSV file

There is an error in my code - IndexError: list index out of range, at rates[row[0]] = row[1]:def change(): # read file into dictionary with open('exchangeRate.csv', 'r') as in_file: echRdr = csv.reader(in_file) for row in echRdr: rates[row[0]] = row[1]it is because there are empty lines in my file due to editing and the easiest way to solve this is to make it skip these lines, how would i do that? A simple condition in the for loop may solve the issue.def change(): # read file into dictionary with open('exchangeRate.csv', 'r') as in...

 python                     1 answers                     48 view
 2018-10-22         Edwiin

using BitmapSource as Image source in WPF

I'm trying to update an Image (_browserScreenshot below) object in XAML by changing the source image every time an event determines the source needs updating. Right now I have this:public BitmapSource GetScreen(){ Bitmap bitmap = new Bitmap(app.Browser.ClientRectangle.Width, app.Browser.ClientRectangle.Height); app.Browser.DrawToBitmap(bitmap, app.Browser.Bounds); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions...

 wpf                     2 answers                     24 view
 2018-10-22         Edwiin

Accessing undefined objects in JSON with Google Apps Script

I'm working on a telegram bot project and I need to identify the type of JSON file I receive.For example, a message would have :{ "update_id": 12345, "message": { "message_id": 123, "from": { "id": 123456, "is_bot": false, "first_name": "John", "last_name": "Tan", "username": "John123", "language_code": "en-SG" }, "chat": { "id": 123456, "first_name": "John", "last_name": "Tan", "username": "John123", "type": "private" ...

 javascript                     1 answers                     60 view
 2018-10-22         Edwiin

assert() not evaluating code automatically

My PHP version is 7.2.9-1. There is a code injection on line assert in the following exercise:extract($_POST);function goAway() { error_log("Hacking attempt."); header('Location: /error/');}if (!isset($pi) || !is_numeric($pi)) { goAway();}if (!assert("(int)$pi == 3")) { echo "This is not pi.";} else { echo "This might be pi.";}The operation assert() evaluates PHP code and it contains user input. However, I used pi=phpinfo() and the server does not phpinfo() but only outputs This might be pi.. Could someone explain this? From the PHP manual: Assertions sho...

 php                     1 answers                     12 view
 2018-10-22         Edwiin

Sql Server 2005 Puts square brackets around column name

I have recently moved a database from Sql Server 2000 to Sql Server 2005. In the table designer, it insists on putting square brackets around a column named "Content" I don't see Content on the list of reserved words for Sql Server, so I don't understand why it is doing this. Is there a way I can prevent it? CONTENT is a keyword when defining an XML column with a schema.See here.Edit: The MSDN link is broken (per Champ's comment), so here is the relevant extract: Creating a typed XML column is as simple as adding the name of the schema inside parentheses, as you see ...

 sql                     3 answers                     21 view
 2018-10-22         Edwiin

Enumerating table partitions in Postgres table

Suppose I have a table like this:id | part | value----+-------+------- 1 | 0 | 8 2 | 0 | 3 3 | 0 | 4 4 | 1 | 6 5 | 0 | 13 6 | 0 | 4 7 | 1 | 2 8 | 0 | 11 9 | 0 | 15 10 | 0 | 3 11 | 0 | 2I would like to enumerate groups that have part atribute 0.Ultimately I want to get this:id | part | value | number----+-------+----------------- 1 | 0 | 8 | 1 2 | 0 | 3 | 2 3 | 0 | 4 | 3 4 | 1 | 6 | 0 5 | 0 | 13 | 1 6 | 0 | 4 | 2 7 | 1 | 2 | 0 8 | 0 | 11 ...

 sql                     1 answers                     92 view
 2018-10-22         Edwiin

Slack Incoming Webhook sends as my user

I've created an Incoming Webhook within my Slack workspace. I'm using it from a third party tool to post a JSON object to the hook url. I want to send a notification to @user_1My issue is that the notification sends to a private channel between myself and that user @user_1, rather than sending to @user_1 directly, say via Slackbot or a channel with only that user in.How do I ensure that the notification is sent from either Slackbot or @user_1, rather than myself?The way that I set up is by creating a New App with an Incoming Webhook. For the channel, I select @user_1, an...

 webhooks                     1 answers                     17 view
 2018-10-22         Edwiin

CherryPy encoding: bool object not iterable

Hello, I am using CherryPy to host the gui of an application that takes json files from qualtrics and drops them in a mysql server. The code seems to work for most surveys but for some I get the following error:Traceback (most recent call last):File "C:\Users\jam66\AppData\Local\Programs\Python\Python37-32\lib\site-packages\cherrypy\_cprequest.py", line 627, in respond self._do_respond(path_info)File "C:\Users\jam66\AppData\Local\Programs\Python\Python37-32\lib\site-packages\cherrypy\_cprequest.py", line 686, in _do_respond response.body = self.handler()File "C:\U...

 cherrypy                     1 answers                     32 view
 2018-10-22         Edwiin

Python 3.6 is required. Current python version is ''

I'm trying to use azure functions on Ubuntu and have the following error:Python 3.6 is required. Current python version is ''I've installed azure functions tools using:npm i -g azure-functions-core-tools@core --unsafe-perm trueand trying to:func init <> --worker-runtime pythonAny idea why it fails?Thanks,Adrian Depending what sudo apt list --installed|grep python3.6 says you may want to install python3.6 via sudo apt-get install python3.6. [XXX]

 azure-functions-core-tools                     1 answers                     102 view
 2018-10-22         Edwiin

Using CSS or HTML how can I eliminate the margins of a website?

I am building the project section of my personal website.It looks the following way:WebsiteI am trying to get rid of the left margin so my image can start from the left margin.This my current code: <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"> <div class="row-lg-4"> <div class="hovereffect"> <img class="img-responsive" src="../Projects/img/cyberSecurity.jpg" height = "600vh" width = "100vw" alt=""> <div class="overlay"> <h2>Effect 12</h2> <p> <a href="#">LINK HE...

 html                     3 answers                     55 view

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