on-internet

How to get DPI in C# .NET?

I'm trying to build a Windows Forms application using C#. How do I get the DPI in .NET? I've read before that there is DPIX and DPIY, which can be used in .NET to get the current DPI. Is that correct? Thanks all.

Join the discussion →

How can I specify a vector parameter so that values may change but the vector structure won't?

In defining a function in an interface : virtual void ModifyPreComputedCoeffs ( std::vector < IndexCoeffPair_t > & model_ ) = 0; we want to specify that the vector model_ should not be altered in the sense push_back etc operations should not be done on the vector, but the IndexCoeffPair_t struct objects in the model_ could be changed. How should we specify that ? Declaring the parameter as const, like so: virtual void ModifyPreComputedCoeffs ( const std::vector < IndexCoeffPair_t > & model_ ) = 0; does not work I think.

Join the discussion →

Negative weights using Dijkstra's Algorithm

I am trying to understand why Dijkstra's algorithm will not work with negative weights. Reading an example on Shortest Paths, I am trying to figure out the following scenario: 2 A-------B \ / 3 \ / -2 \ / C From the website: Assuming the edges are all directed from left to right, If we start with A, Dijkstra's algorithm will choose the edge (A,x) minimizing d(A,A)+length(edge), namely (A,B). It then sets d(A,B)=2 and chooses another edge (y,C) minimizing d(A,y)+d(y,C); the only choice is (A,C) and it sets d(A,C)=3. But it never finds the shortest path from A to B, via C, with total length 1. I

Join the discussion →

Fixed position but relative to container

I am trying to fix a div so it always sticks to the top of the screen, using: position: fixed; top: 0px; right: 0px; However, the div is inside a centered container. When I use position:fixed it fixes the div relative to the browser window, such as it's up against the right side of the browser. Instead, it should be fixed relative to the container. I know that position:absolute can be used to fix an element relative to the div, but when you scroll down the page the element vanishes and doesn't stick to the top as with position:fixed. Is there a hack or workaround to achieve this?

Join the discussion →

Why is dereferencing a null pointer undefined behaviour?

According to ISO C++, dereferencing a null pointer is undefined behaviou. My curiosity is, why? Why has the standard decided to declare it undefined behavior? What is the rationale behind this decision? Compiler dependency? Doesn't seem, because according to C99 standard, as far as I know, it is well defined. Machine dependency? Any ideas?

Join the discussion →

Saving a picture from a webcam displayed video in a PictureBox in VB6

I have used a code from the internet to show my webcam in a certain form, however, i dont know how to capture an image and save it automatically to my local disk drive via command button click. would anyone help me ASAP :)) here is my code for the form. Option Explicit Const ws_visible = &H10000000 Const ws_child = &H40000000 Const WM_USER = 1024 Const WM_CAP_EDIT_COPY = WM_USER + 30 Const wm_cap_driver_connect = WM_USER + 10 Const wm_cap_set_preview = WM_USER + 50 Const wm_cap_set_overlay = WM_USER + 51 Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52 Const WM_CAP_SEQUENCE = WM_USER + 62 Const WM_

Join the discussion →

send email without gmail

It seems many solutions involve using a server: smtp.gmail.com and System.Net.Mail.SmtpClient. one two Other's suggest using System.Web.Mail (which many say has been deprecated): here for example. In any case, when I tried it, I wasn't able to get either of the above examples to work. I don't think it's a firewall problem. I am able to use outlook express to send emails through gmail. The error in C# that I am given is that the target machine is actively refusing the connection. Should I attempt to use outlook from the code? Would the best way to do that be through AutoIt or through some dll/c

Join the discussion →

php nusoap return array

I am new to web services. I want to write a generic function in php nusoap server side which can query (fetch data from multiple tables) and return a dynamic array depending upon the results returned from mysql... Here is the server code... require_once ('../lib/nusoap.php'); $server = new soap_server; $server->register('getallbook'); function getallbook() { $conn = mysql_connect('localhost','root',''); mysql_select_db('apexinventry', $conn); $sql = "SELECT * FROM users"; $q = mysql_query($sql); while($r = mysql_fetch_array($q)){ $items[] = array('cd'=>$r['id'],'title'=>$r['userid'],'author'=>

Join the discussion →

Confused over memory mapping

I've recently started getting into low level stuff and looking into bootloaders and operating systems etc... As I understand it, for ARM processors at least, peripherals are initialized by the bootloader and then they are mapped into the physical memory space. From here, code can access the peripherals by simply writing values to the memory space mapped to the peripherals registers. Later if the chip has a MMU, it can be used to further remap into virtual memory spaces. Am I right? What I don't understand are (assuming what I have said above is correct): How does the bootloader initialize the

Join the discussion →

Encapsulate a dynamic number of OR LIKE conditions with parentheses using CodeIgniter's active record methods [duplicate]

I'm producing a query like the following using ActiveRecord SELECT * FROM (`foods`) WHERE `type` = 'fruits' AND `tags` LIKE '%green%' OR `tags` LIKE '%blue%' OR `tags` LIKE '%red%' The number of tags and values is unknown. Arrays are created dynamically. Below I added a possible array. $tags = array ( '0' => 'green'. '1' => 'blue', '2' => 'red' ); Having an array of tags, I use the following loop to create the query I posted on top. $this->db->where('type', $type); //var type is retrieved from input value foreach($tags as $tag): $this->db->or_like('tags', $tag); endforeach; The issue: I need t

Join the discussion →

Use of frame_max in RabbitMQ

I've read about the frame_max for rabbitMQ, it said frame_max is "Maximum permissible size of a frame (in bytes) to negotiate with clients. Setting to 0 means "unlimited" but will trigger a bug in some QPid clients. Setting a larger value may improve throughput; setting a smaller value may improve latency." Why the default value is 128 KB. I think in production environment, there is no case in which one wants to have high latency, then why the default value is set so much low. It can be set by default as very high, so as one can have high throughput always. Is there any harm in having high val

Join the discussion →

Resize pdf pages in Python

I am using python to crop pdf pages. Everything works fine, but how do I change the page size(width)? This is my crop code: input = PdfFileReader(file('my.pdf', 'rb')) p = input.getPage(1) (w, h) = p.mediaBox.upperRight p.mediaBox.upperRight = (w/4, h) output.addPage(p) When I crop pages, I need to resize them as well, how can I do this?

Join the discussion →

Django low level cache views

I have an index view which validates a form containing various data. Even though the thankyou.html page doesn't have complex calculations to kill the server, I would like to render a slightly different html page if thankyou.html is already low level cached. To tell you the truth, I don't know what key to pass it... Here is the code: def index(request): form = UserForm() message = 'Incorrect data!' if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): try: User.objects.get(code=form.cleaned_data['code']) except (KeyError, ObjectDoesNotExist): u = User(lastname=form.clea

Join the discussion →

How to simulate PC's Esc key on android

I'm writing an app that can play flash on android, but I can't simulate ESC key, since a lot of flash games need ESC key to return to the main menu, without this key the app I made will be useless. So who could tell me how to simulate this? Can I just send a keycode? but I don't know the keycode too...

Join the discussion →

How to Play Video from URL in Android?

I wrote code for play video from URL. But I am getting UNABLE TO PLAY VIDEO message. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView videoView = (VideoView) findViewById(R.id.video); MediaController mc = new MediaController(this); mc.setAnchorView(videoView); mc.setMediaPlayer(videoView); Uri video = Uri.parse("http://www.youtube.com/watch?v=qvtCk1wZ7LM&feature=player_detailpage"); videoView.setMediaController(mc); videoView.setVideoURI(video); videoView.start(); } <VideoView android:layout_width="match_parent" andr

Join the discussion →

Export DataGridView data to excel

In my application I'm exporting DataGridView data to excel sheet now I want to pass the combobox and textbox selected values to excel sheet and I have to give title to my excel sheet as Report for my windows application how can I do that? Can anyone help me on this? I have code for exporting datagridview data to excel: private void btnexcel_Click(object sender, EventArgs e) { Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkS

Join the discussion →

How to get the value before or between certain unchanging symbols in a dynamic string in JavaScript

I have a string which contains: abc: def - 01:00, ghi - 02:00 Any part of this string can change, except the order of the dividers in the string i.e. :, -, :, ,, -, and : How do I get the text before the first : and stick it into a variable for later use? And also, how do I get the text between the first - and , and stick that into a different variable?

Join the discussion →

finding index of max value in an array in C

I want to find index of max value in array in C. I write this code example: maks=0; for(i=0;i< N * N;i++) { if(array[i]>maks) { maks=(int) array[i]; k=i; } } But this isn't work properly.Could you advise me another example?

Join the discussion →

Comparing Bitfields of Different Sizes

What happens if you use a bitwise operator (&, |, etc.) to compare two bitfields of different sizes? For example, comparing 0 1 1 0 with 0 0 1 0 0 0 0 1: 0 1 1 0 0 0 0 0 The smaller one is extended with zeros and pushed to the 0 0 1 0 0 0 0 1 most-significant side. Or... 0 0 0 0 0 1 1 0 The smaller one is extended with zeros and pushed to the 0 0 1 0 0 0 0 1 least-significant side. Or... 0 1 1 0 The longer one is truncated from its least-significant side, 0 0 1 0 keeping its most significant side. Or... 0 1 1 0 The longer one is truncated from its most-significant side, 0 0 0 1 keeping its lea

Join the discussion →

how to uniqify a list of dict in python

I have a list: d = [{'x':1, 'y':2}, {'x':3, 'y':4}, {'x':1, 'y':2}] {'x':1, 'y':2} comes more than once I want to remove it from the list.My result should be: d = [{'x':1, 'y':2}, {'x':3, 'y':4} ] Note: list(set(d)) is not working here throwing an error.

Join the discussion →

How to decode URL-encoded string in shell?

I have a file with a list of user-agents which are encoded. E.g.: Mozilla%2F5.0%20%28Macintosh%3B%20U%3B%20Intel%20Mac%20OS%20X%2010.6%3B%20en I want a shell script which can read this file and write to a new file with decoded strings. Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en I have been trying to use this example to get it going but it is not working so far. $ echo -e "$(echo "%31+%32%0A%33+%34" | sed 'y/+/ /; s/%/\\x/g')" My script looks like: #!/bin/bash for f in *.log; do echo -e "$(cat $f | sed 'y/+/ /; s/%/\x/g')" > y.log done

Join the discussion →

Converting (any) PDF to black (K)-only CMYK

This is related to: Converting PDF to CMYK (with identify recognizing CMYK). Script (or some other means) to convert RGB to CMYK in PDF? ... but a bit more specific here: say I have an RGB PDF, where the text color is "rich black" (R:0 G:0 B:0 gone to C:100 M:100 Y:100 K:100), and diverse images and vector graphics. I would like to convert this to a CMYK PDF, using a free command line tool (so it is batch scriptable under Linux), which has contents only in the black (K) channel: Preserves vector graphics (+ text glyphs) - colors become grayscale in black (K) channel only Images get converted t

Join the discussion →
Older stories