Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from 2017-11-22T13:16:57Z
Updated: 9 hours 3 min ago

Why is my GitHub Pages website not displaying?

Sun, 11/19/2017 - 19:27

I'm completely new to creating and hosting websites, but I am trying to publish my website code to github and view it with github pages.

I've created a new repository and added in my project file which contains an HTML file, a CSS file, and an images folder with one .jpg image inside.

My github pages site is set to be built from the master branch, however when I try to look at my website, only the repository title and my added comment show up. When I try to view my website locally, everything works correctly.

My github:

Center image without link with width 100%

Sun, 11/19/2017 - 19:07

I want to center my Logo, but the hyperlink on it extends itself to width 100%, which perfectly makes sense because I set the margin auto.

But how can I still have my Logo centered and have the link only on the area of my image?

.logo { height: 50px; display: inline-block; vertical-align:middle; padding: 0px 10px; } @media (max-width: 600px) { #nav ul.desktop-nav li { display: none; } .logo { display: block; margin: auto; } } <a href="#"><img class="logo" src="logo.png"></a>

How to check if triangle2D is inside another one or overlapping it?

Sun, 11/19/2017 - 14:19

I'm trying to check if triangle2D is contain another triangle or overlapping it.

I can do that with circle e.g:

/** Return true if the specified point * (x, y) is inside this circle */ public boolean contains(double x, double y) { return Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2)) < radius; } /** Return true if the specified * circle is inside this circle */ public boolean contains(Circle2D circle) { return Math.sqrt(Math.pow(circle.getX() - x, 2) + Math.pow(circle.getY() - y, 2)) <= Math.abs(radius - circle.getRadius()); } /** Return true if the specified * circle overlaps with this circle */ public boolean overlaps(Circle2D circle) { return Math.sqrt(Math.pow(circle.getX() - x, 2) + Math.pow(circle.getY() - y, 2)) <= radius + circle.getRadius(); }

But I don't know how to do that with triangle.

I've found this for point only, but I don't how to do that if triangle contain other triangle or overlapping it.

Identifying conflicting dates on create in rails

Sun, 11/19/2017 - 12:38

Making a reservation app. How can I check or validate the date for example date_start and date_end has the value of

date_start date_end 26-11-2017 27-11-2017

I will create another reservation which has these starting and end date values but it conflicts with the other values. How can I check for conflicting dates?

date_start date_end 25-11-2017 28-11-2017

Used this to validate the dates in between


validate :no_reservation_overlap scope :overlapping, ->(period_start, period_end) do where "((date_start <= ?) and (date_end >= ?))", period_end, period_start end private def no_reservation_overlap if (Reservation.overlapping(date_start, date_end).any?) errors.add(:date_end, 'it overlaps another reservation') end end

View - choosing the date

<%= f.label :'date_start:' %> <%= f.date_field :date_start %> <%= f.label :'date_end:' %> <%= f.date_field :date_end %>

Sample dates 26 to 27 are already booked/reserved supposedly the it must prevent from inserting 25 to 28 because 26 to 27 are already booked.

Transition doesn't work with checkbox

Sun, 11/19/2017 - 12:02

Need some help. Dont understant why transition doesn't work. I want that pop up menu with stuf slowly shows on click on category. Any idea why it doesn't? Should i use max-height or what?

.content_product_left_popup { width: 243px; height: 37px; background-color: #ccc; margin-bottom: 18px; } .content_product_left_box1 input[type="checkbox"] { display: none; } .content_product_left_box1 input[type="checkbox"] ~ .content_product_left_popup_menu1 { height: 0; display: none; -webkit-transition: height 0.3s ease-in-out; -moz-transition: height 0.3s ease-in-out; -o-transition: height 0.3s ease-in-out; -ms-transition: height 0.3s ease-in-out; transition: height 0.3s ease-in-out; } .content_product_left_box1 input[type="checkbox"]:checked ~ .content_product_left_popup_menu1 { height: 100px; width: 243px; display: block; background-color: #ccc; margin-bot: 10px; } <div class="content_product_left_box1"> <label> <input type="checkbox"> <div class="content_product_left_popup1 content_product_left_popup"> Category </div> <div class="content_product_left_popup_menu1 content_product_left_popup_menu"> Some stuff </div> </label> </div> <div class="content_product_left_box2"> <div class="content_product_left_popup2 content_product_left_popup"> Brand </div> <div class="content_product_left_popup_menu2 content_product_left_popup_menu"> </div> </div>

RasPi based Assistance system for a motel

Sun, 11/19/2017 - 12:02

This is for an assistance calling system for a motel. There are 50 rooms and 7 service provider (Laundry, Restaurant, Chef, Room Service, Chauffer, Reception). Each of the room has a KNX based touch screen where they can access these. Once they press this, it should alert each department and if some one acknowledges this, that particular user should be able to see that it is acknowledged and help is on the way. How can I do this?

I have good experience in using RasPi with Home Assistant (HASS)/ OpenHAB. This is what I have come up with so far. One of the RasPi is communicating to KNX via IP interface.

Possible Solution 1:

Run a single RasPi with HASS. Provide fixed tablets at each location with the ip address of the HASS server hardcoded (a sandboxed webapp)

I need to find a way to differentiate the device that is accessing the page through GET/POST/IP (not sure if i will be able to get static IP). Can some one suggest how can I do this with HASS? And display actionable notification. (I am not sure how I can do this as well without alerting any other devices) Once the user acknowledges it I lit a small LED to acknowledge that help is on the way. Difficult part is how I can differentiate; how i can provide different UI; how I can restrict notification.

Possible Solution 2:

Run 7 RasPi with HASS. This way I can differentiate each devices by only letting it access notifications relevant to that; however I have only one KNX-IP interface and it is connected to only 1 RasPI. How can I make the RasPI communicate to other RasPI with Home Assistant.

Possible Soln 3:

Do not go with HASS. Write python/php scripts. If this is the only solution, i would like a lot of help in how to get started, etc.

Any other solution? PLEASE help me.

Zipping a file and saving it to local disk using Actionscript 3 & FZip

Sun, 11/19/2017 - 12:02

i made a flash desktop application that requires the user to save a file to his computer, in this case i have a lot of images and i want the user to save them on his computer, the images are on a folder called "imgs", i'm using one image in this case, i tried to do the following using FZip:

import deng.fzip.*; import flash.filesystem.*; import flash.filesystem.File; //retrieve the image from the "imgs" folder var myfile:File = new File("C:/Users/User/Desktop/zip/imgs/myimage.png"); //zipping the image var zip:FZip = new FZip(); zip.addFile(,; //saving the image to the user's desktop var ba:ByteArray = new ByteArray(); zip.serialize(ba); ba.position = 0; var finalZIP:File = File.desktopDirectory.resolvePath(""); var fs:FileStream = new FileStream();, FileMode.WRITE); fs.writeBytes(ba); fs.close();

the result is a zip file in the desktop, named "", with and image named "myimage.png", but when i unzip the file the image is empty, i tried to do the same with a text file, the text file is there zipped, but with nothing inside it. Any idea what might cause this problem?

Wrong values in launch configuration

Sun, 11/19/2017 - 12:02

I want to run a Node.js app in US South which was deployed in Germany before.


applications: - name: ISICC IDES disk_quota: 1024M host: isiccides command: node server.js path: . instances: 1 memory: 256M domain:

I create a new launch configuration.

  1. Under Spaces I'm still offered the Germany spaces.
  2. Domain is set to, which I can not change.

Android custom settings in custom launcher

Sun, 11/19/2017 - 12:01

I'm working on a custom Android launcher project. I need to have custom settings screen with all system and built in options than Android has already, but with different UI/UX than the default one that comes with OS.

Are there some open source project available already that utilizes all system Android APIs for different options, etc. so I can reuse that logic and provide customized UI?

I need to cover all available options.

I'm having trouble finding one, because of "settings" keyword, where websearch gives me everything but what I need :)

Thanks in advance.

Bounds on constructors?

Sun, 11/19/2017 - 12:01

NOTE: if someone can come up with a better title for what I am trying to ask - please mention or edit.

Given a wrap method:

trait MyWrapperBound { val message: String } def wrap[T <: MyWrapperBound](message: String): T

I am looking for a way to describe that all all implementations of MyWrapperBound should have a constructor that takes a message: String so I can construct and return it from my wrap method.

I can think of a couple of ways to do this:

Method 1 - using an implicit:

def wrap[T <: MyWrapperBound](message: String)(implicit factory: String => T): T

This would mean that any MyWrapperBound impl. would also have to create the implicit:

case class SimpleBound(message: String) extends MyWrapperBound object SimpleBound { implicit def factory(message: String): SimpleBound = SimpleBound(message) }

This would result in a fair amount of boilerplate - which I'd like to avoid.

Method 2 - macro:

def wrap[T <: MyWrapperBound](message: String)(implicit factory: String => T): T = macro ...

The macro could take the type, assert there is a valid constructor and throw a nice compile error if not present.

My question is - being fairly new to scala, is there a simpler option that I am missing? or another option that makes more sense?

Create new entry box when button is clicked (PYTHON GUI)

Sun, 11/19/2017 - 12:01

Im building a project in Python 3.6 for my school (faculty of civil engineering Belgrade), Im using Tkinter.

I made a notepad with 2 cards. I want to add new entry box in second card when button is clicked (button is in first card). Im stuck with this, can you please help me?

Push object into an array in react-native

Sun, 11/19/2017 - 11:58

I have requirement like need to form object as below

[ { "place": "Royal Palace, Oslo", "latitude" : "59.916911" }, { "place": "Royal Palace, Oslo", "latitude" : "59.916911" } ]

the above place and latitude values are available within map function as

let sampleArray = []; => { let place =; let latitude = {/*with other logic function we will get latitude value*/} //need to send these both values into below array to form array shown as above. sampleArray.push(); })

thanks in advance.

Exception when calling strcat

Sun, 11/19/2017 - 11:53

I'm new to C and I need to parse JSON to a file. I literally spent an hour looking for a working way to append an int to a str.

Here is my code :

int day = 1; char strDay = (char) day; char str[100]; strcpy(str, "Blockchain"); strcat(str, strDay);

Everything works well until the strcat call. Thanks in advance

EDIT : I'm using parson to parse my struct to a file. Here's how the JSON file should look lile

{ "Blockchain": { "Block1": { "Day": 2, "Transaction1": { "ID": 1, "Amount": 2 } }, "Block2": { "Transaction2": { "ID": 2, "Amount": 5 } } }}

To do that, I use the parson lib and it works like that :

json_object_dotset_number(root_object, "Blockchain.Blocks.Block1.Transaction1.ID", tmpTransaction->accountID);

I need a way to create mutiples blocks and transactions and that's why I thought of appending the day to the block and the id to the transaction

Occurrence of a letter case sensitive

Sun, 11/19/2017 - 11:50

I am trying to find occurrence of letter 'b' and 'B'. the code that I have written works perfectly. Is there a better way that i can do this.
My code:

def count_letter_b(string): #TODO: Your code goes here a = int(string.count('B')) b = int(string.count('b')) return a + b print count_letter_b("Bubble Bungle")

Android: Check if EditText is empty in real time

Sun, 11/19/2017 - 11:49

In one activity of my app I have 5 EditText fields. However, I want etPlayer5 only to be enabled when the other 4 EditTexts are not empty. I wrote this little code to achieve this:

etPlayer1 = (EditText) findViewById(; etPlayer2 = (EditText) findViewById(; etPlayer3 = (EditText) findViewById(; etPlayer4 = (EditText) findViewById(; etPlayer5 = (EditText) findViewById(; if (namePlayer1.matches("")||namePlayer2.matches("")||namePlayer3.matches("")||namePlayer4.matches("")) { etPlayer5.setEnabled(false); etPlayer5.setFocusable(false); } else { etPlayer5.setEnabled(true); etPlayer5.setFocusable(true); }

Of course this code doesn't work in real time. What do I need to do that when the last of the EditTexts 1 to 4 is filled in, etPlayer5 is automatically set enabled without using a button or something?

Thank you!

Runtime errror with 100000 recursive calls in C++

Sun, 11/19/2017 - 11:44

I tried to run this code in C++14 on Cygwin and Mingw in Windows 10 but in both I am getting runtime error. But on Ubuntu 16.04 it runs without any problem.

#include <iostream> using namespace std; int rec(int n){ if(n == 0) return 0; return 1 + rec(n-1); } int main(){ int k = 123456; cout << rec(k) << endl; return 0 ; }

But if I change the value of k to some number in 10^4 it works even on windows 10, like k = 12345. What could be the reason behind this strange behavior?

How to remove # in front of a line with sed?

Sun, 11/19/2017 - 11:43

I'm trying to uncomment (removing #) the line sql.

session { radutmp # # See "Simultaneous Use Checking Queries" in sql.conf # sql }

This is what I've tried:

sed -i 's/# sql/ sql/' /etc/freeradius/sites-available/inner-tunnel

But somehow the spaces are not correctly calculated. It doesn't find # sql.

(Javascript): How to calculate angle of rectangle using corner position?

Sun, 11/19/2017 - 11:28

I have a rectangle like this...

... and I also know the rectangles corner positions, see the array below:

var corners = [[107, 0], [0, 21], [111, 24], [4, 45]]

Because I need to calculate the rectangles angle like I've symbolized in the image above, my idea was to just use this code:

var rectangle_angle = ((180/Math.PI) * Math.atan((a[1] - b[1]) / (a[0] - b[0]))).toFixed(2) console.log('angle : ' + rectangle_angle)

In the case above I'm using the first two corner points to calculate the angle, see below:

var a = corners[0], b = corners[1]

But e.g. I was using a rectangle like below and tried to calculate the rectangles angle...

(corners: [[101, 0], [110, 22], [0, 38], [9, 60]])

... but the result I got is this -> angle : 67.75, what absolutely is not the right rotation angle.

Afterwards I fixed the problem by just using corner[0] & corner[2] for the calculation instead of using corner[0] & corner[1].

So the result I get now is -20.62°. Way better.

Now my question: How can I extract the right points from my corners array that I have to use for my calculation?

I hope somebody can help me fixing my problem, however - thanks a million in advance.
- Greetings, jonas

You can try the function here:

var corners = [[107, 0], [0, 21], [111, 24], [4, 45]] var a = corners[0], b = corners[1] var rectangle_angle = ((180/Math.PI) * Math.atan((a[1] - b[1]) / (a[0] - b[0]))).toFixed(2) console.log('angle : ' + rectangle_angle)

Lua get last pattern occurrence with string.match

Sun, 11/19/2017 - 11:24

I have a string and want the last digit occurrence (for now my string.match only take the first occurrence)

testvar = "350.11$ i paid, 320$, with visa, cash, 200.21, mastercard, shopping, food" print ("last number: ".. string.match (testvar, "(%d*%.?%d+)"))

in that case I want 200.21 as result (and not 350.11 as by now)

How to GET data by search word Django

Sun, 11/19/2017 - 11:17

I have problem getting the data to the home page. I would like to filter out all the books based on Genre. I'm following the MDN site for this.


{% extends "base_generic.html" %} {% block content %} <h1>Local Library Home</h1> <p>Welcome to <em>Local Library</em>, a very basic Django website.</p> <h2>Dynamic content</h2> <form action="" method="get"> <input type="text" name="genre" placeholder="Search"> <input type="submit" value="Search"> </form> {% endblock %}

urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^books/$', views.BookListView.as_view(), name='books'), url(r'^(?P<string>[-\w]+)$', views.GenreListView.as_view(), name='index'), ]

GenreListView class

class GenreListView(generic.ListView): model = Book def get(request, string): try: book = Book.objects.all().filter(genre=string) except Book.DoesNotExist: raise Http404("Book does not exist") return render( request, 'index.html', context={'book': book,} )

I can't figure out what I'm missing or what else I have to do to get all the date based on genre?