Questions

jQuery .scrollTop(); + animation

I set the page to scroll to top when a button is clicked. But first I used an if statement to see if the top of the page was not set to 0. Then if it's not 0 I animate the page to scroll to the top....

10 May at 04:28

What's the best way to cancel event propagation between nested ng-click calls?

Here's an example. Let's say I want to have an image overlay like a lot of sites. So when you click a thumbnail, a black overlay appears over your whole window, and a larger version of the image is ...

16 May at 16:39

How to check if a number is between two values?

In JavaScript, I'm telling the browser to do something if the window size is greater than 500px. I do it like so: ``` if (windowsize > 500) { // do this } ``` This works great, but I would like...

12 Jun at 04:58

Get the Query Executed in Laravel 3/4

How can I retrieve the raw executed SQL query in Laravel 3/4 using Laravel Query Builder or Eloquent ORM? For example, something like this: ``` DB::table('users')->where_status(1)->get(); ``` Or: ...

How to call function from another file in Go

I want to call function from another file in Go. Can any one help? `test1.go` ``` package main func main() { demo() } ``` `test2.go` ``` package main import "fmt" func main() { } func demo() ...

23 Dec at 11:17

Center a DIV horizontally and vertically

Is there a way to but, and that is important, that I have always centered divs with the absolute positioning and negative margins like in the example provided. But it has the problem that it cut...

2 May at 09:26

How to make HTML input tag only accept numerical values?

I need to make sure that a certain `<input>` field only takes numbers as value. The input is not part of a form. Hence it doesn't get submitted, so validating during submission is not an option. I wan...

6 Jul at 07:30

Check if a value is in an array (C#)

How do I check if a value is in an array in C#? Like, I want to create an array with a list of printer names. These will be fed to a method, which will look at each string in turn, and if the string...

30 Jan at 09:52

Async/await vs BackgroundWorker

In the past few days I have tested the new features of .net 4.5 and c# 5. I like its new async/await features. Earlier I had used [BackgroundWorker](http://msdn.microsoft.com/en-us/library/vstudio/sy...

Why is the time complexity of both DFS and BFS O( V + E )

The basic algorithm for BFS: ``` set start vertex to visited load it into queue while queue not empty for each edge incident to vertex if its not visited load into queue ...

MySQL root access from all hosts

I've installed MySQL server on a remote Ubuntu machine. The `root` user is defined in the `mysql.user` table this way: ``` mysql> SELECT host, user, password FROM user WHERE user = 'root'; +---------...

16 Oct at 06:47

More elegant "ps aux | grep -v grep"

When I check list of processes and 'grep' out those that are interesting for me, the `grep` itself is also included in the results. For example, to list terminals: ``` $ ps aux | grep terminal user ...

21 Feb at 10:15

Trim a string based on the string length

I want to trim a string if the length exceeds 10 characters. Suppose if the string length is 12 (`String s="abcdafghijkl"`), then the new trimmed string will contain `"abcdefgh.."`. How can I achiev...

16 May at 16:3

Android - get children inside a View?

Given a View how can I get the child views inside it? So I have a custom View and debugger shows that under `mChildren` there are 7 other views. I need a way to access these views but it doesn't seem...

6 Dec at 04:7

Return first N key:value pairs from dict

Consider the following dictionary, d: ``` d = {'a': 3, 'b': 2, 'c': 3, 'd': 4, 'e': 5} ``` I want to return the first N key:value pairs from d (N <= 4 in this case). What is the most efficient meth...

22 Sep at 12:29

Use tab to indent in textarea

I have a simple HTML textarea on my site. Right now, if you click in it, it goes to the next field. I would like to make the tab button indent a few spaces instead. How can I do this?

1 May at 21:23

How to use JavaScript variables in jQuery selectors?

How do I use JavaScript variables as a parameter in a jQuery selector? ``` <script type="text/javascript"> $(function(){ $("input").click(function(){ var x = $(this).attr("name"); $("i...

17 Aug at 18:47

How can I store a command in a variable in a shell script?

I would like to store a command to use at a later time in a variable (not the output of the command, but the command itself). I have a simple script as follows: ``` command="ls"; echo "Command: $comma...

5 Dec at 02:54

In which case do you use the JPA @JoinTable annotation?

In which case do you use the JPA `@JoinTable` annotation?

Count number of records returned by group by

How do I count the number of records returned by a group by query, For eg: ``` select count(*) from temptable group by column_1, column_2, column_3, column_4 ``` Gives me, ``` 1 1 2 ``` I nee...

1 Sep at 13:31

How to play an android notification sound

I was wondering how I could play a notification sound without playing it over the media stream. Right now I can do this via the media player, however I don't want it to play as a media file, I want i...

16 Jan at 11:47

How do I set a conditional breakpoint in gdb, when char* x points to a string whose value equals "hello"?

Can I specify that I want gdb to break at line x when `char* x` points to a string whose value equals `"hello"`? If yes, how?

AttributeError: 'module' object has no attribute 'urlopen'

I'm trying to use Python to download the HTML source code of a website but I'm receiving this error. ``` Traceback (most recent call last): File "C:\Users\Sergio.Tapia\Documents\NetBeansProjec...

20 Aug at 15:19

Default visibility for C# classes and members (fields, methods, etc.)?

I'm trying to find a reference for the default visibility of various aspects of C#. Class types, fields, methods, enums, etc. Can someone provide a list of these along with their default visibility (...

13 Feb at 18:2

jQuery get the location of an element relative to window

Given an HTML DOM ID, how to get an element's position relative to the window in JavaScript/JQuery? This is not the same as relative to the document nor offset parent since the element may be inside ...

19 Apr at 11:40