summary
stringlengths 15
147
| text
stringlengths 1
19.3k
| answer
stringlengths 32
22.6k
| labels
float64 0.33
1
| answer_summary
stringlengths 5
164
|
---|---|---|---|---|
Is it appropriate to email an eminent researcher in your field?
|
Sometimes, I feel to contact some of the eminent researchers in my field for any of the following reasons:
Appreciating their research publication (recent times). They publish in top conferences, which are usually not hosted in my country or nearby.
Requesting comments on some of my research hypothesis
Sometimes just because I am a die hard fan of them. For example, probably the only reason I continued with research in Computer Science was due to Don Knuth.
Sometimes, to know what they think on some specific research area that has propagated due to there work. (Probably looks like some journalistic work)
For knowing how did they tackle the pressures or certain situation during their PhD or research. (Yes, it's vague but these questions come to mind and probably should be answered by oneself or personal interaction, but adding it for the sake of completion)
Since, most of them are located outside my country, I can't visit or phone them. So, how are such emails perceived. Is it appropriate to send such emails, given that they are expected to have very busy schedule and it would probably waste their time?
Though I have mentioned my field as Computer Science, the question should be applicable to all the fields.
|
While many of these topics are excellent points to start a 1-1 conversation, I seriously doubt whether you'd get much of a response over email. This is not to say that they wouldn't appreciate your praise, but that there may not be anything to reply to in particular.
I suspect an email will get a better response if you have specific questions about research content: ideally, a question related to something in a recent paper that isn't entirely obvious. For example, in my field it's sometimes the case that someone sketches a proof idea in a conference paper without a full version, and fleshing this out requires some clarification from the authors.
Of course, you can always add in a question from your list as extra cargo. Then it's a little more likely that someone will reply.
More generally, think about it this way: if you never met someone before, and they came up to you and asked you questions that might be construed as personal (especially 5), or that require you to come up with opinions on the fly (2,4), you might hesitate to respond. The same thing, but without the pressure to say something, will happen over email.
| 0.777778 |
E-mails are excellent points to start a 1-1 conversation .
|
Is "Pick up those blocks" grammatically incorrect?
|
I had someone correct me today as I instructed my child to "pick up those blocks." This person insisted that it should just be:
Pick up those.
since "those" is already plural.
Is this person correct?
|
"Pick up those blocks" is perfectly correct. The fact that "those" is plural doesn't mean that you can leave out the object, "blocks." How would the child know what to pick up?
There's something off about the sentence "Pick up those," because the antecedent of "those" is missing.
"Should I pick up these or those?"
"Pick up those."
is OK. But by itself, it sounds wrong.
| 1 |
"Pick up those blocks"
|
async & await - poll for alternatives
|
Now that we know what is in store for c#5, there is apparently still an opening for us to influence the choice of the two new keywords for 'Asynchrony' that were announced by Anders Heijsberg yesterday at PDC10.
async void ArchiveDocuments(List<Url> urls) {
Task archive = null;
for(int i = 0; i < urls.Count; ++i) {
var document = await FetchAsync(urls[i]);
if (archive != null)
await archive;
archive = ArchiveAsync(document);
}
}
Eric Lippert has an explanation of the choice of the current two keywords, and the way in which they have been misunderstood in usability studies. The comments have several other propositions.
Please - one suggestion per answer, duplicates will be nuked.
|
I think async is fine, but maybe that's because I associate it with ASP.NET async pages - same idea.
For the await keyword I prefer continue after or resume after.
I don't like yield or any of its variants, because the semantics are such that the method may never actually yield execution; it depends on the state of the task.
| 1 |
Async is fine, but maybe that's because I associate it with ASP.NET pages
|
Force garbage collection/compaction with malloc()
|
I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:
# (1)
for k in range(4..20):
# (2)
input = generate 2**k random points
for variant in variants:
benchmark the following call
run variant on input array
# (3)
Is it possible to reset the whole heap management at (2) to the state it had at (1)? All memory allocated on the heap that was allocated during the program is guaranteed to be freed at (3).
I am using g++ 4.3 on Linux.
Edit: I understand that there is no real garbage collection in C/C++. I want to force the memory allocation to join adjacent empty chunks of memory it has in its free list at (2).
|
I think there's a simple solution to your problem - you could move the outside loop outside of your application and into a shell script or another application and pass the (k) (and any other) parameters through the command line to the benchmarked app - this way you'll be sure all executions had similar starting conditions.
| 0.666667 |
You could move the outside loop outside of your application and into a shell script or another application and pass the (k) parameters through the command
|
Is there a comprehensive life science techniques/methods database?
|
There are so many techniques/methodologies in the life sciences that we can use to interrogate interesting questions. The thing is, most of us are completely unaware of the available methods we can employ. Rather, we go with the techniques we are familiar with or that are popular in our subdomains at the time. But that's pretty limiting.
So I'm wondering... we have databases for everything else... is there one for life sciences techniques/methods? Something like this could be immensely helpful in experimental planning. In particular, I think a comprehensive database would help scientists break outside of their spheres of familiarity and to employ less known (but potentially illuminating) methods to their questions.
I know there are journals that publish protocols and methods, but they are fragmented and don't encompass everything.
Does what I'm looking for exist? If not, how might one go about creating such a tool?
|
My personal favourite is OpenWetWare. Think wikipedia for scientific protocols and an open access lab notebook.
There's a problem with this things. Despite the common stereotype of scientist being open and good at sharing, my experience is the opposite. Many laboratories are not good at all in sharing their techniques/secrets. They will share the basic stuff that you can find online, no problem, but that's about it.
Seems they're afraid that everyone's else after them, trying to scoop them. I have suggested OpenWetWare to some other labs and they refused for that same reason. Even though some will use it to find protocols, they don't see a reason to share back.
| 0.888889 |
OpenWetWare is not good at sharing scientific protocols .
|
Which definition is more used for "determine"?
|
I've seen "determine" used for two completely different meanings:
Zeus' mood will determine tomorrow's weather. (determine = control, dictate)
The weather forecaster will determine tomorrow's weather. (determine = forecast, predict)
Are these meanings used equally often, or is one much more common than the other?
|
Actually, I think the word determine is being used here in both cases in the sense of "to decide" or "to resolve". The difference is: in the first case, Zeus is deciding what the weather will be (as it is under his direct control), and in the second case, the weatherman is deciding what the weather should be (a prediction).
| 1 |
determining is used in both cases in the sense of "to decide" or "to resolve"
|
Should we allow or avoid non-standard pronouns?
|
This question brings up an important question:
Do we want to allow or avoid the use of non-standard English such as the words zie and zir as non gender specific pronouns on this site?
|
Sure, let them. Who cares about "zis"? If someone is fond of their own pet thing, let them do it. They'll have confused people make edits all the time and they'll roll them back and there's no need to have more scuffling than that over it. I've seen it with "colour vs color" edits, and that's such a waste of time. If someone rejects BC/AD/BCE/CE dates and only puts in years from whatever other frame of reference - fine, let them.
What will happen is that if people insist on making question in their own pet mindframe, few people will answer their question. As long as people are asking questions they want to know the answer to, this will be self correcting - if you use a language or date system or whatever that people don't understand, you won't get answers. If they are not asking questions they want to know the answer to, crush them, because that's not what we need here.
| 1 |
What's the difference between "zis" and "colour"?
|
Is there a iOS Configuration Profile Key for "Find My iPhone?"
|
I've been looking at this page:
http://developer.apple.com/library/ios/#featuredarticles/iPhoneConfigurationProfileRef/Introduction/Introduction.html
for the configuration profile keys. I couldn't find one for the feature "Find My iPhone." Is there a key for that? If so what is it?
|
Sorry, but both Michael and titaniumdecoy are only partially correct. The "Find My iPhone" app is an app that helps you locate your iOS device if you have the settings set in your iCloud settings on the device.
I too would be interested in knowing if it is possible to push out a configuration profile (using IPCU) that has the "Find My iPhone" setting locked on even though it is technically an iCloud user settings.
| 1 |
The "Find My iPhone" app helps you locate your iOS device if you have the settings set in your iCloud settings
|
Is this morphism the normalization of P^1 in this curve
|
Let $S$ be an integral Dedekind scheme.
Let $f:X\longrightarrow \mathbf{P}^1_{S}$ be a finite flat surjective morphism, where $X$ is an integral normal scheme.
Let $\eta$ be the generic point of $S$. Note that $f_\eta:X_\eta\longrightarrow \mathbf{P}^1_{K(S)}$ is a finite morphism of curves over $K(S)$.
Question. Is $f$ the normalization of $\mathbf{P}^1_S$ in the function field of $X_\eta$?
|
Yes. This follows from Zariski's Main Theorem (although there are probably more direct arguments in this case).
| 0.888889 |
Zariski's Main Theorem
|
Are there any publicly available databases ( not just web apps ) of guitar chords?
|
I need guitar chords in a database for a project I'm working on ( preferably MySQL, CSV or some other easily portable format ). I can imagine many formats by which one could store this information, so I don't particularly care how it's setup.
This information must exist in databases all over the internet, but is there anything freely and publicly available?
|
A quick google of "downloadable guitar chords" took me to the Chordpda site. It is an app for windows mobile devices but it has an XML database of chords so that would be simple to use.
Free and downloadable - I'm giving no assurances as to how good it is, but there must be more - that was just a 5 second google search.
| 1 |
A quick google of "downloadable guitar chords"
|
GMGridview for MonoDevelop and Android
|
Does anyone know of something similar to GMGridview for MonoDevelop and Android?
I am looking for something that will allow me to place about 12 to 15 icons/buttons on the Android that I can swipe/scroll back and forth. I am using MonoDevelop and am very new to Android Development.
I do not necessarily need the drag and drop functionality, but I cannot even find an example of placing many icons on the screen and allowing me to scroll back and forth.
I am struggling with how the layout should be done so any help is appreciated!!
Thank you for any assistance!!!
|
GridView... ?
http://developer.android.com/reference/android/widget/GridView.html
And I have no idea how is it connected with MonoDevelop.
| 1 |
GridView ?
|
can I use a disk larger than 320 GB with RPi?
|
I have a 500GB Toshiba 2.5' HD, which I formated using Debian Wheezy 64bit. I created 2 partitions (180GB and 320GB).
RPi would only recognize the first partition.
So, I tried creating the partitions using the raspberrypi. Here are my surprising findings:
root@raspberrypi:/home/ozn# fdisk -l
Disk /dev/mmcblk0: 4025 MB, 4025483264 bytes
4 heads, 16 sectors/track, 122848 cylinders, total 7862272 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dbfc6
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 7862271 3869696 83 Linux
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x950e3b8d
Device Boot Start End Blocks Id System
/dev/sda1 2048 625142447 312570200 83 Linux
/dev/sda2 625142448 976773167 175815360 83 Linux
First, /dev/sda is NOT recognized correctly! This disk is 500GB.
Second, mounting /dev/sda2 is not possible:
root@raspberrypi:/home/ozn# mount -t ext4 /dev/sda2 /media/usbhdd1/
mount: special device /dev/sda2 does not exist
# although fdisk -l showed this device !
Third, trying to format the disk, it really sees only the sectors until 320GB:
When I start fdisk I am warned:
Building a new DOS disklabel with disk identifier 0x6784fc4b.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
I have other USB hard drives with 320GB and they really mount fine.
Is this a limitation of RPi? Or a problem with this specific Hard Drive?
How can I use this large disk with my RPi?
update: solved the issue with help of the commentators here...
here is what I did ...
I thought I have some weired issue with Debian Wheezy & gparted. So, I reformatted the hard drive to NTFS. Before that I ERASED the partition table.
And created a new single NTFS partition.
Bingo! RPi, identified the partition. However, it claimed my Drive is now 2TB big, and recommended I will use GPT:
root@raspberrypi:/home/ozn# fdisk -l /dev/sda
Disk /dev/sda: 2199.0 GB, 2199023255552 bytes
255 heads, 63 sectors/track, 267349 cylinders, total 4294967296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf720f720
Disk /dev/sda doesn't contain a valid partition table
root@raspberrypi:/home/ozn# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb7032c3f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
whoops! That is WRONG!
So, I disconnected the hard drive again. re-connented it to my laptop. I erased the partition table again, and re-created the partition table using fdisk on RPi! not on my laptop! This time, I took a short cut, and created the disk partition with ext4 directly.
I plugged the hard-drive to RPi and BINGO!
root@raspberrypi:/home/ozn# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
81 heads, 63 sectors/track, 191411 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000505b8
Device Boot Start End Blocks Id System
/dev/sda1 2048 976773167 488385560 83 Linux
Disk /dev/mmcblk0: 4025 MB, 4025483264 bytes
4 heads, 16 sectors/track, 122848 cylinders, total 7862272 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dbfc6
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 7862271 3869696 83 Linux
Disk /dev/sda: 500.1 GB, 500107862016 bytes
81 heads, 63 sectors/track, 191411 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000505b8
Device Boot Start End Blocks Id System
/dev/sda1 2048 976773167 488385560 83 Linux
The disk is now identified correctly on my laptop with Debian.
ozdeb@yenitiny:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
81 heads, 63 sectors/track, 191411 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000505b8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 976773167 488385560 83 Linux
conclusion (?)
My guess is that gparted in Debian Wheezy includes some nasty bug which is sometimes showing it's ugly face. I would report a bug if I had more solid evidence. But ... since I have only one 500GB hard drive, and I don't want to
risk the health of this hard drive reformatting it so many time, I will settle this with it. If you happen to bump into this post, and you have had similar problems with large SATA drives and partitioning on wheezy, I would be happy to know.
|
I have a 500Gb HDD formatted with ext3. I've connected it to my RPi using a USB->SATA enclosure and everything works just fine. Using ArchLinuxARM though. So I don't think there are any limitations on disk size for RPi.
| 1 |
I have a 500Gb HDD formatted with ext3
|
AD via LDAP - How can I return all ancestor groups from a query?
|
I am querying Active Directory via LDAP (from Java and PHP) to build a list of all groups that a user is a member of. This list must contain all least all groups (organizational-units optional) that contain groups the user is directly a member of. For example:
User1 is a member of GroupA, GroupB, and GroupC.
GroupA is a member of GroupD.
I am looking for a way to construct an LDAP query that will return GroupA, GroupB, GroupC, and GroupD all at once.
My current implementation is below, but I am looking for a more efficient way to gather this information.
Current Naive Implementation (In pseudo-code)
user = ldap_search('samaccountname=johndoe', baseDN);
allGroups = array();
foreach (user.getAttribute('memberOf') as groupDN) {
allGroups.push(groupDN);
allGroups = allGroups.merge(getAncestorGroups(groupDN));
}
function getAncestorGroups(groupDN) {
allGroups = array();
group = ldap_lookup(groupDN);
parents = group.getAttribute('memberOf');
foreach (parents as groupDN) {
allGroups.push(groupDN);
allGroups = allGroups.merge(getAncestorGroups(groupDN));
}
return allGroups;
}
|
Active Directory has a special search filter option that allows it to filter through chained objects, like nested groups. The capability is described here.
Here is an example of how to retrieve all users in a group, including nested groups:
(&(objectClass=user)(memberof:1.2.840.113556.1.4.1941:={0}))
where {0} is the DN of the parent group.
| 0.777778 |
Active Directory has a search filter option that allows it to filter through chained objects
|
Convert the_geom to text and then transform
|
I have this query that returns the_geom as text. However how could I also apply a transform to the same query. I can do this separately with the second example. Though I would like to do this to all the rows in my table, and in that example I copied the st_astext output into the transform query.
select sitename, st_astext(the_geom) from sites_tbl;
sitename | st_astext
Belfast A | POINT(145592 530021)
ST_AsText(ST_Transform(ST_SetSRID('POINT(145592 530021)'::geometry,27700), 4326));
|
This is a query I use to write out the LAT/LON of points from data stored in State Plane (feet):
select
residential_block_points.geoid_num
, st_x(st_centroid(st_transform(residential_block_points.geom, 4326))) as X
, st_y(st_centroid(st_transform(residential_block_points.geom, 4326))) as Y
from
residential_block_points
and you could add this data as new fields in the existing table:
ALTER TABLE "residential_block_points" ADD x double precision;
ALTER TABLE "residential_block_points" ADD y double precision;
UPDATE "residential_block_points" SET x = st_x(st_centroid(st_transform(residential_block_points.geom, 4326)));
UPDATE "residential_block_points" SET y = st_y(st_centroid(st_transform(residential_block_points.geom, 4326)));
| 0.888889 |
LAT/LON of points stored in State Plane
|
Is it possible to connect to already running session on Xubuntu 12.04 machine?
|
Previously I was connecting to my Xubuntu machine1 by running on it VNC server first and then using VNC client on machine2 to connect to machine1. The problem is that i had to login anew to my desktop, so I got new X11 session, I believe.
I would like to connect to my already running X11 session if it's running. Is it possible to do that? If yes, than what should I do?
Thanks in advance.
|
vncviewer allows to specify the display number in the connection string:
If you run the viewer with no arguments it will prompt you for a VNC
server to connect to. Alternatively, specify the VNC server as an
argument, e.g.: vncviewer snoopy:2
where 'snoopy' is the name of the machine, and '2' is the display
number of the VNC server on that machine. Either the machine name or
display number can be omitted. So for example ":1" means display
number 1 on the same machine, and "snoopy" means "snoopy:0" i.e.
display 0 on machine "snoopy".
Source: manpage for vncviewer
I could not find an explicit option in Remmina to specify display number, however:
By default, a VNC server will listen for connections from a VNC viewer
on TCP port "5900+N", where N is the "Display Number" (usually just
zero). So a VNC server setup for Display-0 will listen on TCP-5900,
Display-1 is TCP-5901, etc.
Additionally, the VNC server will listen for connections from a
web-browser on TCP port "5800+N", where N is as above. If you point a
web-browser to this port, the VNC server will automatically provide a
Java VNC viewer that runs right in your web-browser. This Java Viewer
will then exchange data with the VNC Server on the same ports a normal
VNC Viewer would use: "5900+N".
(source)
So I guess you may try to connect to a specific display by specifying port number in connection settings.
| 1 |
vncviewer allows to specify display number in connection string
|
Equivalent Key Signatures
|
I've noticed that a variety of pieces in the classical repetoire (certainly at least the piano repetoire), label what seems to be effectively the same key signature differently. That is, I am not aware of any differences in terms of key between a piece in "G Sharp major" and "A flat major" (or their equivalent minors). Is there any reason that sometimes a sharped key signature is used while at other times the equivalent flatted key signature is used?
As a related point, I have undoubtedly noticed the preference of certain "equivalent" key signatures over others. For example, one encounters "E flat" significantly more than "D sharp" and likewise "C sharp" significantly more than "D flat". Is there any particular reason for this, or is it simply a convention that has been handed down to use through musical history?
|
The short (and oversimplified) answer is: Because Ab Major has fewer flats than G# Major has sharps, and thus it's easier for musicians to read. This becomes especially apparent with keys such as D# Major, which has a double-sharp in it---the seventh note of the D# Major scale is not D, but Cx (that's "C double-sharp").
The longer and more accurate answer is that these keys are not in fact equivalent. Only in an equal-tempered tuning system do G# and Ab have the same pitch, Eb and D# have the same pitch, etc. That is, only in equal temperament do enharmonically equivalent notes actually have the same pitch. In every other tuning system, the enharmonically equivalent notes are slightly (but definitely noticeably) different from each other. If you've only been exposed to fixed-pitch instruments such as the piano and the guitar, this concept can be challenging at first, but violinists, wind, and brass players know that their intonation depends on the context of the key in which they're playing.
This in turn leads to different keys having different sonic characteristics. In the modern, equal-tempered era, we've mostly lost these distinctions, but to composers of two hundred years ago and more, the keys of Ab and G# didn't sound the same at all, and they would compose to a specific key in order to take advantage of its particular character.
Update: In response to Brian's comment, I thought it would be helpful to post an example. Here are links to YouTube videos, all three of which were posted by the same person, using the same synthesizer, all three playing Bach's Air on the G String. But each link uses a different tuning system:
Equal Temperament: http://www.youtube.com/watch?v=c6XkgNT20Eg
Just Intonation: http://www.youtube.com/watch?v=gdL8aPQUOk0
Pythagorean Tuning: http://www.youtube.com/watch?v=hq-SrgV7_Ow
| 0.777778 |
In equal-tempered tuning systems, enharmonically equivalent notes are slightly different from each other .
|
Shape of rotating rope (lasso problem?)
|
Let's take a wire or a rope. I usually do this with a chain or my scarf.
I fixate one end in my hand and apply rotation (by subtle movements of this endpoint like spinning a lasso). The rope gets into rotation and obtains certain bent shape:
Some part is missing because cellphone cameras ain't great for high-speed photos but I hope you can imagine all the scarf.
The question is: how can I calculate/predict this shape?
Although this problem doesn't seem that bizarre, I have never seen any solution. Nor I have found this question asked anywhere on internet... Must be because I just don't know how to formulate it without pictures.
Also by taking longer rope I get more than one bend:
I apoligize for the quality again. It is even harder to rotate this while taking picture. The form is not spiral, it is more like a shape in a plane that's rotating.
I'll be thankful for explanations, solutions, links or at least a correct formulation of this problem.
|
It will be some sort of hyperbolic function, and the force and length of rope will determine the frequency to predict the shape. The initial 'circle' at your wrist will define the constant force to explain the sin curve. This is not a very good explanation but if you were to define a hyperbolic function using a z axis it could be sinh z=(e^z-e^-z)/2.
| 1 |
The initial 'circle' at your wrist defines the constant force to explain the sin curve
|
Export Resolution in Adobe Illustrator
|
I've mainly used Photoshop before and only just picked up Illustrator a few days ago. Anyway, I used Illustrator to create lots of images (with transparent backgrounds) of different letters, each one filled with circles. More to the point, upon exporting as a .PNG, I noticed a resolution option. Me being the little derp that I am, I figured a larger resolution is always better, so I set this to high (300 ppi).
Upon importing the images into my project however, I realized that the images had become a lot larger than they should be. Upon tweaking the export resolution setting, I noticed that if I set this to low (72 ppi), the images come out as the expected size. I was just wondering how I should expect this to effect my drawings. If I were to keep the high resolution images I exported at 300 ppi, am I always going to be forced to reduce their size afterwards by a certain amount? Otherwise, should I always stick to 72 ppi in order to keep the size of the image the same and to avoid needing to re-size things later?
Image quality is not so important in this case, so there probably isn't much reason for me to use anything higher than 72 ppi anyway. Just for the sake of learning however, I thought this would be a good question to ask.
|
Illustrator has really no pixel unit, what ot does is it equates pixels with points. Sine a point is 1/72 th of an inch you get one pixel is one pixel with 72 ppi export. Otherwise illustrator will just assume your image in inches and act accordingly.
| 1 |
ot equates pixels with points
|
What client for DECwindows?
|
I have inherited a VAX system that was just migrated onto CHARON-VAX (VMS emulated on Windows) I can access it via ssh, but not with X. Anyone here familiar with DECwindows? is it X compliant? Or do I need a specific client to access it? Are there any "hidden" config files to me modified to enable X sharing?
|
DECWindows is X compliant. Try looking at the help for SET DISPLAY in particular /TRANSPORT /NODE /CREATE /SERVER /SCREEN e.g.
SET DISPLAY/CREATE/TRANSPORT=TCPIP/NODE=your.client.ip.address
RUN SYS$SYSTEM:DECW$CLOCK
RUN SYS$SYSTEM:DECW$DTTERM
In gerneral HELP on VMS is excellent.
I'm not sure if the DECW$DTTERM is correct dir sys$system:decw$*.* for a list of DECWindows binaries.
Chapter 19 of this document also explains how to setup and configure XDMCP for VMS.
We used to use hummingbird X (from a PC ) or VXTs to speak X to our VAXen but anything should be OK.
There may be more clues to getting things working here
| 0.666667 |
DECWindows is X compliant
|
Setfacl configuration issue in Linux
|
I am configuring a Linux Server with ACL[Access Control Lists]. It is not allowing me to perform setfacl operation on one of the directoriy /xfiles. I am able to perform the setfacl on other directories as /tmp /op/applocal/.
I am getting the error as :
root@asifdl01devv # setfacl -m user:eqtrd:rw-,user:feedmgr:r--,user::---,group::r--,mask:rw-,other:--- /xfiles/change1/testfile
setfacl: /xfiles/change1/testfile: Operation not supported
I have defined my /etc/fstab as
/dev/ROOTVG/rootlv / ext3 defaults 1 1
/dev/ROOTVG/varlv /var ext3 defaults 1 2
/dev/ROOTVG/optlv /opt ext3 defaults 1 2
/dev/ROOTVG/crashlv /var/crash ext3 defaults 1 2
/dev/ROOTVG/tmplv /tmp ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/ROOTVG/swaplv swap swap defaults 0 0
/dev/APPVG/home /home ext3 defaults 1 2
/dev/APPVG/archives /archives ext3 defaults 1 2
/dev/APPVG/test /test ext3 defaults 1 2
/dev/APPVG/oracle /opt/oracle ext3 defaults 1 2
/dev/APPVG/ifeeds /xfiles ext3 defaults 1 2
I have a solaris server where the vfstab is defined as
cat vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/vx/dsk/bootdg/swapvol - - swap - no -
swap - /tmp tmpfs - yes size=1024m
/dev/vx/dsk/bootdg/rootvol /dev/vx/rdsk/bootdg/rootvol / ufs 1 no logging
/dev/vx/dsk/bootdg/var /dev/vx/rdsk/bootdg/var /var ufs 1 no logging
/dev/vx/dsk/bootdg/home /dev/vx/rdsk/bootdg/home /home ufs 2 yes logging
/dev/vx/dsk/APP/test /dev/vx/rdsk/APP/test /test vxfs 3 yes -
/dev/vx/dsk/APP/archives /dev/vx/rdsk/APP/archives /archives vxfs 3 yes -
/dev/vx/dsk/APP/oracle /dev/vx/rdsk/APP/oracle /opt/oracle vxfs 3 yes -
/dev/vx/dsk/APP/xfiles /dev/vx/rdsk/APP/xfiles /xfiles vxfs 3 yes -
I am not able to find out the issue. Any help would be appreciated.
|
You need to enable acls on the mount point. Either remount with the acl option or reboot with the acl option in the fstab.
You need to first check if your kernel supports the acl option - otherwise, the mount may fail.
To check if acl was compiled into the kernel
cat /boot/config-`uname -r` | grep _ACL
The 'expected' output should be something like this ..
CONFIG_EXT2_FS_POSIX_ACL=y
CONFIG_EXT3_FS_POSIX_ACL=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_FS_POSIX_ACL=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFS_ACL_SUPPORT=m
To remount without reboot
mount -o remount,acl /xfiles
To mount with acl with a reboot/persistent
/dev/APPVG/ifeeds /xfiles ext3 defaults,acl 1 2
| 0.888889 |
remount with acl option or reboot with the fstab
|
What does mathematics have to do with programming?
|
I just started a diploma in software development. Right now we're starting out with basic Java and such (so right from the bottom you might say) - which is fine, I have no programming experience apart from knowing how to do "Hello World" in Java.
I keep hearing that mathematics is pertinent to coding, but how is it so? What general examples would show how mathematics and programming go together, or are reliant on one another?
I apologize of my question is vague, I'm barely starting to get a rough idea of the kind of world I'm stepping into as a code monkey student...
|
First off: I am a mathematician - a professional one (in that I get paid for doing maths). I am not a programmer. I do do some programming, but very definitely of the Cargo Cult variety (see first comment to http://tex.stackexchange.com/q/451/86 and my response) and nothing of the sort that would normally bring me to this site (indeed, I registered here to post this answer after seeing a link to it in the TeX chat room).
The summary of my answer is: Mathematics is Programming.
I recently got to teach a mathematics course to a non-mathematical group of students. They were the programming section. I thought this was fantastic! At last, I was going to be able to teach mathematics to people who already understood the basic ideas and who already had a rudimentary toolkit for doing maths. I was incredibly disappointed when I asked how many of them had actually written a program and got an answer somewhere between 0 and 1.
Before I go on, I should clarify a few things. There are areas of mathematics that concern themselves directly with programming and are to do with evaluating algorithms and classifying languages and such-like. I'm not talking about those. There is also a program which is trying to translate all of mathematics into a formal language that can be evaluated by a computer. This is a bit closer to what I'm talking about, but even so to focus on that would miss the main part of what I'm trying to say. The mathematics that I do and the programming that I do are almost completely unrelated by topic. The connection between them is on a different level.
Where I'd like to start is with the comment on the main question:
If that is doing math, then all human activity is a form of math. If that's the case then the word math doesn't have a useful meaning, because it can't be used to distinguish one activity from another.
Yes, that is doing maths. But "maths" is still a useful word because, as the song says, "It ain't what you do, it's the way that you do it.". I would say that I am doing maths when I am approaching something in a mathematical way. Sometimes, that is "hard core" mathematics: formulating definitions, proving theorems. Sometimes, it isn't. Sometimes, it's writing silly little programs so that my kids can learn their spelling words.
This is what mathematics helps me with when I program:
Abstraction This is probably the most important transferable skill from mathematics. By this, I mean the ability to strip away all the unnecessary stuff and focus on the important properties.
Perspective If I could only choose one thing that all my students were to learn, this would be it: The ability to change ones point of view to suit the problem. We commonly treat this in linear algebra with change-of-basis formulae (that lead to horrendous matrices and horrendous complications), but it is much more applicable than that. At heart, it is the idea that just because something has been presented to you in one fashion, that doesn't have to be the way you work with it. This separates ones view of the thing itself from the way it has been presented. This can be extremely practical: it is all about making something useful or efficient. If I have a list of vectors and it is more efficient to store them as a list of x-coordinates and a list of y-coordinates, so be it.
Form versus Function Leading on from the above; if a thing can be presented in many different ways then it is no longer fair to say that one particular presentation is the thing. To misquote that song again: "It ain't what you are it's what you do" that matters.
I could go on, but those are the ones that spring to mind.
Now, there are probably lots of (negative) reactions to what I've written so far. One will be "That's not maths, that's just good sense." (or bad sense) to which I refer to my remark above agreeing with the sentiment that "all human activity is a form of math". Another will be "That isn't the type of maths meant in the question.". This is almost certainly true and here I actually have a lot more sympathy with the person who said "At least I haven't touched the maths for 10 years,". He or she is wrong, of course, they have been doing maths for 10 years because whenever they wrote a program they were doing maths. They just didn't realise it. And here we get to the point about why I was delighted with the (sadly unrealised) possibility of teaching mathematics to students who were already programmers.
I do actually use some "real maths" in my programs. I recently coded a fun 3D shape explorer which involved using some maths to figure out the projections and other transformations that I had to apply to my data. I was mildly amused to find myself actually coding quaternions! But of course, the maths that was involved was trivial compared to the maths that I do when I'm working. It was "back of envelope" stuff. That type of maths, then I agree with the sentiment that you pick it up when you need it, and if you need something more complicated than you can find on Wikipedia then you find a real mathematician to do it for you. However, in order that you can pick it up when you need it then you need to have learnt something. That thing might not be anything you ever actually use, but having learnt that something makes it all the easier to pick up what you do actually use later in life. So this is where I disagree with Coder: you do need to learn some mathematics if you are ever going to use any mathematics and you need to learn it from the mathematical side (which doesn't mean proving theorems, by the way).
And so finally to the "Mathematics is Programming". You can learn all of these things from being a good programmer. And if you've learnt these things, you will find mathematics much easier because you will understand that when we talk about a vector in a vector space then it's just an instance of the class Vector which means that we can do all the things that Vector does to that instance: add, subtract, scale, and so forth. That's why I would love to teach mathematics to programmers. But, speaking as a mathematician, I would say that the first of these, "Abstraction", is easier to learn in mathematics than in programming because mathematics is the pursuit of abstraction. Whenever we see some behaviour our training is always to ask "What is it about that thing that makes it behave in that way? What if I took another thing that was similar, would it behave in the same way? How much of what that thing is would I have to lose for it to stop behaving like that?" (Taking this to the extreme leads to "centipede mathematics" - search for the term). But we don't do this with (just) "real world" objects (whatever they are), we do this with things that have already been abstracted.
This has gone on long enough, so let me close with one of the classic mathematician jokes:
A mathematician and a physicist both attended a seminar on some new model involving 24 dimensional space. Afterwards, they were discussing it and the physicist remarked: "That was really hard. I mean, how does one visualise 24-dimensional space?" to which the mathematician replied: "Oh, it's easy. Just visualise n-dimensional space and then set n = 24.".
Added 2012-03-2
There were quite a few comments on this answer expressing a variety of views. These have now been deleted by a moderator on the understanding that I would try to take into incorporate them (or respond to them) in my answer.
However, I'm not sure that I can. Reading those comments and the rest of what's on this page, I can only come to the conclusion that there is a huge misunderstanding as to what mathematics actually is. Moreover, I don't feel competent enough to explain it. Fortunately, someone has already linked to Lockhart's Lament so I'll defer the explanation to that. Whilst I might have put it differently (as I grew up in a scientific environment, I would have put more emphasis on the experimental nature of mathematics), I don't think I could put it better.
I do still think I can add something. As well as the misunderstandings as to what mathematics is, there are also misunderstandings as to what "doing mathematics" means. I see two almost contradictory stances:
Mathematics is about equations and formulas. So there's no need to study it because Wikipedia exists (this is almost the converse of Euler's apocryphal challenge to Diderot).
Mathematics is about theorems and definitions. So there's no need to study it as programs never prove anything (which is about as complete a fallacy as ... insert favourite fallacy here).
Whilst the two stances contradict each other, they end up in the same place: there's no point in a programmer learning any mathematics - and most assuredly not from a mathematician! After all, what do they know about anything? Anything that a programmer really needs to know can be found in Wikipedia, or cribbed off someone else.
Above, I described myself as a Cargo Cult Programmer. I bet most of you had a private giggle to yourself and thought, "Ah yes, I bet I know what your programs look like then.". You probably felt a bit smug and superior (though I'm sure you felt bad about feeling smug and superior).
What I've described just above is Cargo Cult Mathematics.
So when I say that you should learn a bit of mathematics to understand how mathematics works, I'm saying it for exactly the same reason as you might if you saw a bit of code that I'd written: "How much easier your life would be if you'd stop cut-and-pasting code from StackOverflow and learnt just a bit about how to do it properly.".
The most important thing, though, is that you should learn it from mathematicians. Why so? Here's an analogy. The language that I'm most adept at is TeX. (Says it all, really!). Now, suppose I want to learn a bit more about TeX and it just so happens that Don Knuth is in town and has offered to give some tutorials on TeX. Or I could just read about it on Wikipedia. Or maybe it's Perl and Larry Wall, or C# (is that the right one?) and Jon Skeet. It may well be that these people are not the best teachers, but they sure make up for it in the amount that they know!
And that's what mathematicians are. We're the people who write the actual language, who then write the libraries that you use. Of course, you don't have to know how to prove a theorem - you're not going to write a library! But if you know a bit about how we think, then it might help you understand why we wrote the library the way we did, and if you understand that it might help you make better use of it.
There is a middle ground between looking up equations on Wikipedia and proving the Poincaré conjecture, just as - to refer to Lockhart's lament - there is a middle ground between "I don't really know much about art, but I know what I like" and being Monet, and between "Where's the 'ANY' key?" and being Don Knuth. If you are still in university then you have an amazing opportunity to learn from people who are experts in their area and who - for some reason - are willing to spend their time explaining it to you.
The other point I wanted to expand on a bit was why as a programmer you should not be scared of learning a bit more mathematics. It's not the Deep Connections, nor the usefulness. It's that your ability to program a computer can directly help you learn mathematics. I just want to mention a few.
Understanding variables. So many people get confused by simple statements like "Let n be a natural number ...". Or "Let epsilon > 0". There are places in mathematics where it's important to remember the scope of a variable. These are all commonplace in programming. Learn to translate a mathematical statement into a program and you'll find it much easier to keep track of what's what.
The nature of proof. If you've ever written a test, or written a program to be used by someone else, then you understand the core of proofs. When you do that, you have to know that whatever the user puts in, you can deal with it (insert obligatory xkcd reference here). That's all a proof is! A demonstration that whatever the "user/universe" puts in, the statement will hold. Experimentalists will lean to the "If it works under normal circumstances, it's true" but programmers know that there is always that kid who will try Alt+G+Shift+ÅØÆ just to see what happens.
DRY. Sorry to break this to you, but we invented it, not you. We've been "not repeating ourselves" for millennia. That's why I have a copy of Euclid's elements on my shelves and it's still useful.
And there's more. If I knew a bit more about programming, I'd write a book called "Mathematics for Programmers" where the aim wasn't to teach "The mathematics that programmers should know" but "mathematics that everyone should know, but optimised for programmers". But I'll probably never know enough about programming to write it - unless someone offers to collaborate with me!
I'll leave it there. Probably if I thought more, I'd change what I've written; hopefully I'd explain it better. In a months' time I might even disagree with parts of it. If anyone wishes to argue further, or comment otherwise, probably best not to do so in the comments here. You know where to find me.
| 1 |
Mathematics is Programming: How do you translate a mathematical statement into a program?
|
Tables with a lot of rows - where should the delete option be?
|
Question regarding how to handle large tables with many rows:
Where should the delete option be? I see many examples placing the delete icon or text on the far-right of the row. Is this best practice? Is it always advisable to swap row delete to checkbox selection/batch delete?
If a table row has multiple available actions such as [Edit | Publish | View History ] etc, should these items be grouped into a single "Actions" row item?
|
why don't you just use check-boxes for deleting and arrows for actions, similar to this ->
keep is as clean as possible and it does not take much space
| 1 |
Use check-boxes for deleting and arrow for actions
|
Hydraulic brakes feel loose
|
I have a bike with Avid hydraulic brakes. The levers feel loose and at the end of pushing it, there is a "soft" feeling (like when V-brakes pads aren't adjusted properly).
As I understand, it's air inside the pipes. Is there something I can try to do to fix it without opening it / refilling liquid?
|
You need a kit to bleed that brake. Disc Brake Bleed Kit
It is one of those tools/kits that as an individual it is not worth buying.
Even on Amazon the kit it $40.
A (quality) bleed replaces the fluid.
| 0.777778 |
Disc Brake Bleed Kit
|
Interpolated FIR filter
|
I am confused about this Q&A : Interpolation by factor of 2
If my input signal
$$
x[n]= x0,x1,x2,x3
$$
then according to the threads explaination my $v[n]$ will be
$$
v[n]=x0,0,x1,0,x2,0,x3,0
$$
$x[n] \rightarrow$ zeropad $\rightarrow v[n]$
$v[n]\rightarrow$ LPF $\rightarrow y[m]$
My $y[m]$ is the output of LPF which removes aliases. So basically LPF transfer function is given as
$$
y[m] = v[n]*h[n]
$$
i,e. $y[m]=\displaystyle\sum_{n=0}^{\infty}h(m-n)v(n)$
So here $h[m]$ is my filter coefficients and $v[n]$ is my zero padded input signal...
so, if I multiply zero with my filter coefficients, then my output will also be zero...
If I send 10 input samples, after zero padding I will get 20 samples, out of which 10 will be zero....
So what is the use of getting zero as my output? Correct me if am wrong (I know I am wrong, but please give me some idea how zero padding & LPF is helping in this regard).
For FIR filter: $y(n)=h(0)x(n)+h(1)x(n−1)+....+h(N−1)x(n−N+1)$,
where $x(n)$ is the input signal,
$y(n)$ is the output signal,
$h(n)$ is the impulse response,
and $N$ is the filter length.
For simplicity, I am taking order $N=4$,and some random numbers
(time) n --> [ 0 1 2 3]
x[n]--> [ 2 4 6 8]
h[n]--> [.1 .2 .3 .4]
what is $y[2.5]$???
n-->[0 0.5 1 1.5 2 2.5 3 3.5]
v[n]-->[2 0 4 0 6 0 8 0 ] (after zero padding)
Lets calculate for $y[2.5]=h(0)x(2.5)+h(1)x(1.5)+h(2)x(0.5)+h(3)x(-0.5)$
so here $x(2.5)=x(1.5)=x(0.5)=0$
Please answer this to clear my confusion???
|
The interpolation lowpass filter computes a weighted sum of input samples, which results in the zero input samples being interpolated using the non-zero samples of the input signal. The $*$ sign is NOT multiplication but convolution!
EDIT: I'm adding a simple example to clear things up a bit. Let's consider the impulse response $h = [0.5, 1, 0.5]$ and a zero-padded input signal
$x=[1,0,3,0,5,0,3,0,1]$. The time index is denoted by $n$, and $n=0$ corresponds to the left-most values of $h$ and $x$. The output $y$ is the convolution of $(x*h)(n)$:
$$y(0) = h(0)x(0) = 0.5\\
y(1) = h(0)x(1) + h(1)x(0) = 1\\
y(2) = h(0)x(2) + h(1)x(1) + h(2)x(0) = 2\\
y(3) = h(0)x(3) + h(1)x(2) + h(2)x(1) = 3\\
y(4) = h(0)x(4) + h(1)x(3) + h(2)x(2) = 4\\
y(5) = h(0)x(5) + h(1)x(4) + h(2)x(3) = 5\\\vdots$$
This impulse response obviously performs linear interpolation of the zero-padded input signal.
| 0.833333 |
Interpolation lowpass filter computes a weighted sum of input samples
|
Does a terminator have a form of self-preservation or prohibition against suicide?
|
This weekend I was watching Terminator 2 (editor cut). In the end, after T-1000 is destroyed, Arnold asks Sarah and John to destroy him by melting and says "I cannot destroy myself".
So, what does this mean? The terminator cannot destroy himself unless it is absolutely necessary in order to succeed in his mission (like protect John?)?
In that case, what was the Terminator in part 1 going to do after the success of his mission (i.e. destroy Sarah)? Just live a long happy life and wait for Skynet arise?
Update:
I understand that this is not the exact Third law of Asimov, since the terminators definitely don't follow the First or Second law. Let's call it the law of self-preservation. Does terminator have a form of self-preservation to some point and the prohibition of suicide?
|
In the book version, the Terminator does indeed terminate itself.
However, regarding the movie: It says (1:30) "I cannot self-terminate" (emphasis by me). This is different from "I mustn't self-terminate" or "I may not self-terminate", which could be read as: It's not forbidden for it to terminate itself, but it simply does not have the ability to do it.
This is a bit argumentative, because from the fact that it knows how to terminate a T-1000 you may assume that it could terminate a hostile T-800 as well, and it seems intelligent enough to realise that it is a T-800 as well meaning that the same means would have to be taken to terminate itself than a different T-800.
A completely different (albeit quite far fetched) explanation might be that this is a way to ensure that its missions are carried out. From a model checking point of view all assignments could be solved most easily by self-termination (inaction is the safest option). So maybe this is a technical requirement all T-800 share by design.
| 1 |
The Terminator does indeed terminate itself
|
What happens if a player exiles Wurmcoil Engine when it dies with Mimic Vat?
|
My guess is that the player who controlled Wurmcoil Engine doesn't get the tokens because Mimic Vat's exile resolves first and the creature doesn't land in the graveyard. Am I correct?
|
If and when a Wurmcoil Engine dies and goes to the graveyard, its ability will trigger and go on the stack. If it was a non-token creature at the time it died, Mimics Vat will also trigger at the same time and go on the stack. The active player decides the order in which they are put on the stack, but either way, both effects will resolve unless countered. Meaning: for a non-token Wurmcoil Engine, 2 tokens will be created and it can be exiled with the Vat.
A Wurmcoil Engine (or a token copy thereof) that gets exiled neither gives tokens nor triggers the Vat. However, if you have a way to destroy or sacc a Wurmcoil Engine token before it is exiled, the token Engine will also create its 2 smaller tokens, though still not trigger the Vat.
| 1 |
If and when a Wurmcoil Engine dies, its ability will trigger and go on the stack
|
What would you call a former criminal who has been released from prison?
|
What do you call a former criminal who has served their sentence and been released from prison?
I thought of “convicted criminal”, but that might imply the person is still a criminal and/or serving a sentence.
Does “convicted criminal” fit this definition?
Are there other--better--words that are more accurate?
|
Another term you could use would be "ex-offender." A friend of mine works with recently released men and this is the term he uses.
| 1 |
Another term you could use is "ex-offender"
|
Can we put hash tables inside a hash table?
|
Can we link another hash table for each key, in a hash table?
My target is to have a very fast 2-d data structure to store cells in a spreadsheet.
I'll store "all columns within a row" in a hash table. Then do this to all 'r' number of rows. Next make the final hash table for rows and store all the 'r' number of hash tables in the new hash table. is this way efficient? or is there a better way?
|
How about
Map<String, Map<Integer,Integer>> asdf = new HashMap<String, Map<Integer, Integer>>();
But to be honest you should start with wrapping it inside an object. In this structure globally will be very inconvenient.
You could try this BiHashMap
public class BiHashMap<K1, K2, V> {
private final Map<K1, Map<K2, V>> mMap;
public BiHashMap() {
mMap = new HashMap<K1, Map<K2, V>>();
}
/**
* Associates the specified value with the specified keys in this map (optional operation). If the map previously
* contained a mapping for the key, the old value is replaced by the specified value.
*
* @param key1
* the first key
* @param key2
* the second key
* @param value
* the value to be set
* @return the value previously associated with (key1,key2), or <code>null</code> if none
* @see Map#put(Object, Object)
*/
public V put(K1 key1, K2 key2, V value) {
Map<K2, V> map;
if (mMap.containsKey(key1)) {
map = mMap.get(key1);
} else {
map = new HashMap<K2, V>();
mMap.put(key1, map);
}
return map.put(key2, value);
}
/**
* Returns the value to which the specified key is mapped, or <code>null</code> if this map contains no mapping for
* the key.
*
* @param key1
* the first key whose associated value is to be returned
* @param key2
* the second key whose associated value is to be returned
* @return the value to which the specified key is mapped, or <code>null</code> if this map contains no mapping for
* the key
* @see Map#get(Object)
*/
public V get(K1 key1, K2 key2) {
if (mMap.containsKey(key1)) {
return mMap.get(key1).get(key2);
} else {
return null;
}
}
/**
* Returns <code>true</code> if this map contains a mapping for the specified key
*
* @param key1
* the first key whose presence in this map is to be tested
* @param key2
* the second key whose presence in this map is to be tested
* @return Returns true if this map contains a mapping for the specified key
* @see Map#containsKey(Object)
*/
public boolean containsKeys(K1 key1, K2 key2) {
return mMap.containsKey(key1) && mMap.get(key1).containsKey(key2);
}
public void clear() {
mMap.clear();
}
}
And then create use it like this:
BiHashMap<String,String,String> bigBoard = new BiHashMap<String,String,String>();
| 1 |
How to wrap a key in an object globally?
|
Android Activity - Is it common to have a lot of code in one activity class?
|
My one activity seems to have grown quite a bit and I feel like that things should be more object oriented somehow. I think it happens because I am just learning and therefore keep adding different views, to see things working. Before I know it, it has gotten big.
I have subclassed things like LinearLayout, ViewFlipper, Button, TextView, etc etc and thought that providing constructors for these classes that take arguments like textsize, font, layout parameters, background color etc etc might help the situation and actually might lend itself more towards OOP common design paradigms. Doing it this way of course means that my constructor will have tons of arguments.
I was wondering if I could get some feedback on this approach above: should I use my subclasses to my advantage for a more OOP design, or do some activities just naturally have lots of code? Thanks!
|
I have subclassed things like LinearLayout, ViewFlipper, Button, TextView, etc etc and thought that providing constructors for these classes that take arguments like textsize, font, layout parameters, background color etc etc might help the situation and actually might lend itself more towards OOP common design paradigms.
That's not a good idea. Widgets are not designed to be extended as a means of configuration. Moreover, it is not necessary, as all the things you list can (and should) be defined in XML layout resources.
do some activities just naturally have lots of code?
Some activities are responsible for lots of code. You are welcome to pull some of that logic out into other classes, but they would not necessarily be subclasses of widgets. Your Adapters, various ...Listeners, AsyncTasks, Loader.Callbacks, and so forth can frequently be pulled out into separate public classes, rather than having your activity implement a zillion interfaces or have bunches of inner classes.
| 0.777778 |
Do some activities just naturally have lots of code?
|
how to make blocks like "redstone" working in a minecraft-like game when the block is very far-away from your character
|
I'm working on a 2D minecraft-like game, I use chunks to save my world and each chunk has 128*128 blocks in it.
And infinite chunks can create an infinite world.
Memory should never be infinite and only several chunks near the character shown in the screen can be loaded into memory. How can I handle logic based blocks like red stone signals when they are in chunks far away and so not loaded in memory?
|
In Minecraft, circuits in unloaded chunks simply do not work. Especially with pistons and other ways of interacting with the environment, it could get expensive quickly to keep far-away circuits running in an infinite world.
I see three main possible choices for your game:
Keep all chunks loaded. This is just a big nope.
Keep nearby chunks loaded. For chunks too far away, save the state of the chunk. When coming close to the chunk, load the state again.
This means that the circuit will continue where it left off. Complex circuits won't break this way.
On the downside, the circuit won't run when the player is too far, though this is generally acceptable.
Store active components separately. For chunks too far away, unload the terrain data but keep circuitry active.
This will cause things such as sensors, timers, etc... working all the time.
Bigger resource hit. An infinite world means possibly infinite circuits constantly running.
This would only work if circuits cannot interact with the terrain, or if they can only interact with the terrain within proximity of the player.
Of course there may be other ways to work around this, but those are likely going to be some form of hybrid between these ideas.
| 1 |
In Minecraft, circuits in unloaded chunks simply do not work.
|
Can I disable the default calendar app notifications?
|
This strikes me as a bug since the behaviour is incredibly consistent, but perhaps someone here can help me.
I want to use the google developed calendar app as my main calendar app. My phone (a Galaxy S2) came with a samsung developed calendar app (both very conveniently named "Calendar"). At this point, I simply want to disable the samsung calendar app from displaying any sort of notifications (since the google app also displays notifications and I want to use that app).
I have been able to do this by going to settings->Notifications in the samsung app and toggling to "Off".
However, as soon as I restart the device, the notifications are back on their original settings. Anyone else experience this? Anyone know how to make the settings stick?
EDIT: I notice the notification settings of the google developed app (sound, default reminder time, popup) are also not sticking after reboot. Is my device broken? It seems to only be for calendar. Gmail and other apps hold their settings fine.
EDIT 2: Ok, so disabling the samsung app allows my google app calendar settings to stick after reboot. So looks like that is what I will be doing. Anyone know how I can change the vcs file association to this app now?
|
I've same issue on my S2.
The problem is a conflict between Google Calendar & Samsung stock calendar.
The second one overwrite settings of Google Calendar.
Only solution is disable it and use Google Calendar.
| 0.888889 |
Google Calendar & Samsung stock calendar
|
How do I know I'm running within "go test"
|
When I run "go test", I want to use a different configuration file. How do I know within my code if I'm running within a test context or a normal context? Is there some sort of environment variable to check?
|
Code examples would help. But from your question it sounds like you've hardcoded a path to a config file somewhere when you probably wanted to pass it in instead.
Change the function you are testing to take a parameter defining the config file and then in your test code pass a different path in than you use in the non test code. It's bad practice for your code to have a different path when testing vs production.
| 0.888889 |
How to pass a path to a config file
|
How can I keep Mail.app's archive from becoming too big?
|
I'm trying to reduce my hard drive space used to prepare for a move to an SSD. I've got a wonderful application called DaisyDisk that allows me to visualize data segments on my hard drives.
I have three internal drives, and for the time being I'd just like to slim down the size of my startup disk, so I can move it to a smaller SSD.
By far the largest segment of my hard drive is a section under Macintosh HD/Users/joelglovier/library/Mail/V2/Mailboxes. This directory is over 75GB. You can see the visualization from DaisyDisk here: http://cl.ly/E7OJ
I found this directory before, when trying to slim down my hard drive, and simply deleted it's contents, then changed my settings in Mail.app to not archive attachments, thinking that would resolve the issue.
However, some months later this directory has again creeped up to a ginormous size.
Can anybody please help me understand what this directory is for, and how to permanently reduce it's size - via Mail.app settings, or whatever I need to change to stop it from becoming so huge.
Thank you!
Note: I'm on OSX Lion 10.7.3 using Mail.app ver 5.2.
EDIT: SO I dug through the files in the directory in question. There was one particular mailbox in /Library/Mail/V2/Mailboxes called "Recovered Messages (account name).mbox" which contained a very strange subdirectory structure of a single email duplicated thousands of times under different subdirectory structures. For example, there was a subdirectory in it that had /1, /2, /3, etc., and each one of those directories had /attachments and /messages. The /attachments on each had hundreds of subdirectories each containing this one same attachement from a particular email, and the /messages under each had hundreds of copies of the email all with different numerical file names. But the weird thing is ALL were from the same exact email.
|
I was having problems trying to migrate my email data when i updated to lion. i eventually gave up trying and just moved my /Library/Mail folder to my desktop and re-added all my email accounts. when i started to delete the Mail folder i realized it was 150 GB.
For the last 3 years I would notice that emails i had sent years ago were reappearing in my sent folder. Its funny that someone would mention using a specialized service to send large files, because that's exactly what i was doing. I was sharing files on my idisk. However the emails were not just limited to my idisk shares, there were also emails without attachments that would keep appearing in my sent box.
i contacted some of the people from these recurring messages and they confirmed that they had not received any duplicates. so i just shrugged it off. Little did i know this glitch was eating away at my hard drive. I had noticed that no matter what i did, my hard drive was always gradually decreasing.
i reinstalled more times than i can count, but for the past 6 years i have always synced my mail accounts with my dotmac/mobileme account. I realize now that it would have been better to re-add my mail accounts manually after a fresh install. i don't believe that would have solved everything, but it would have slowed down the rate of which my hard drive was filing up.
I see now why Apple has abandoned their mobileme platform and gave the mail app a major overhaul. Hopefully the issues are resolved now.
For me, the strategy to manage Mail is to not migrate in the data and start over regularly so I can see what syncs down from the cloud and what mail came from older Macs.
| 1 |
How do I migrate my email data to lion
|
Adding variables to the model one by one, or at the same time
|
What are the benefits of adding the variables into a model one by one, as compared to adding them all at the same time?
As I see in most research, the first model that is tested is consisted of all the control variables, then in the second model the first predictor is added, then the second one, and so on, until all predictors are in the model.
Are there any benefits in using this approach, or would it be ok to have just do two models - one with just the controls, and one with controls + all other predictors.
(p.s.) - am interested in this with regards to logistic regression
|
This is a habit that stems from linear regression, where this sequence of models can be interpreted as ways of estimating indirect effects. Unfortunately this trick does not generalize to non-linear models, like logistic regression (e.g. Buis 2010). Still the habit persists, as you have observed. Unless you are interested in direct an indirect effects, I would just avoid all the complexities involved with comparing non-linear models and just report one model. If direct and indirect effects are of interest then you can choose between different methods, some references are given below:
M.L. Buis (2010). Direct and indirect effects in a logit model. The Stata Journal, 10(1), pp. 11-29.
http://www.stata-journal.com/article.html?article=st0182 (free)
Hicks, R. and D. Tingley (2011). Causal mediation analysis. The Stata Journal 11(4), 605-619.
http://www.stata-journal.com/article.html?article=st0243
Kohler, U., K. B. Karlson, and A. Holm (2011). Comparing coefficients of nested nonlinear probability models. The Stata Journal 11(3), 420-438.
http://www.stata-journal.com/article.html?article=st0236
Sinning, M., M. Hahn, and T. K. Bauer (2008). The Blinder-Oaxaca decomposition for nonlinear regression models. The Stata Journal 8(4), 480-492.
http://www.stata-journal.com/article.html?article=st0152 (free)
| 0.777778 |
Direct and indirect effects in logit models
|
Macbook Pro is unresponsive for about a minute when waking up. Is this normal?
|
Whenever I wake up my 2012 Macbook Pro after it's been asleep for a few hours, the screen turns on, but it is unresponsive for about a minute. During this time, the mouse cursor does not move at all whenever I touch the trackpad and the computer is unresponsive to the keyboard. I also see the WiFi icon in the taskbar act as if it is searching for WiFi (the WiFi icon is gray, but each bar turns black consecutively from bottom to top repeatedly). The computer is finally responsive after a minute or so and the WiFi icon stops searching.
Is this normal behavior for a Macbook Pro when waking? If not, what could a potential issue be?
My computer is a 2012 Macbook Pro 13 in, non Retina Display.
|
Actually it may be coming out of hibernation.
Do you ever get a milky white screen with a progress bar? That then goes away and you can see the screen but not operate anything?
It may be coming out of hibernation.
| 1 |
Do you ever get a white screen with a progress bar?
|
What do $0^n$ and $1^n$ mean in cryptography?
|
Let $f$ = $\{f_k\}$ be a pseudorandom function family.
Let $G(x)$ be a pseudo-random generator such that:
$G(x) = f_x(0^k)f_x(1^k)$ where $k=|x|$.
I don't understand the meaning of $1^n$ and $0^n$, and the differences between them, in that context.
What do they represent?
What is the special role / effect they have on the above context? And how?
Why $1^n$ and $0^n$, and not other combinations?
|
$0^n$ means a string of $n$ zeros (the $n$-bit string that is all zeros). $1^n$ means a string of $n$ ones.
Why were these used? There's nothing special about $0^n$ or $1^n$, in this context. They could have used any pair of two constant $n$-bit strings, as long as the two strings were not the same. $0^n$ and $1^n$ is a convenient choice of two strings that are different, but they could have chosen any other pair (as long as they're not both the same) and that would have worked fine, too.
| 0.333333 |
Why were used to choose a string of $n$ zeros?
|
Variations in the pronunciation of "the"
|
Although there are rather simple rules determining the pronunciation of "the", native speakers quite often deviate from these rules (including, e.g., TV shows). According to the Longman Pronunciation Dictionary,
The EFL learner is advised to use [ðə] before a consonant sound (the
boy, the house), [ði] before a vowel sound (the egg, the hour). Native
speakers, however, sometimes ignore this distribution, in particular
by using [ðə] before a vowel (which is in turn usually reinforced by a
preceding ʔ), or by using [ði:] in any
environment, though especially before a hesitation pause. Furthermore,
some speakers use stressed [ðə] as a strong form, rather than the
usual [ði:].
My question is: when native speakers use [ðə] instead of [ði] before a vowel sound, do they do it on purpose or accidentally? If it is on purpose, how do they (typically) decide which pronunciation to use? What is a valid reason to use [ðə] before a vowel sound?
|
To summarize the discussion here and elsewhere:
In contrast to the pronunciation-based distinction between a and an, the pronunciation of "the" is not strictly determined by the pronunciation of the following word. The guidelines in, for example, the Longman Pronunciation Dictionary are in fact just guidelines for non-native speakers. If one listens closely to native speakers, it becomes obvious that [ðə] and [ði] are chosen relatively freely, irrespective of the following word. Hence, it is interesting that people who learn English as a foreign language are usually told by teachers and textbooks that the pronunciation of "the" follows the same strict rule as the distinction between a and an. This misconception can even be found on English language sites such as here.
A similar answer was given here.
| 0.777778 |
The pronunciation of "the" is not strictly determined by the pronunciation of the following word
|
Two different analytic curves cannot intersect in infinitely many points
|
A curve in Euclidean space $\mathbb{R}^n$, $n \geq 2$ is $analytic$ if the coordinates of its points $x= x_{1},...,x_{n}$ can be expressed as analytic functions of a real parameter $x_{i}=x_{i}(t)$, $i=1,...,n$ and $\alpha \leq t \leq \beta$ and the derivatives $x'(t_{0})$ do not simultaneously vanish for any $t_{0} \in [\alpha, \beta]$.
I search for a proof of the following fact:
If the set of intersection points of two analytic curves is infinite, then these curves coincide.
Can we prove the same as above if we relax the condition that the coordinates are analytic to the condition that the coordinates belong to the class $C^{\infty}$?
Edit: Thanks to below remark by Ramiro, to obtain the above implication, we have to assume that any two curves $K_{1}, K_{2}$ as in the question are such that $K_{1} \cap K_{2}$ is not another analytic curve.
2nd edit: As suggested Peter, we can reformulate our question as follows:
Consider two immersed curves which are parameterized real analytically on compact intervals. If they have an infinite number of different intersection points, then their union is again a real analytic immersed curve.
|
Wrong: $t\mapsto \binom{t}{\sin(t)}$ and $t\mapsto\binom{t}{\cos(t)}$.
Edit: Grzegorz pointed out that $t$ is in a compact interval $[\alpha,\beta]$.
Under this assumption the statement is correct.
Proof: Let $f,g:[\alpha,\beta]\to \mathbb R^n$ be the two real analytically parameterized curves which intersect in $f(t_i)=g(t_i), i=1,2,\dots$ different points. Then the $t_i$ have accumulation points in $[\alpha,\beta]$, thus $f$ and $g$ coincide on $[\alpha,\beta]$.
In the $C^\infty$ case the statement is wrong: Let $[\alpha,\beta]=[0,1]$ and consider
$$f(t) = \binom{t}{e^{-1/t^2}\sin(1/t)},\qquad g(t)=\binom{t}{0}.$$
2nd edit: Noam pointed out that my proof above was not conclusive.
So let me try again: Suppose that $f(t_i)=g(u_i)$ for sequences of distinct points.
The $t_i$ have accumulation an point $t$ and the $u_i$ have an accumulation point $u$.
By continuity, $x=f(t)=g(u)$. Now we change both parameterizations as follows:
Choose a line $r\mapsto x + r.v$ for a vector $v$ such that both curves are transversal to the hyperplane $v^\bot$. Since both curves are immersions (if I understood the question right),
such $v$ exists. Now consider the orthogonal projection of both curves onto this line. In a neighborhood of $r=0$ these are real analytic diffeomorphisms, so their inverses gives us new parameterizations of both curves in the parameter $r$. There are still infinitely many intersection points of the two curves near $x$, but these intersections happen now at the same
parameter values $r_i$ with $r_i\to 0$ without loss. Now my proof from above applies.
I hope that I did not overlook something else this time. Many thanks for pointing out my mistakes.
3rd edit: I overlooked again something (Thanks SJR and Ramiro). So what I proved is:
The intersection of the two curves contains an open interval in each curve. Note that each curve, as an immersion, is locally a real analytic submanifold.
4th edit: Grzegorz, to the new question you posed in the comment, the following comes to my mind:
By a theorem of Whitney, any closed set in $\mathbb R^n$ is the zero locus of a smooth function. So take a set in $\mathbb R$ like the Cantor set which in uncountable, and a smooth function on $\mathbb R$ vanishing exactly on this set. The graph of this function and the $x$-axis are two $C^\infty$-curves which intersect in this set.
What do mean by: $K_1\cap K_2$ is not $C^\infty$?
5th edit: Grzegorz, instead of excluding Ramiro's example in your edit of the question,
you could reformulate as follows:
Consider two immersed curves which are parameterized real analytically on compact intervals.
If they have an infinite number of different intersection points, then their union is again a real analytic immersed curve.
| 0.666667 |
Wrong: Let $f,g:[alpha,beta]to mathbb R
|
What are the best tips for saving money as a university student?
|
What are the best tips for saving money as a university student?
I will be attending university this coming semester and am planning on maintaining a sustainable financial situation right now, but would like any good tips or suggestions to saving money as a student.
|
Try to cash flow as much as you can. You can work and go to school, if you replace playing beer pong with a job you'll be in a lot better off at graduation, grade wise and debt wise.
Make a budget, for each month and for each semester, plan cut cost accordingly.
Used books, sometimes even the next to recent version.
Read this book for more info Debt-Free U: How I Paid for an Outstanding College Education Without Loans, Scholarships, or Mooching off My Parents
| 1 |
Debt-Free U: How I Paid for Outstanding College Education Without Loans, Scholarships or Mooching off My Parents
|
Customising SharePoint 2007 Survey Pages with pagebreaks
|
SharePoint 2007 Standard
I have a survey, which has been broken up with page breaks. Is there a way to add introductory content to each segment? As best as I can tell, there isn't a new ASPX page for each section, so a change to the basic form will show on all pages.
Any ideas appreciated.
|
You could achieve it by generating introductory content on the client side as demonstrated below.
Steps
1) Add CEWP into Survey Edit Form page
2) Insert the following content into CEWP
<h2 id="questionSummary">Please specify your development skills</h2>
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
(function(){
var questionSummary = $("#questionSummary");
var fieldName = getParameterByName('FirstField');
switch(fieldName){
case "Skills":
questionSummary.append("Please specify your development skills");
break;
}
})();
</script>
Key points:
during page navigation in Survey form, query string parameter
FirstField is appended
function getParameterByName is used to retrieve query string
parameter, in our case FirstField
Results
Note: The specified example is for SharePoint 2013 but the same
approach could be applied in SharePoint 2007
| 0.666667 |
Add CEWP to Survey Edit Form page
|
When suggestion is rejected in Improve/Edit, why are reviewer's stats not displayed?
|
When a reviewer picks "Improve" and indicates that suggestion wasn't helpful, an edit gets rejected. In suggestion record page, when one clicks (more), only stats for Community user and suggestor are shown. What is the reason that reviewer stats aren't displayed in this case?
An example of such an edit is here:
gnat reviewed this 17 hours ago: Edit
Community♦ reviewed this 17 hours ago: Reject
Conflicted with a subsequent edit.
When one clicks (more), page shows only one reviewer:
Reviewer Stats
Community has approved 1219 edit suggestions and rejected 303 edit suggestions
I wonder because in case of straight rejection, without Improve, both reviewer stats are shown. In this example, with two straight rejects, clicking (more) shows both reviewers:
Reviewer Stats
gnat has approved 392 edit suggestions and rejected 233 edit suggestions
KeesDijk has approved 47 edit suggestions and rejected 14 edit suggestions
|
You didn't approve or reject the suggested edit, you replaced it with your own (through the Improve option). This isn't quite the same as voting to reject the edit; rather it is a new edit that is seeded with the suggestion.
Community then rejected the original suggestion, because your edit replaced it.
| 1 |
You didn't approve or reject the suggested edit, replaced it with your own .
|
How to find the distance using dot product from point $A$ to the line through $B$ and $C$?
|
How to find the distance using dot product from point $A$ to the line through $B$ and $C$?
The points are $A = (2, -6, 1)$, $B = (3, 4, -2)$ and $C = (7, -1, 5)$.
I have tried this method: $$d=\frac{||BC \times BA||}{||BC||}$$
Please tell me how to find the distance using dot product.
|
HINT:
use the property that v1.v2=0 , if v1,v2 are perpendicular.
OK.so, let A(2,-6,1); B(3,4,-2); C(7,-1,5) be given.
Now lets find BC vector, which comes BC(4,-5,7).
Now suppose a point P(x,y,z) in between B and C.and draw perpendicular from A to this point P .
We can find AP vector which is AP(x-2,4+6,z-1).
now dot product of AP and BC is zero. From here you get P.Once you have P. The |AP| is the required distance
| 0.666667 |
v1.v2=0 if v1,v2 are perpendicular
|
MVC 4 and JsonResult format
|
have a problem with the result format of this code
public JsonResult getCategorias(int? id)
{
var res = from c in db.Categorias
where (( id.HasValue && c.CategoriaPadre == id.Value) || (!id.HasValue && c.CategoriaPadre == null))
select new { id = c.Id, label = c.Descripcion };
return this.Json(res, JsonRequestBehavior.AllowGet);
}
this return a json:
[{"id":21,"label":"Marketing3"},{"id":22,"label":"Marketing4"}]
But i need a json with this format:
{"21":"Marketing3","22":"Marketing4"}
What can i do?
Thanks a lot and sorry my english.
|
You can also use this:-
public static KeyValuePair<string,string> KeyValue(YourClass obj)
{
return new KeyValuePair<string, string>(obj.id, obj.label);
}
Before call
Json(result.ConvertAll(i => KeyValue(i)), JsonRequestBehavior.AllowGet);
| 0.777778 |
Public static KeyValuePair<string,string> KeyValute(YourClass obj
|
how to change my hostname?
|
My hostname is localhost, reported by hostname command, and terminal prompt root@localhost:~#.
How can i change it to mismis.com with mismis alias? and what is the proper configuration.
I confused after reading some articles on web.
My /etc/hosts:
127.0.0.1 localhost
127.0.1.1 srv345.myweb.com srv345
178.162.231.61 janstone.mismis.com janstone
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
|
The system hostname is configured in /etc/hostname. A change made to this file will take effect after reboot.
At boot time the string in /etc/hostname is loaded into the kernel using the hostname command. If you edit /etc/hostname then you should also set the system hostname manually using the hostname command.
sudo hostname mismis
Note that in Debian and Ubuntu the system hostname is the short hostname, not a fully qualified domain name.
If the machine has a static external IP address ADRS then this address and the hostname should appear on a line in /etc/hosts, as follows.
ADRS <hostname>
If the machine has a static fully-qualified domain name then this should appear first after the IP address on the line and the short hostname should follow it.
ADRS <fully-qualified-hostname> <short-hostname>
In the present case, assuming that the external IP address is 178.162.231.61 and the desired canonical hostname is "mismis.com", the /etc/hosts line should look like the following.
178.162.231.61 mismis.com mismis
If the machine has no static external IP address, but gets assigned addresses dynamically via DHCP, for example, then 127.0.1.1 should be used instead.
127.0.1.1 mismis.com mismis
or
127.0.1.1 mismis
In /etc/hosts, any IP address should appear on at most ONE line. On that line the first domain name that follows the IP address is the canonical hostname associated with that IP address, and any subsequent domain names are aliases for the canonical hostname.
| 1 |
System hostname is configured in /etc/hostname
|
Comment before or after the relevant code
|
Assuming a comment won't fit (or can't go) on the line it applies to, should one write the comment before the code or after?
Well, wherever future readers will best understand the comment's scope. In other words, wherever most programmers/scripters put such comments.
So where do most programmers/scripters put a comment: before or after its code?
If your answer applies only to specific languages, please indicate which.
And if you can cite an accepted spec or guide that supports your answer, so much the better.
|
So where do most programmers/scripters put a comment: before or after its code?
In many years of programming using a variety of languages, I don't recall seeing any code in any language where a comment is placed on a new line after the code to which it refers. In the US, at least, the de facto standard is commenting either before the code or on the same line following the code. Writing your comments after the related code invites a drug test, a psychiatric evalutation, and/or a date with a pair of pliers and a blow torch.
The only exception I can think of is a comment marking the end of a previously commented section, like this:
// BEGIN CRITICAL SECTION
lock(&myMutex);
doSomeThreadUnsafeStuff();
unlock(&myMutex);
// END CRITICAL SECTION
Jef Raskin wrote a well-considered essay on comments that's worth a read. He doesn't say whether he puts his comments before or after the code, but he does say that he never puts them inline, and I'd bet a lot of money that he doesn't put them after either.
| 0.888889 |
Commenting before or after a related code
|
Kyoto Cabinet / Berkeley DB : Hash table size limitations
|
I am having a hard time storing hundreds of millions of key/value pairs of 16/32bytes with a hash array on my SSD.
With Kyoto Cabinet: When it works fine, it inserts at 70000 record/s. Once it drops, it goes down to 10-500 records/s. With the default settings, the drop happens after around a million records. Looking at the documentation, that is the default number of buckets in the array, so it makes sense. I increased this number to 25 millions and indeed, it works fine until around 25 millions records. Problem is, as soon as I push the number of buckets to 30 millions or over, the insert rate is down to 10-500 records/s from the beginning. Kyoto Cabinet is not designed to increase the number of bucket after the database is created, so I cannot insert more than 25 millions records.
1/ Why would KC's insert rate get very low once the bucket number exceeds 25M ?
With Berkeley DB: The best speed I got is slightly lower than KC, closer to 50000 record/s, but still ok. With the default settings, just like KC, the speed drops suddenly after around a million records. I know BDB is designed to extend gradually its number of buckets. Regardless of that, It tried to increase the initial number, playing with HashNumElements and FillFactor, but any of these attempts made the situation worst. So I still cannot insert over 1-2 millions records with DBD. I tried activating non-synchronized transactions, tried different rates of checkpoints, increased caches. Nothing improves the drop down.
2/ What could cause BDB's insert rate to drop after 1-2 million inserts ?
Note: I'm working with java, and when the speed is dropping, the CPU usage lowers to 0-30% while at 100% when working at correct speed.
Note: Stopping the process and resuming the insertion changes nothing. So I don't think that is related to memory limits or garbage collection.
Thx.
|
Below is how I managed to store billions of records despite the writing limitations encountered with KC.
With much effort, I still haven't solved the problem for neither Kyoto Cabinet nor Berkeley DB. However I came up with an interesting workaround using Kyoto Cabinet.
I noticed I cannot write more than 25M records on one KC file, but read has no such limitation −it is always fast, regardless of the size of the database. The solution I found is to create a new KC file (a new database) for every 25M new records. That way the reading happens on many KC files and is still fast, and the writing happens only on the last created file and is fast as well. Only remaining problem was to allow update/deletion of the records on the previous files. For that, I copied the SSTables approach, which is :
All the 0 to N-1 files are read-only, file N is read+write.
Any insert/update/deletion is written in file N.
Reads look into files N to 0, and return the first-seen/last-written insertion/update/deletion.
A bloom filter is attached to each file to avoid accessing a file that doesn't have the wanted record.
As soon as file N reaches 25M records, it becomes read-only and file N+1 is created.
Notes :
Just like with SSTables, If a lot of updates/deletions are performed, we might want to perform compaction. However contrary to SSTables, compaction here doesn't require to rewrite the file. Outdated records are simply removed from the KC files, and if a KC file gets very small, it can be either removed −reinserting the records in file N− or reopenned for new insertions −provided the next files are compact.
A deletion does not delete the record, but write a special value that identifies the record as deleted. During compaction, deleted records are removed for real.
Checking if a record exists usually requires to look into the database. Thanks to the bloom filters, most of the negative answers can be given without any disk access.
| 0.666667 |
How to store billions of records without a KC file
|
Is IP restriction enough or should I SSL my web authentication?
|
I want to connect to my home install of phpmyadmin. I restricted the connection for this to my 2 IPs.
But I don't really understand this whole OSI layering. I do know that the IP is saved in the second layer, and I guess that the IP restriction will just look for this layer.
Is it possible to read out the password from the 7th layer, even if I have an IP restriction?
|
The OSI layers are a model which was not meant for IP but for an older, competing protocol. IP does not fit well in that layer, especially when envisioning SSL (which must be both in layer 6 and layer 4, which is logically impossible). These layers are just confusing, so don't use them.
IP restrictions means that your server will refuse to pursue connections which are tagged with the wrong IP address. This does not protect the data against eavesdroppers.
Let me take an analogy: suppose that your connections are good old letters, with a destination address, and a sender address. The envelopes are transparent. The equivalent of IP restrictions is when the recipient refuses to even open, let alone respond to, envelopes which are not tagged with a "known sender" address. But nobody guarantees that the sender address written on the envelope is genuine; sending a letter with a fake sender address is easy. Of course, if I, an attacker, send a letter with your address as alleged sender, I won't see the response (unless I plunder your mailbox). But the recipient may have already have acted upon the letter contents, believing them to originate from you. Moreover, since the envelopes are transparent, every postman may read the contents of the letters.
For real protection, you need opaque letters, entrusted to armed conveyers in an armored vehicle. In the Internet world, this is called SSL (aka HTTPS in a Web context).
| 0.666667 |
HTTPS in a Web context
|
Create an "All Posts" or "Archives" Page with WordPress 3.0?
|
I'd like to create an "All Posts" page on the Ocean Bytes blog that contains an unordered list of all Titles of the posts to date, with each title hyperlinking to its blog post.
There appear to be several plugins that do something like this, but most do not list Wordpress 3.0+ as supported yet, or they want to subset the blog postings by Year and then Month which is not desired.
Any suggestions for the "best way"?
Thx.
|
Create a new template file and do this as the loop:
query_posts( array( 'posts_per_page' => -1, 'post_status' => 'publish' ) );
if( have_posts() ):
echo '<ul>';
while( have_posts() ):
the_post();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
endwhile;
echo '</ul>';
endif;
wp_reset_query();
Then just use that template for a page and it'll automatically generate the page. Check out the codex page for query_posts() for more information on how to change the query.
| 1 |
Create a new template file for query_posts
|
How to get the 10-5 most dominant frequency in an audio signal
|
I have this wav file that I recorded using my laptop, It contains the sound of a G chord of a guitar. Since the guitar have 6 strings the sound should contain different frequencies I want to determine the top 10 most dominant frequency in the signal.
[X, Fs] = wavread('chordG.wav');
freq = fft(X);
plot(abs(freq)):
I dont know how to proceed after that it shows the graph of the frequency but I dont know how can I extract the values in the graph.
Your answer would be very much appreciated :)
|
There are research papers on the topic of automatic polyphonic chord estimation/transcription on MIREX (http://www.music-ir.org/mirex/wiki/2014:Audio_Chord_Estimation). Also a book and a thesis by A. Klapuri.
| 1 |
Automatic polyphonic chord estimation/transcription on MIREX
|
How can I better protect my LAN from Internet Hackers
|
My computer is connected to my Netgear router which is also the switch for my network, this in turn is connected to my cable modem which is just a bridging device.
My router is blocking scans and fragmentation attacks but I believe its processor and RAM is getting hammered doing so because my LAN speed is very slow both wired and wireless and on multiple machines.
Would adding a hardware firewall between my ISP bridge and my Router help or is there a better solution to dealing with these attacks?
|
Placing a second firewall in front of your current one would offload some of the processing of scans/probes/attacks and free up CPU cycles on your Netgear router/switch/AP. Just get another Netgear and configure the two devices to talk to each other.
BUT, I do not have high hopes that this will accomplish what you seek. It is unlikely that your Netgear is so overwhelmed that it cannot properly handle legitimate traffic. Look to see what the actual problem might be. Too many machines communicating at once? Line noise/interference? Infected machines sending bot traffic?
Set up Wireshark on one of your wired machines and on a wireless machine and see what is going on on the line.
| 1 |
Set up a second firewall in front of your current one and configure the two devices to talk to each other
|
Display pop-up message or hide custom button if field is blank
|
I'm new to Salesforce, so if this is trivial, accept my apologies in advance.
I have a button that points to an internal website. This button grabs looks at a custom field and uses that custom field as a passable parameter. The button is working as it should, but I'm needing more functionality.
What I'm looking to do is hide the button or display a popup message if my custom field is blank.
EDIT: So it looks like Javascript is what I'm looking for since we cannot hide the button.
This is what I have right now when I click a button. It opens up an internal report and passes the parameter that is in the KEY4__c custom field:
http://linktoreportserver/Parameter={!Lead.KEY4__c}
If the KEY4__c field is empty or null, I want it to send a popup to the user. If there is data, I want it to go to the URL above.
|
For your JavaScript, you can perform both steps to hide the button and/or show an alert.
First, the alert:
if({!ISBLANK(Object.Field)}) {
alert("You must populate the Field before using this button");
} else {
window.open("https://myserver/?param={!JSENCODE(Object.Field)}","_blank");
}
Now, we can add the following code to a Static Resource:
(function() {
function disableButtons() {
var btns = document.querySelectorAll('input[value="Button Label"]'), i = 0;
if(window.$shouldDisable) {
while(i<btns.length) btns[i++].disabled="disabled";
}
}
window.addEventListener("load", disableButtons, true);
}
Finally, add the resource to your button:
{!RequireScript(UrlFor($Resource.disableButton, null, null)}
window.$shouldDisable = {!ISBLANK(Object.Field)};
if(window.$shouldDisable) {
alert("You must populate the Field before using this button");
} else {
window.open("https://myserver/?param={!JSENCODE(Object.Field)}","_blank");
}
Using RequireScript causes whatever is included in the script to run on page load.
| 0.833333 |
Using RequireScript, you can hide the button
|
What's the best way to scan in hundreds of pictures?
|
I have thousands of old pictures which were sitting in a photo album. Unfortunately, instead of the photo album protecting the pictures, the plastic coverings yellowed, and the pictures themselves had to be carefully extracted from the books. There is also quite a bit of powdered paper (the backings on the books pretty much fell apart while we extracted the pictures), and the fronts of the images are still a bit sticky.
These pictures are 30+ years old, are often extremely faded, and were originally taken on (what I think is) "110 film" -- they are approximately 2.5" squares.
Anyway, I need to scan all these images in to preserve them from further decay. Unfortunately, it's taking forever -- going through less than 100 images took an entire day, even if one discounts any time spent in Photoshop trying to remove some of the photo album's artifacts on the images.
What I really need is some method of scanning the images in faster. Most automated solutions aren't going to work because they accept 4x6s as their smallest image size, and even if that was not the case, the adhesives still stuck to the prints would probably ruin any such device in 5 seconds flat.
Is there a better way of doing this (i.e. fast scanner?) that wouldn't take so much time?
|
Use a high speed page feed scanner like the DR-2010C from Canon. It can scan up to 20 pages per minute and automatically crops the scan image to the document size. You can get it from $370- from Amazon (amongst others)
If you have thousands of photos to scan it will be cheaper to buy this scanner than to use a service like Scancafe. 1680 photos at Scancafe will cost $370-. If you factor in your selling price your breakeven point will drop to about 1000 photos.
| 1 |
Use a high speed page feed scanner like the DR-2010C from Canon
|
How to ask a question according to the specific sections?
|
(1)I get up early in order to catch a bus.
(2)I get up early because I can catch a bus.
How to ask a question according to “in order to catch a bus ” and "because I can catch a bus"?
|
What do you want to achieve by getting up early? I get up early in order to catch the morning bus.
What is your reason for wanting to get up early? I get up early because if I don't, I will miss the morning bus.
Note that the question can really the same: why? The difference is how the answer is worded:
Why do you X? I do X in order to .
Why do you X? I do X because of .
I think your intended answers are based on the fact that you must catch the morning bus to arrive to work on time.
- I get up early in order to catch the morning bus.
- I get up early because if I don't, I'll miss the morning buss.
- I get up early so I can make it to work on time.
- I get up early because I want to make it to work on time.
Following is a bunch of examples. I'm not sure if it's just me, but it seems that often the "because" answer is kind of worded in the opposite sense of the "in order to answer". It seems like "because" is the driving force or reason, and "in order to" is a goal state. Also, the "in order to" answer seems more cold/clinical/unemotional/to-the-point while the "because" has more emotion and a broader set of reasons. I don't know if this is just me though:
Why do you eat hamburgers? I eat hamburgers because I like hamburgers.
Why do you eat hamburgers? I eat hamburgers because [I'm trying | I want | I need] to gain weight.
Why do you eat hamburgers? I eat hamburgers in order to gain weight.
Why are you eating hamburgers right now? Because their only $1 each.
Why are you eating hamburgers right now? In order to save money; they're only $1 each.
Why are you eating hamburgers right now? Because [I want | I need] to save money, and their only $1 each.
Why do you eat food? I eat food in order to live. Note how well "in order to" answers an abstract question.
Why do you eat food? I eat food because I need to eat food in order to live. Not a great answer.
Why do you eat food? I eat food because if I don't, I will starve to death. Because is using the opposite sense to mean the same thing.
Why do you eat food? I eat food in order to avoid starving to death. In order to sounds more awkward this way than the first line.
Why do you eat food? I eat food because I get hungry. Because is more simple here, based on base emotion or desire.
Why do you eat food? I eat food in order to satisfy my hunger. In order to has to carefully consider the goal state.
Why do you watch James Bond movies? I watch James Bond movies because I like James Bond.
Why do you watch movies? I watch movies in order to gain enjoyment. In order to is more cold/passive way of describing things.
Why do you watch movies? I watch movies because it's fun.
Why do you smoke? I smoke because I'm addicted to nicotine.
Why do you smoke? I smoke in order to satisfy my nicotine cravings.
Why are you trying to quit smoking? I'm trying to quit smoking because smoking is bad for me.
What are you trying to quit smoking? I'm trying to quit smoking in order to get more healthy.
| 1 |
Why do you eat food in order to get up early?
|
Is there any performance difference between ++i and i++ in C#?
|
Is there any performance difference between using something like
for(int i = 0; i < 10; i++) { ... }
and
for(int i = 0; i < 10; ++i) { ... }
or is the compiler able to optimize in such a way that they are equally fast in the case where they are functionally equivalent?
Edit:
This was asked because I had a discussion with a co-worker about it, not because I think its a useful optimization in any practical sense. It is largely academic.
|
If you're asking this question, you're either trolling for reputation or trying to solve the wrong problem.
The first question to ask is "how to I improve customer satisfaction with my software by making it run faster?" and the answer is almost never "use ++i instead of i++" or vice versa.
From Coding Horror's post "Hardware is Cheap, Programmers are Expensive":
Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.
-- M.A. Jackson
I read rule 2 to mean "first write clean, clear code that meets your customer's needs, then speed it up where it's too slow". It's highly unlikely that ++i vs. i++ is going to be the solution.
| 1 |
How to improve customer satisfaction with my software?
|
Modern design - What's that?
|
I am working on redesigning my website and iterating through fivesecondtests.
The overall feedback is improving but no matter what I change, several people have mentionned that my designs look "dated". "Not modern". "Use modern fonts".
What are "modern fonts"?
Technically, Calibri, Cambria, etc. are "modern fonts", but I hardly ever see those online. What fonts are considered "modern" in the context of web design?
What are the characteristics of a "modern design"? Conversely what
are the tell tale signs of a "dated" design?
For reference, here is the latest iteration of my design. Does it still look "dated"? If so, what elements give that impression?
I think I am starting to get a better idea of what "modern web design" is:
No or light gradients
Sans serif typefaces
Light drop shadows
Good page hierarchy / directing visitor's attention
Is there anything else that makes a design look "modern"?
I have implemented the most of the recommendations in the answers, and I feel it has improved the design a lot. (Never mind the logo - will figure that one out later)
Am I still stuck in the past? Or am I finally getting somewhere?
Implementing all recommendations, this is what I get:
It's obviously much better, but is it up to modern standards yet? If not, can it get there without changing massively the layout?
The learning process never ends, does it? Assume that the central menu has a lava effect and that hopefully I can get a decent photo of myself shot to replace that one.
Looking at the various versions, I can see the design improving by leaps and bounds. Not sure how much further it needs to improve to reach professional standards, but it's certainly moving in the right direction.
Thanks a lot to all of you. I am impressed by the quality of the advice and how specific and actionable most recommendations have been so far.
|
From my understanding of what you are asking it is very subjective to quantify a design as " modern". However many website design maybe considered "modern" because of their presentation, look and feel, inclusions of interactive graphics (html 5, JavaScript, flash) and beautiful illustrations on the website. Some may consider your website old because it visually looks like ... well old website :( (pre-drupal,wordpress even pre-flash)
Your website looks very plainly a very simplistic design (which is good thing) but is not appealing visually. You should try and change your layout, integrate your logo better into your site and also try to add an animated banner. Also the "thanks a lot" is a little old fashioned.
You really don't have to look very hard to find cool and inspirational designs on the internet :)
Most of today's websites which maybe considered modern are made using Drupal, Wordpress, Joomla or another CMS (but these 3 are very well known. open source and you can download them for free)
Here's the basic layout for Drupal and what you can do:
For some cool buttons see here
For a menu bar that moves with the page scroll you can see this
For a drop down menu you can see this
You can make a slider/slideshow on your own or use software for it like SlideShowPro or a free one - WOW Slider.You can do all sorts of things with this - make it scrollable and in many cases its a good idea to link it to your menu bar. (See here for some inspiration)
For smooth scrolling see this
The rest really is upto you. Make good use of the Triptych part ... it can make your site go from cool to awesome (again see smooth scrolling - this is extremely handy). Use AJAX to make your site more dynamic (because modern designs won't just relate to the visual appeal of your website but also the interaction of your site with the viewer) (jQuery makes life simple here).
For some cool ideas of what this or a similar layout scheme can be tailored into see here.
See this for some more inspiration
Here's the thing mate: You can skip all of this and just do your own thing. How you design essentially comes from you. Its your way of looking at things. Wordpress, Joomla and Drupal are used extensively in modern websites - from big corporate names to everyday users. Now to go back to your title question of "modern" design - pardon me here, but I don't know what is the purpose of your website, your deadlines or client - But the latest in web design is HTML5. Check out the Chrome Experiments, which really are making these designs look outdated, and some cool sites built using HTML5 and JavaScript.
| 1 |
How to quantify a design as "modern"
|
With estimates of mass constraints on magnetic monopoles, how likely is one to be found by the LHC(MoEDAL)?
|
Fermilab seems to have ruled out monopoles with mass less than 850 GeV, but I have seen some estimates of the mass thought to be in the order of up to $10^{18}$ GeV, which, of course, would make them undetectable in any accelerators. By 2013, the LHC is scheduled to reach up to 14 TeV. The only disputed sighting of a cosmic ray produced magnetic monopole was in 1982 when Blas Cabrera reported discovering one (Valentine event monopole). This has never been duplicated. CERN has set up the Monopole and Exotics Detector MOEDAL. Other experiments set up to detect them are the Antarctic Impulsive Transient Antenna--ANITA, and the Antarctic Muon And Neutrino Detection Array, aka AMANDA. While both of these detected neutrinos, neither detected magnetic monopoles (looking for Cerenkov radiation produced by products of monopole interaction).
Another method of detection is to look for induced current in a superconducting ring when a monopole passes through.
Joseph Polchinski called the existence of monopoles “one of the safest bets that one can make about physics not yet seen.” This shows some optimism on his part that one will be seen. Is there any reason or way to limit the mass of the monopole on the upside to 14 TEV or less?
|
Dear Gordon, Polchinski didn't imply anything about the lightness of the monopoles. You are overinterpreting what he said: his statement was an in-principle statement by a theorist. Just to be sure, the MoEDAL collaboration has overinterpreted him, too: he has never suggested that an experiment of their kind will find the beast. Still, it's very important to know whether such qualitatively different particles exist even if we think it's very likely that they won't be directly detected in the near (or far) future. Most of the top contemporary state-of-the-art theoretical physics deals with objects that will probably never be detected by direct experiments, for obvious financial and technological limitations.
Directly experimentally, the lower bound on the mass is just 500 GeV or so, but when some theory is wisely added, the mass is pretty much required to be exponentially higher than the TeV scale. In particular, some kind of unification seems necessary to allow the magnetic monopoles, and unification such as GUT can only appear at very high scales, such as the GUT scale of $10^{16}$ GeV: that's where the electromagnetic $U(1)$ may be embedded in a larger group that allows a topologically nontrivial solution (the $SU(2)$ of the weak interactions is not enough - it doesn't contain the hypercharge which has to be twisted as well). So it's unlikely that direct detection succeeds. Inflation has probably diluted the concentration of those massive magnetic monopoles to a very tiny number.
| 0.888889 |
Polchinski has never suggested that an experiment of their kind will find the beast .
|
Can I use the word "library" to refer to collections of things other than books or software?
|
It makes sense to say "library of books". Is it legitimate to use the word "library" in other contexts.
For example, could one have a "library of hedgehogs" or a "library of apples"?
|
I think a library implies that the objects are labeled or organized in some fashion, or used as a reference. So perhaps if you had a museum of stuffed hedgehogs from different time periods you could refer to it as a library of hedgehogs.
| 1 |
Library of hedgehogs from different time periods
|
No sound in Ubuntu except at log in
|
I installed Ubuntu 12.04 a month ago and am using it till now. I failed to notice that all this time there was no sound at all while running Ubuntu, even while playing a game in Wine. The weird thing is that only the startup sound comes when I log in (Indian/African drum tone), then comes the utter silence.
I tested both Digital Output (S/PDIF) and the speakers in the sound settings but can hear nothing.
Any help?
|
Sometimes the problem is that alsa somehow got muted. Open a terminal and type:
alsamixer
and disable Auto-Mute Mode. The mute can be toggled with the M key.
| 1 |
Auto-Mute Mode
|
How valuable is studying cognitive psychology for UX?
|
I am starting my second year in grad school and thinking about what to study. One thing that I know is good to have a grasp of is cognitive psychology. But I would like to get someones perspective.
Have you studied cognitive psychology? Either 1 class or more... and what did that give you?
|
Have you studied cognitive psychology? Either 1 class or more...
Yes.
and what did that give you?
That's a difficult question.
A lot of the academic cognitive psychology probably isn't that relevant to UX to be honest... (for example the language generation / comprehension bit )
Without some good guidance you could spend a lot of time reading psychology stuff, which, while interesting isn't really that relevant to UX.
Which begs the next question...
| 0.888889 |
Cognitive psychology isn't that relevant to UX?
|
What is the difference between drought resistant non-succulent plants and plants that cannot be allowed to dry out?
|
What features make one plant able to withstand dry spells better than another with relatively similar structure? For instance, one of my Rudbeckias is wilting from drought at the moment, and an Oenothera next to it is not yet showing signs of dryness.
Or like jewelweed (Impatiens capensis), which wilts even while the soil is damp, in full sun, and ragweed (Ambrosia artemisiifolia), which will grow in very dry locations without being phased.
Is it caused by a faster transpiration rate in some plants than in others?
|
Plants in drier conditions usually have reduced surface area, thick waxy cuticle covering the epidermis, reduced number of stomata, and water storage tissues that presides in its roots and leaves.
This means that even if the plants are similar, one of them might express more of one of the features shown above.
| 1 |
Plants in drier conditions usually have reduced surface area, thick waxy cuticle covering epidermis, reduced number of
|
Should I write a recommendation letter for a student at a previous job/institution?
|
I receive requests for recommendation many times, but I have received one from a student belonging at a previous affiliation of mine, asking for a favourable letter in view of their achievements.
I am aware of the fact that if I comment on the performance of the student, it could be used against me, since it is good practice to "erase" all the material, marks, personal information of the students and staff relationship at a previous job. So I am hesitant to go in that direction. On the other hand, I could comment only very generally on the skills of the student, which could backfire their application to a new job
Differently from this question I am not looking for a recommendation, but giving one...
|
When you change job, you don’t erase your memory (well, not in all jobs), nor do you all your responsibilities related to this previous job vanish. It is true that leaving a position creates certain obligations in the data you can retain, and how you can use non-publicly available information pertaining to your older institution. However, in the particular case of a reference letter, I don't think it should cause trouble. Moreover, reference letters are confidential.
Actually, I'd go further than saying it should not be a problem. In fact, I think if you can honestly write him a good recommendation letter, it is part of your responsibility to do it. This responsibility is not to your former institution, but to the student and the academic system as a whole.
| 1 |
When you change job, you don’t erase your memory (well, not in all jobs)
|
How to use the displaymath environment within a table?
|
I am trying to use the cases construct within a table. I tried to follow this example. When I copy paste the entire example, it compiles without an error.
But when I try to reproduce it, I get immediately into trouble:
\documentclass{article}
\begin{document}
\begin{table}
\begin{tabular}{c}
\hline
\[ e \] \\
\hline
\end{tabular}
\end{table}
\end{document}
Bad math environment delimiter [ e ].
What am I doing wrong?
|
The difference between your example and the one you refer to from how-to-add-equation-with-cases-inside-the-table is that you are trying to put a displayed equation into a "centred" table cell whereas the example puts one inside a "paragraph" in a tabular environment.
You either need to use a p-cell in your tabular environment:
\begin{tabular}{p{5cm}}
\hline
\[ e \] \\
\hline
\end{tabular}
OR you can use a normal (centred) cell with in-line mathematics that you explicitly typeset in \displaystyle:
\begin{tabular}{c}
\hline
\(\displaystyle f(x)=\begin{cases}1,&\text{if }x=1,\\0,&\text{otherwise}\end{cases}\)
\hline
\end{tabular}
Of course, you could also leave the \displaystyle out here.
(Btw, here I am assuming that you have loaded the amsmath package for the \text command.)
| 0.888889 |
How-to-add-equation-with-cases-inside-the-table
|
WD Black 2.5 sata drive slow on windows 8. Sector size is 4k. What gives? 40MBps write
|
WD Black 2.5 sata drive slow on windows 8. Sector size is 4k. What gives? 40MBps write.
This is a brand new WD black scorpion 500gb drive, on a brand new Zotac Zbox Nano CI320, quad core with 4gb of ram and Windows 8.1 x64.
Take a look at the pic and see from left are two USB 3.0 external drives and the last is my internal sata C drive that is showing issues. SMART scan came back A-ok! Kind of clueless here.
Update Back with some better news, after uninstalling the drive in device manager, booting into safemode then out again, I got this and confirmed it through about 4 more of the tests:
*note: the dip in data speed towards the end was from me doing something else with the drive while testing.
Update Tested again after 20 minutes since test above, it's back to slow 40mbps write speed :(
Testing on another system now! Then RMA if need be.
As it stands now: Sometimes getting full speed, mostly getting capped 40MBps write :(
Could someone please take a look at the SMART data and tell me if anything looks off to you?
Well guys, I think I've finally figured it out. It seems to have been a temp issue. I took some action to reduce temps, and attached two big solid copper blocks with thermal paste to the label side of the hdd. Temps now are going from 50c-60c variably. I'm probably going to make use of my eSata port on this thing, and relocate the internal drive to an external enclosure and eventually put in an SSD in the near future. :) My guess was the drive was going into a low power mode to reduce temps. That's the only thing I can think of.
|
I've seen similar drive behavior caused by a misbehaving flash chip on the PCB.
It would show faster, almost normal write speed for a short while after boot (the system has been turned off for a few hours before that). Then only the write speed will start fluctuating and then go slow again. If this is the case here I would test on a different system to confirm the results and if there is no change - go for RMA.
However if it's performing as expected in safe mode for a long period of time, you should dig into Windows. It could be a driver, but it could also be a process. It could also be due to insufficient power, but that usually happens with external drives.
| 0.888889 |
Drive behavior caused by a misbehaving flash chip on PCB
|
How to make a figure span on two columns in a scientific paper?
|
If I just try to set the figure's size to 0.9\textwidth my figure will just end up on the right column, sized to be two-columns wide.
Has anyone done this before?
|
From the TUG faq: use the starred versions figure* and table*. Unfortunately, they're somewhat limited in positioning.
Also, the same solution applies to equations. Just include them in a figure* environment. But I don't recommend doing this: it will look ugly and confusing. For an example, see this paper. (sorry, I couldn't find an example in arXiv)
| 0.888889 |
Use the starred versions figure* and table*
|
Are DSLRs a dying breed, making now the time to switch to a mirrorless camera system?
|
I came across this thought provoking article on Stuck in Customs today that makes a strong case to hold off too much investment in DSLR gear, and instead switch to mirror-less cameras like the Sony NEX. The author prefers to call such cameras 3rd generation cameras to prevent any bias.
The crux of the argument lies in the smaller size and faster shooting speeds of the new cameras, while the sensor size is an area where they seem to be lacking (Sony & Samsung cameras are APS-C sized though). Currently the big makers - Nikon & Canon - have practically no presence in this market (Nikon seems to be doing something with the V1). However, they seem to have slowed down the introduction of new entry level DSLR models over the last year as well.
So, as DSLR users looking to build and enhance their kit (there are many like me who've jumped the bandwagon over the last couple of years, and are just starting to build their kit), what are the advantages of sticking with the DSLR system rather than switching to the 3rd gen cameras?
IMO, one point that could cause a massive switch in the DSLR base would be if Nikon & Canon announced mirror-less models compatible with their current lens lineups, but that is a hypothetical scenario.
P.S. There is a similar question on mirror-less cameras, but that seems to be from the perspective of a person starting out rather than a person already invested in the DSLR system.
|
they said rangefinders were going to go the way of the dodo when SLRs were introduced.
They said SLRs were going away when point and shoot cameras were introduced.
They said black and white was dead when colour film was invented.
All are still with us today.
| 0.888889 |
SLRs were going away when point and shoot cameras were introduced
|
Why does itemAt() not always find QGraphicsItem
|
Consider this extremely simple example in which you can drag a square around a QGraphicsScene (using PyQt, C++ users read self as this)
import sys
from PyQt4 import QtGui, QtCore
class MainWindowUi(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.scene = Scene(0, 0, 300, 300, self)
self.view = QtGui.QGraphicsView()
self.setCentralWidget(self.view)
self.view.setScene(self.scene)
self.scene.addItem(Square(0,0,50,50))
class Scene(QtGui.QGraphicsScene):
def mousePressEvent(self, e):
self.currentItem = self.itemAt(e.pos())
print (self.currentItem)
QtGui.QGraphicsScene.mousePressEvent(self, e)
class Square(QtGui.QGraphicsRectItem):
def __init__(self, *args):
QtGui.QGraphicsRectItem.__init__(self, *args)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = MainWindowUi()
win.show()
sys.exit(app.exec_())
When you click the mouse in the scene you should see a print statement telling you that you clicked either on the square or on nothing (ie. None). This works if you just start the program and click on the square.
Now drag the square away from the upper left corner and click on it again. This time itemAt() return None even when you click on the square.
What's going on?
|
The answer seems to be that I should have used self.itemAt(e.scenePos()) instead of self.itemAt(e.pos()). I found this in this SO question.
I note here that the reason I've been having trouble finding information on this issue is that moving QGraphicsItems around in a QGraphicsScene is not what Qt calls "drag and drop". To search for information on this topic you want to search for things like "move QGraphicsItem".
| 0.888889 |
Moving QGraphicsItems around in a QGraphicsScene
|
Salesforce Mobile SDK Community Registration
|
I am developing a mobile application for one of our client using Salesforce SDk. I haven't found any documentation regarding the community registration vai Salsforce SDK. Is this possible?
Because when i complete the registration from "Not a member" link the page is still loading in the webview , not getting redirected to the application ( to mobile). Is there any way to accomplish registration via SDK?
|
This link provides all configuration items that you need to have in place to use Communities with the Salesforce Mobile SDK. Depending on the kind of user license, you also need to have appropriate permissions (such as API enabled for Portal users) - refer this link.
SDK does not provide any explicit support for self-registration.
| 1 |
Salesforce Mobile SDK provides all configuration items that you need to have in place .
|
Button Onclick EventHandler from CreateChildControls
|
I have declared a button in my CreateChildControls method in my web part page:
TableCell updateCell = new TableCell();
Update = new Button();
Update.Text = "Update";
Update.OnClientClick += new EventHandler(Update_OnClick);
updateCell.Controls.Add(Update);
ButtonRow.Controls.Add(updateCell);
This is the eventhandler that I created:
private void Update_OnClick(object sender, EventArgs e)
{
if (_TYPE == "FIXED")
{
Item["Retail"] = txtFixedRetail.Text;
Item.Update();
EmailFixedAlert();
}
}
However JScript throws an error:
Microsoft JScript runtime error: 'System' is undefined
And produces this in the HTML:
<td><input type="submit" name="ctl00$m$g_c260f907_31c1_436b_b99e_9bf79427625c$ctl11" value="Update" onclick="System.EventHandler;" /></td>
Why is the eventhandler that I declared in the WebPart not passing to the Page?
Do I have to push all events to the Client?
|
Button.OnClientClick is assigning JavaScript to run in the browser
Button.Click is for Server side event handling
| 1 |
JavaScript to run in browser Button.OnClientClick
|
Opening a file on unix using c++
|
I am trying to open a file in c++ and the server the progam in running on is based on tux.
string filename = "../dir/input.txt"; works but
string filename = "~jal/dir1/dir/input.txt"; fails
Is there any way to open a file in c++ when the filename provided is in the second format?
|
You could scan the string, replacing ~user by the appropriate directory.
The POSIX function wordexp does that, and a few other things
variable substitution, like you can use $HOME
optional command substitution, like $(echo foo) (can be disabled)
arithmetic expansion, like $((3+4))
word splitting, like splitting ~/a ~/b into two words
wildcard expansion, like *.cpp
and quoting, like "~/a ~/b" remains that
| 0.888889 |
user by the appropriate directory
|
Wrapper classes for objects returned by 3rd party APIs
|
I am building a WPF application which uses a third party library to fetch objects which I want to allow the user to interact with.
The objects are returned as interface types. Am I right in thinking it is good practise to create wrapper classes for these objects instead of binding directly to the interface returned e.g (ICustomer)?
If so, what is the best way to do this? My current thinking is to inject the service into my view model. Then create my own version of the customer class (ClientCustomer) on the client. When I call get customers on the service it will return a list of ICustomer. For each of these, I will create a new instance of ClientCustomer passing in the ICustomer object and client customer can simply return the underlying properties. This will leave me with a list of ClientCustomer objects which I can bind to instead of binding directly to the List of ICustomer.
public class ClientCustomer
{
public ClientCustomer(ICustomer c)
{
this.customer = c;
}
public string Name
{
get { return this.customer.Name;}
}
//Other properties in a similar way to Name
}
public class CustomerViewViewModel : ViewModelBase
{
ICustomerService svc;
public ViewModel(ICustomerService svc)
{
this.svc = svc;
Customers = new List<ClientCustomer>();
var custs = svc.GetCustomers();
custs.ForEach(c => Customers.Add( new ClientCustomer(c));
}
public List<ClientCustomer> Customers {get;}
}
Is this a good approach? I'm also unsure how to handle complex types which ICustomer contains. For instance ICustomer has a List of Bank accounts IBankAccount. Do I need to wrap the Bank Account object in a similar way as well?
|
You're almost there. You have the right idea, but you missed the execution of the idea a little bit.
public class ClientCustomer
{
public ClientCustomer(ICustomer c)
{
this.customer = c;
}
public string Name
You've put a boundary in between yourself and the third party interface, but then you've turned around and coded against an implementation. We should code against interfaces whenever possible.
Right now you're probably confused.
But I can't code against that interface. I need to insulate myself from it.
You're right. You do need to insulate yourself from the third party interface. It's their boundary, not yours. You need the Adapter pattern.
You need to create your own interface that your code will work with.
interface IClientCustomer
{
string Name { get; }
}
Then your class implements your interface.
public class ClientCustomer : IClientCustomer
And all of the client code works with classes implementing the IClientCustomer interface.
public ViewModel(ICustomerService svc)
{
this.svc = svc;
Customers = new List<IClientCustomer>();
This way, if you ever swap the libraries out, you're truly insulated. You create a new class that implements your interface and it is much easier to swap one for another. If you make this small change, I'd say you've got it right.
| 0.777778 |
How to code against a third party interface?
|
android opengl error (Application unexpectedly stopped)
|
I'm developing this game for android. I'm following a tutorial on how to make menus. And this is the code. There's no errors just warning in the code so I dont know what to do.
08-23 21:31:41.099: E/System(79): Failure starting core service
08-23 21:31:41.099: E/System(79): java.lang.SecurityException
08-23 21:31:41.099: E/System(79): at android.os.BinderProxy.transact(Native Method)
08-23 21:31:41.099: E/System(79): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
08-23 21:31:41.099: E/System(79): at android.os.ServiceManager.addService(ServiceManager.java:72)
08-23 21:31:41.099: E/System(79): at com.android.server.ServerThread.run(SystemServer.java:206)
08-23 21:31:41.139: E/EventHub(79): could not get driver version for /dev/input/mouse0, Not a typewriter
08-23 21:31:41.139: E/EventHub(79): could not get driver version for /dev/input/mice, Not a typewriter
08-23 21:31:42.049: E/SoundPool(79): error loading /system/media/audio/ui/Effect_Tick.ogg
08-23 21:31:42.049: E/SoundPool(79): error loading /system/media/audio/ui/KeypressStandard.ogg
08-23 21:31:42.069: E/SoundPool(79): error loading /system/media/audio/ui/KeypressSpacebar.ogg
08-23 21:31:42.069: E/SoundPool(79): error loading /system/media/audio/ui/KeypressDelete.ogg
08-23 21:31:42.079: E/SoundPool(79): error loading /system/media/audio/ui/KeypressReturn.ogg
08-23 21:31:42.159: E/UsbObserver(79): java.lang.NullPointerException
08-23 21:31:42.159: E/UsbObserver(79): at com.android.server.UsbObserver.init(UsbObserver.java:131)
08-23 21:31:42.159: E/UsbObserver(79): at com.android.server.UsbObserver.<init>(UsbObserver.java:65)
08-23 21:31:42.159: E/UsbObserver(79): at com.android.server.ServerThread.run(SystemServer.java:402)
08-23 21:31:47.820: E/ThrottleService(79): Could not open GPS configuration file /etc/gps.conf
08-23 21:31:47.880: E/ThrottleService(79): Error reading data file
08-23 21:31:49.250: E/logwrapper(194): executing /system/bin/tc failed: No such file or directory
08-23 21:31:49.320: E/logwrapper(195): executing /system/bin/tc failed: No such file or directory
08-23 21:31:49.370: E/logwrapper(196): executing /system/bin/tc failed: No such file or directory
08-23 21:31:57.759: E/logwrapper(225): executing /system/bin/tc failed: No such file or directory
08-23 21:31:57.889: E/logwrapper(226): executing /system/bin/tc failed: No such file or directory
08-23 21:31:58.000: E/logwrapper(227): executing /system/bin/tc failed: No such file or directory
08-23 21:32:41.593: E/MetadataRetrieverClient(34): failed to extract an album art
08-23 21:33:17.502: E/ThrottleService(79): Error reading data file
08-23 22:06:08.702: E/AndroidRuntime(414): FATAL EXCEPTION: GLThread 13
08-23 22:06:08.702: E/AndroidRuntime(414): java.lang.IllegalArgumentException: No EGLConfig found!
08-23 22:06:08.702: E/AndroidRuntime(414): at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:183)
08-23 22:06:08.702: E/AndroidRuntime(414): at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:157)
08-23 22:06:08.702: E/AndroidRuntime(414): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:919)
08-23 22:06:08.702: E/AndroidRuntime(414): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1264)
08-23 22:06:08.702: E/AndroidRuntime(414): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
|
Changed already the target SDK, enable GPU Host, the processor to Intel. Still getting errors
08-25 01:41:48.889: ERROR/Zygote(793): setreuid() failed. errno: 30
08-25 01:42:01.820: ERROR/Zygote(793): setreuid() failed. errno: 30
08-25 01:42:04.430: ERROR/BatteryService(853): acOnlinePath not found
08-25 01:42:04.430: ERROR/BatteryService(853): usbOnlinePath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryStatusPath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryHealthPath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryPresentPath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryCapacityPath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryVoltagePath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryTemperaturePath not found
08-25 01:42:04.430: ERROR/BatteryService(853): batteryTechnologyPath not found
08-25 01:42:04.770: ERROR/EGL_emulation(853): rcMakeCurrent returned EGL_FALSE
08-25 01:42:04.770: ERROR/EGL_emulation(853): tid 874: eglMakeCurrent(984): error 0x3006 (EGL_BAD_CONTEXT)
08-25 01:42:04.770: ERROR/libEGL(853): call to OpenGL ES API with no current context (logged once per thread)
08-25 01:42:04.770: ERROR/libEGL(853): call to OpenGL ES API with no current context (logged once per thread)
08-25 01:42:04.770: ERROR/libEGL(853): call to OpenGL ES API with no current context (logged once per thread)
08-25 01:42:04.770: ERROR/libEGL(853): call to OpenGL ES API with no current context (logged once per thread)
08-25 01:43:01.773: ERROR/Zygote(889): setreuid() failed. errno: 30
| 0.833333 |
ERROR/Zygote(793): setreuid() failed
|
What is the Gorel Hagra?
|
What is it?
How is it performed?
May one perform it?
And, if so, when may it be used?
|
As I've heard it, it involves opening a Tanach to a random verse; I heard something it specifically being some Amsterdam printing of the Tanach (anyone back me up here?). There are some famous stories about its use, though these may be no more than hearsay:
One rabbi who got the verse, "do not use witchcraft or divinations!"
When Rabbi Joseph Breuer was ill and needed an additional name, they found the verse "Shimon and Levi are brothers"; his "brother" in leading the KAJ community was Rabbi Shimon Schwab, so he became Levi Joseph Breuer.
I think there's one with R' Aharon Kotlar, debating coming to America in 1941, and finding (Exodus 4:27) "Hashem told Aharon, go greet Moshe in the desert", referring to Rabbi Moshe Feinstein (who had made it to America in 1936). H/t Alex (see comments below).
As far as how/when/why to use it, eh good question.
| 1 |
How to open a Tanach to a random verse?
|
how to install .net framework? if not already installed using autorun.inf
|
I need the file autorun.inf with this content:
[autorun]
open=file.bat
icon=icon.ico
and file.bat with this content for detect setup.exe and framework4 (if the last don't exist):
REG HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full /v Version :rechek
IF %errorlevel%==0 GOTO INSTALL start setup.exe exit GOTO eof :INSTALL dotNetFx40_Full_x86_x64.exe GOTO rechek
What is the error in the file .bat file?
|
Here is a not tested batch code which makes more sense then your batch code:
@echo off
setlocal
set "RetryCount=0"
:ReCheckFramework
%SystemRoot%\System32\reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Version>nul 2>nul
if not errorlevel 1 goto EndFrameworkInstall
start "Install FrameWork" /wait dotNetFx40_Full_x86_x64.exe
set /A RetryCount+=1
if %RetryCount% LSS 3 goto ReCheckFramework
:EndFrameworkInstall
endlocal
Testing a batch file should be always done by opening a command prompt window and running the batch file from within this console window. Then syntax errors and errors on parameter list of commands and applications can be easily seen.
reg.exe requires as first parameter the action to do, here query. And you forget the double quotes around registry key as it contains spaces.
Also writing nearly all commands in one line is also wrong.
Well, best would be to really check version of installed .NET Framework 4 in case of a newer version is already installed then what is put on CD/DVD.
| 0.777778 |
How to test a batch file
|
Which is the correct statement on proteins?
|
I need help with one of the questions on my biochemistry assignment
Choose the correct statement on proteins:
a) proteins are folded by alpha-helix
b) proteins can preserve their function even if they only partially change their shapes
c) proteins are composed of amino acids
d) all of the above
Thanks in advance! :)
|
Do you have a textbook? That will definitely have the answer early on in the chapter. Also, have you tried reading the protein Wikipedia article, in particular the structure subsection. You will find the information you want there.
| 1 |
Do you have a textbook?
|
Firefox flex and max-width
|
I’m trying to display an image centered and resized by CSS (max-width / max-height, flex).
This is working fine in Chrome but not in Firefox. What’s wrong?
a {
border: 1px solid red;
display: flex;
height: 100px;
width: 100px;
justify-content: center;
align-items: center;
box-sizing: border-box;
padding: 5px;
}
img {
max-width: 100%;
max-height: 100%;
border: 1px solid green;
}
<a class="frame">
<img src="http://placehold.it/500x150"/>
</a>
See: http://jsfiddle.net/ymLb50w0/2/
|
You may try to align it vertically like it's explained here
Horizontal alignment shouldn't be a problem
| 0.888889 |
Horizontal alignment shouldn't be a problem
|
Split WP install between 2 databases?
|
Is it possible for Wordpress to work from two databases?
The reason I ask is that we're approaching our 100mb limit for database size on our host (1and1) but have up to 100 databases, so what I was hoping to do is essentially 'add on' another database for when the limit is reached?
|
Yes, but that is out of quick and easy realm.
See HyperDB in Codex and repository for starters.
| 0.888889 |
HyperDB in Codex and repository
|
Can a PC have more than one Default Gateway?
|
I know that a PC can have multiple network adapters each of which with different network identifiers (IP,MAC etc.).
My question is, can a certain PC have more than one active default gateway? And if so, how does the PC (or better say the OS) knows to what adapter use for any given packet?
|
The default gateway is the route use if none of the other routes match. So by that definition, there can be only one at a time.
Except not really, because your routing rules might be more complicated. Modern versions of Linux, for example, support using multiple completely independent routing tables, and making packet-by-packet determination as to which table to consult. So for example, perhaps you have one network configuration used for normal traffic, but a completely different routing table for your web browser. Or perhaps you have another routing table that's only used for packets with specific TOS bits set. But each would have its own default gateway which would reflect the default route for that specific routing table.
Normally, the routing table is as simple as, "local traffic to the local interface, everything else to the router." But if you're using a more complicated network setup, then the tools exist to cope with whatever network scenario you can dream up.
| 0.666667 |
The default gateway is the route use if none of the other routes match.
|
Can I be prosecuted in a European country while on vacation?
|
Obviously I know the answer is yes, but if I visited a European country and stole something there would I actually be put in jail and face trial or be deported or face trial in the US?
|
Depending on the countries involved, both are possible and there are a few other scenarios too.
You are arrested, prosecuted locally and serve your sentence where you committed your crime. As others have said, local law fully applies, it happens all the time. Your home country should be informed and can at most complain and try to exert some pressure on a political level but you don't have any extraordinary legal protection only because you are a foreign national. For a famous recent case illustrating this, see Amanda Knox.
You are arrested, prosecuted and sentenced but you are allowed to serve your sentence in your home country. As @MastaBaba pointed out, there are international agreements to organise this on a bilateral basis.
You are arrested, prosecuted, sentenced and you serve your sentence but it doesn't end there. You can still be deported and/or banned after the end of your sentence. Many European countries have actually introduced or strengthened legislation to this end in the last decade. So it's not either face trial or be deported, if you are really “lucky” it could be both!
You are arrested and criminal proceedings are initiated but you manage to come back home at some point during the procedure. In Europe, for a simple theft with no prior offence or aggravating circumstances, a jail sentence is unlikely and it is therefore unusual to be detained prior to trial. If you choose to “jump bail” and somehow manage to leave the country, things become a bit complicated. Among the possibilities:
The country where you committed your crime seeks your extradition to force you to appear in court and/or execute your sentence (not always possible because some countries never extradite their own citizens). For another prominent example, see Roman Polanski.
You are sentenced in absentia. Institutions like the Council of Europe have been pushing against this practice but some countries still do it. You might or might not be entitled to a retrial when you are finally caught but one effect is typically to suspend or extend statutes of limitation so that such a sentence means you will have to look over your shoulder and avoid going back to the country of your crime (or possibly all the countries that have an extradition treaty with that country) for the rest of your life.
You could still face prosecution in your home country (see below), although that would seem exceedingly unlikely for a theft.
Nothing happens, you come back home and are prosecuted in your country of origin. Many countries do that for particularly serious crimes but some countries also allow it for pretty much everything, in particular because they never extradite their own citizens. In the latter case, the crime in question must typically exist in the laws of both countries whereas in the former case, it's sometimes even possible to prosecute people for things that were not illegal where and when they happened (e.g. in many European countries, laws against child prostitution typically apply to offences committed abroad, without any reference to local law).
You are prosecuted in another, unrelated third country. It's unusual and typically limited to particularly heinous crimes (and in particular war crimes, crimes against humanity and genocide) but it does happen. Among those that might take interest are your country or countries of residence or the country of origin or residence of any of your victims and Baltasar Garzón. See also Wikipedia.
Among other curiosities, the fact that it might sometimes be possible to be prosecuted in several places also raises questions related to the application of the non bis in idem principle.
In short, it depends a lot on the details, there is no overarching principle or international agreement that would apply in all cases.
| 1 |
You are arrested, prosecuted and sentenced but you are allowed to serve your sentence in your home country
|
Visual Studio profiler not finding symbols when I run it in Azure
|
I am trying to profile my Windows Azure application using the Visual Studio Profiler in Windows Azure. I followed the instructions at http://msdn.microsoft.com/en-us/library/windowsazure/hh369930.aspx#BK_ProfilingCloudService, but I run into this problem where when I download the profiling report from an instance it can't find the symbol information and I get nothing but hex values for the function names. The profiler outputs the following errors:
Warning VSP2701: F:\approot\MyApp.MyLib.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\system32\MSASN1.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\system32\slc.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.Build.Fra#\d172e68980f5b5930d83fc1bccfc07e3\Microsoft.Build.Framework.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Framework\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.Runtime.Cach#\5cf803aa1b791b9c6cf2d5167fe7d63b\System.Runtime.Caching.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.Applicat#\fdc3ab5c1ff60542a20b6950f64eeb29\System.Web.ApplicationServices.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.DirectorySer#\770f4419204ad7db44842c6dbb86a336\System.DirectoryServices.Protocols.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\System.DirectoryServices.Protocols\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.Protocols.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.DirectorySer#\7f7a77e6e63a5169626f3c0c8c7d72a8\System.DirectoryServices.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\System.DirectoryServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.Drawing\741fda6371303be2c86d23b8dcf88cc3\System.Drawing.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.Data.SqlXml\2d6a784738e5d67e70feb68f0c53a3d8\System.Data.SqlXml.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.SqlXml\v4.0_4.0.0.0__b77a5c561934e089\System.Data.SqlXml.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\assembly\NativeImages_v4.0.30319_64\System.Security\b7ad9cb6010b93a853dd647d9e1f3857\System.Security.ni.dll could not be found when looking for symbol information.
Warning VSP2701: D:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll could not be found when looking for symbol information.
And so on. Looking at the paths, this is clearly the path that is being looked for on the actual Azure instance (I've been in via RDP enough times to recognize what D:\windows and F:\approot means). But I'm viewing this performance report on my own machine. So how can I tell the profiler to look for symbols using MY machine's settings, and not the Azure instance's settings?
For the record, I AM following the instructions in the linked pages, and I have googled this extensively and found nothing. Not to say there's nothing out there, but I'm following the instructions in the profiling blogs and such and still getting the errors. I asked this question on the MSDN forums and a Microsoft rep basically told me that if I followed the instructions it would definitely work.
|
Sorry I didn't see this earlier. Basically the issue is that when your app is profiled, many of the binaries are ngened. Because of this, the system cannot interpret the function addresses without the correct pdb hence you see Hex. You will need to generate the ngen pdb on the same machine where the ngenbinary exist (see http://blogs.msdn.com/b/visualstudioalm/archive/2012/12/10/creating-ngen-pdbs-for-profiling-reports.aspx ). That should take care of most of the binaries listed as *.ni.dll . As for your own application, setting the Symbol location in Visual Studio should be sufficient to locate the symbols for your own application. Hope this helps
| 0.777778 |
Symbol location in Visual Studio should be sufficient to locate the symbols for your own application
|
Why making additional payment to mortgage counts towards principal? Why does it matter?
|
When it comes to mortgage advice, some people recommend making an extra payment. The logic is :"These extra payments are automatically applied to your principal, not interest".
Why does it matter if the extra payment is applied to the principal and not interest?
|
Extra payments apply towards principal, and since interest is amortized and computed monthly.
The impact on your loan is pretty amazing. One extra payment per year will take about 8 years off of a 30 year fixed mortgage.
See a tool like http://www.mortgagecalculator.org for examples.
| 1 |
Extra payments apply towards principal, and since interest is computed monthly.
|
How do i install drivers for Lexmark Z1300 printer for ubuntu 13.10?
|
I bought a new Lexmark Z1300 printer, I couldn't find any drivers for linux for this series, Is there any way to install drivers and make use of this printer on ubuntu 13.10 or i have to switch back to windows to take the printouts?
|
Ubutuforums.org has a list of Lexmark printers that worked in 2007(!) based of a Gentoo article. Back then Lexmark provided a z600 driver but that has been removed from their site. You can try to follow this installation for your z3100 but the 1st mentioning of this printer is post 320 and states it does not work.
My personal experience: in relation to Ubuntu the cheaper Lexmark printers tend to be paperweights. I have only managed to use Lexmark printers when I could hook them up on the network. Not direct from Ubuntu.
You will save yourself a lot of trouble if you return the printer and get a supported one (all HP printers work out of the box)
| 1 |
Lexmark printers that worked in 2007 based on a Gentoo article
|
How can I save messages from a particular sender in a particular folder in Gmail?
|
A particular sender (an advertising company) sends a lot of emails daily into my Gmail inbox. Now those mails are important to me, since I am interested in their ads, but every time it is not possible to check them all. So I don't want my inbox to be flooded with their emails. Sometimes I can't work properly with my inbox filled with their emails. So is there a way so that I can mark the sender such a way so that the mail comes as usual, but it goes to a specific folder in lieu of flooding my inbox, so that when I get free time I can check their mails entering a particular folder?
|
A strength of Gmail is the use of labels, instead of folders. You need to create a filter to automatically add a label to the message and automaticlly archive the messages.
To create a filer for a message that frequently is sent to you:
select or open a message you want to filter
Under the More pulldown select the command: Filter messages like these
You will then see the form open up with the FROM box filled in.
Google with then show you the messages that the filter has found.
Click create filter with this search.
You can now specify if you want to:
Skip the Inbox (Archive it)
Apply the label:
Also apply filter to x matching conversations.
Click create the filter.
Archiving the messages keeps the message, it just removes the inbox label from the message. Labels can be used to search using label:mylabel. Labels are listed on the sidebar menu so that you can quickly jump to a filter that just shows the messages with that label. Plus messages can have multiple labels.
You can edit/delete/create filters under Settings(gear)->Filter
| 1 |
Create a filter to automatically add a label to a message
|
indicator-notifications history
|
I am looking for a way to view all the entries in indicator-notifications. I have it installed already and running. By default, it shows just five recent notifications even when you have more than five in a 'list' somewhere.
Like in the screenshot above, how can I see all the 11 notifications at once?
|
Solution for showing more notifications in the bubble
For Ubuntu 13.04 and up. If you interpret OPs question as "I want more notifications to appear",
sudo nano /usr/share/glib-2.0/schemas/net.launchpad.indicator.notifications.gschema.xml
Look for the lines that say
<range min="1" max = "10"/>
<default>5<default>
and then edit the <default>5<default> and `<range min="1" max = "10"/> to whatever you need.
For the curious
In the debian for the software, it has a few folders that it installs into. It installs things into /usr/share and /usr/lib. Library files are in .so so I can't edit anything in there. Navigating through /usr/share, I found the doc folder which is just debian package info, pixmaps which are the pngs for the icons on the notification bar, and then there was glib-2.0 which conveniently had an easy to read xml file. This is where you edit the variable to show whatever value of notifications you want.
Solution for Saving the Notifications to File
If you interpret OPs question as "I want to see my notification history", this is a general solution, you can do what you want with the log produced, IE let it accumulate, have it clear on shutdown, etc. Indicator-notifications is based on notify-osd as noted in their notes. Indicator-notifications is not necessary for this solution.
In sudo nano /etc/environment add LOG=1.
Reboot.
You notifications will now be stored in/home/$USER/.cache/notify-osd.log
Edit: Global Variables may be a bad idea to change because it is unknown what other programs use that variable. Add LOG=1 to your local .bashrc instead.
| 1 |
Indicator-notifications based on notify-osd
|
What is the correct way to ensure unique entries in a temporal database design?
|
I'm having trouble with the design of a temporal database. I need to know how to make sure I have only one active record for any given timeframe for a store. I have read this answer, but I'm afraid I can't wrap my head around how the trigger would work. Particularly, how I would work that trigger into my existing one that prevents updates to records, and inserts a new record instead. My real problem is that I do not know how to prevent a Store from having more than one effective date when the finished date is null. (i.e. prevent 2 active records for a store).
This is what I have, but it allows me to insert a new record for a store with a different effective date.
Table Definition:
/****** Object: Table [PCR].[Z_STORE_TEAM] Script Date: 05/09/2014 13:05:57 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Z_STORE_TEAM]') AND type in (N'U'))
DROP TABLE [Z_STORE_TEAM]
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Z_STORE_TEAM]') AND type in (N'U'))
BEGIN
CREATE TABLE [Z_STORE_TEAM](
[STORENUM] [int] NOT NULL,
[TEAM] [varchar](10) NULL,
[EFFECTIVE] [date] NOT NULL,
[FINISHED] [date] NULL,
PRIMARY KEY CLUSTERED
(
[STORENUM] ASC,
[EFFECTIVE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
Sample Data:
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (1, N'1', CAST(0x01380B00 AS Date), CAST(0x81380B00 AS Date))
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (1, N'2', CAST(0x81380B00 AS Date), NULL)
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (2, N'1', CAST(0x01380B00 AS Date), NULL)
INSERT [Z_STORE_TEAM] ([STORENUM], [TEAM], [EFFECTIVE], [FINISHED]) VALUES (2, N'2', CAST(0x20380B00 AS Date), NULL)
Instead of Update Trigger:
CREATE TRIGGER [tr_ZStoreTeam_update]
ON [Z_STORE_TEAM]
INSTEAD OF UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
INSERT INTO PCR.Z_STORE_TEAM(STORENUM,TEAM,EFFECTIVE)
SELECT I.STORENUM,I.TEAM,GETDATE() AS EFFECTIVE
FROM inserted I
INNER JOIN PCR.Z_STORE_TEAM ST
ON I.STORENUM = ST.STORENUM
UPDATE ST
SET FINISHED = GETDATE()
FROM PCR.Z_STORE_TEAM ST
INNER JOIN inserted I
ON ST.STORENUM = I.STORENUM
AND ST.EFFECTIVE = I.EFFECTIVE
END
GO
|
The safest way to do this is to enforce your business rules using the built-in referential integrity constraints, as Alexander Kuznetsov describes in his article, "Storing intervals of time with no overlaps".
Applying the techniques listed there to your sample table results in the following script:
CREATE TABLE [Z_STORE_TEAM](
[STORENUM] [int] NOT NULL,
[TEAM] [varchar](10) NULL,
[EFFECTIVE] [date] NOT NULL,
[FINISHED] [date] NULL,
PRIMARY KEY CLUSTERED
(
[STORENUM] ASC,
[EFFECTIVE] ASC
)
) ON [PRIMARY];
INSERT [Z_STORE_TEAM]
([STORENUM], [TEAM], [EFFECTIVE], [FINISHED])
VALUES
(1, N'1', CAST(0x01380B00 AS Date), CAST(0x81380B00 AS Date)),
(1, N'2', CAST(0x81380B00 AS Date), NULL),
(2, N'1', CAST(0x01380B00 AS Date), NULL);
Modifications:
-- New column to hold the previous finish date
ALTER TABLE dbo.Z_STORE_TEAM
ADD PreviousFinished date NULL;
GO
-- Populate the previous finish date
UPDATE This
SET PreviousFinished = Previous.FINISHED
FROM dbo.Z_STORE_TEAM AS This
CROSS APPLY
(
SELECT TOP (1)
Previous.FINISHED
FROM dbo.Z_STORE_TEAM AS Previous
WHERE
Previous.STORENUM = This.STORENUM
AND Previous.FINISHED <= This.EFFECTIVE
ORDER BY
Previous.FINISHED DESC
) AS Previous;
GO
ALTER TABLE dbo.Z_STORE_TEAM
ADD CONSTRAINT UQ_STORENUM_PreviousFinished
UNIQUE (STORENUM, PreviousFinished);
GO
ALTER TABLE dbo.Z_STORE_TEAM
ADD CONSTRAINT CK_PreviousFinished_NotAfter_Effective
CHECK (PreviousFinished = EFFECTIVE);
GO
ALTER TABLE dbo.Z_STORE_TEAM
ADD CONSTRAINT UQ_STORENUM_FINISHED
UNIQUE (STORENUM, FINISHED);
GO
ALTER TABLE dbo.Z_STORE_TEAM
ADD CONSTRAINT FK_STORENUM_PreviousFinished
FOREIGN KEY (STORENUM, PreviousFinished)
REFERENCES dbo.Z_STORE_TEAM (STORENUM, FINISHED);
GO
ALTER TABLE dbo.Z_STORE_TEAM
ADD CONSTRAINT CK_EFFECTIVE_Before_FINISHED
CHECK (EFFECTIVE < FINISHED);
An attempt to insert the fourth row of sample data now fails with an error message:
INSERT [Z_STORE_TEAM]
([STORENUM], [TEAM], [EFFECTIVE], [FINISHED])
VALUES
(2, N'2', '20140201', NULL);
Please read Alex's article to understand how these constraints ensure your table data will always be valid. Having a set of constraints enforce your data integrity means no trigger code is required.
| 0.888889 |
Using a set of referential integrity constraints
|
Call external javascript in the default administration page in Django
|
How can I call external javascript in my default admin html page in Django.
I know that using MEDIA class I can do this in admin.py file.
Here is the my try:
class PlayerAdmin(admin.ModelAdmin):
class Media:
js = ('/static_files/js/adminsettings.js')
But I am not getting data written in the JavaScript file.
|
You need to use a path relative to STATIC_URL (or MEDIA_URL), in your example this may work:
class PlayerAdmin(admin.ModelAdmin):
class Media:
js = ('js/adminsettings.js',)
Also, not that the js attribute is a tuple in my example (it can be any iterable, a list, set, etc.)
An alternative is overriding admin templates, which can give you more flexibility, and allow you to apply the same javascript to many models easily.
| 0.888889 |
How to use a path relative to STATIC_URL?
|
FragmentTabHost in VS2013 - xamarin C#
|
the code i used to create FragmentTabHost :( i am designing for android 2.2 to upper)
i have googled a lot but no use so
i have placed all of my code here.
I get error in :
mTabHost.AddTab(spec);
please help how to solve ??
Activity 2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Content.PM;
using Android.Support.V4.App;
namespace ANRestaurant.Forms
{
[Activity(Label = "ANRestaurant", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = ScreenOrientation.Portrait)]
public class Activity2 : FragmentActivity
{
FragmentTabHost mTabHost;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.activity_main);
try
{
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
Intent intent;
intent = new Intent(this, typeof(Fragment1));
intent.AddFlags(ActivityFlags.NewTask);
//mTabHost.Setup(this, SupportFragmentManager, Resource.Id.tabFrameLayout);
TabHost.TabSpec spec;
spec = mTabHost.NewTabSpec("artists");
spec.SetIndicator("Artists", Resources.GetDrawable(Resource.Drawable.tab_icon1) );
spec.SetContent(intent);
mTabHost.AddTab(spec); ======>Here is the error
//mTabHost.AddTab(
// mTabHost.NewTabSpec("tab2").SetIndicator("Tab 2", null),
// intent, null);
//mTabHost.addTab(
// mTabHost.newTabSpec("tab2").setIndicator("Tab 2", null),
// FragmentTab.class, null);
//mTabHost.addTab(
// mTabHost.newTabSpec("tab3").setIndicator("Tab 3", null),
// FragmentTab.class, null);
}
catch (Exception ex)
{
}
}
}
}
activity_main.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhostN"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/tabFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
Fragment1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
namespace ANRestaurant.Forms
{
public class Fragment1 : Fragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your fragment here
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.fragment1, container, false);
return view;
//return base.OnCreateView(inflater, container, savedInstanceState);
}
}
}
ٍError Is :
Java.Lang.NullPointerException: Exception of type Java.Lang.NullPointerException was thrown.
at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms)
|
I got the same error and found here.
The problem is here in your fragment:
using Android.App;
Change it to:
using Android.Support.V4.App;
It's ok now...
It waste me the whole day.
OK, in output window it shows cast type error. like this:
Android.App.Fragment can't cast to Android.Support.V4.App.Fragment.
| 0.666667 |
How to cast to Android.Support.V4.App.Fragment?
|
How to generate 4 unique digit each time form 1 to 12
|
i want to generate 4 unique digit each time from 1 to 12. For example: [1,3,4,6] or [1,3,10,6] or [1,2,3,4]... but not like [1,2,8,1] or [2,2,4,5]
because in last two chunk 1 comes twice and so as 2 in second chunk. Again i need to generate those unique chunk of numbers randomly.
Any help will be appreciated. Big thanks in advance...:)
|
In javascript:
var numbers = [0,1,2,3,4,5,6,7,8,9];
var uniqueNumbers = [];
function getRandom(){
return numbers[Math.floor(Math.random()*numbers.length)];
}
while (uniqueNumbers.length < 4){
var value = getRandom();
if(uniqueNumbers.indexOf(value) < 0)
uniqueNumbers.push(value);
}
console.log(uniqueNumbers);
| 1 |
var numbers = [0,1,2,3,4,5,6,7,8,9]
|
How do I force a tight globe-valve water shutoff to fully close?
|
I tried to close off the water valve (a multi-twist globe-valve) leading to my back-yard water supply (the shutoff valve is inside the house) but it will not twist fully shut. Is it safe to give the screw a shot of WD-40 to loosen up the valve? Will that help?
Note: the valve is not leaking so I don't want to replace it. I am just trying to shut off the water supply for the winter.
|
Any valve that refuses to fully shut off won't be improved by tightening the handle further.
The usual problem with a Globe Valve is that the rubber valve seal has aged and cracked, needing replacement. This means you have to shut the water off upstream of the valve and remove the body cartridge so the rubber seal can be changed out.
Some valves have a globe shape, but get misidentified by that shape because they actually are Gate Valves which have a vertical wedge shaped metal gate that gets pushed down into a tapered slot. These fail because sediment accumulates in the slot on the downwards side and the gate no longer can be pushed fully home so the taper seals. This requires the water to be turned off upstream so you can take the top off the valve, extract the gate and grub the sediment out using a piece of welding rod so it will flush out when you reassemble the valve.
I've gone over to using quarter turn ball valves when I have to go to this much trouble. They are better than Globe Valves because the opening is the same size as the inner diameter of the pipe when the valve is full open, the water doesn't have to turn 90 degrees to flow through a restriction as it does in a Globe valve and while the gate valve has the same lack of restriction as the ball, the ball valve has no slot for rust, sand and sediment to accumulate in while it spends most its life wide open.
| 1 |
Globe Valves are a vertical wedge shaped metal gate that gets pushed down into a tapered slot .
|
How to get the path of android installed application
|
Hi I am new to Android and I want to know that how can we get the path of the installed application in android, So that we can open the file in our application by using that installed application.
for example:
I want to open the pdf file or doc file in my application but i require the path of that application which can open this file...
Please Help me
Thanks in advance...
|
I used the Following Code to do this
private void openFile(File f)
{
// Create an Intent
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
// Category where the App should be searched
// String category = new String("android.intent.category.DEFAULT");
// Setting up the data and the type for the intent
String type = getMIMEType(f);
/*Uri startDir = Uri.fromFile(f);
intent.setAction(Intent.ACTION_PICK);
intent.setDataAndType(startDir, "vnd.android.cursor.dir/*");*/
intent.setDataAndType(Uri.fromFile(f), type);
// will start the activtiy found by android or show a dialog to select one
startActivity(intent);//
/**intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK+Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
String theMIMEcategory = getMIMEcategory(type);
intent.setDataAndType(Uri.fromFile(f),theMIMEcategory);
try {
startActivity(Intent.createChooser(intent,"Choose Applicaton"));
} catch (Exception e) {
//show error
}
*/
}
/**
* Returns the MIME type for the given file.
*
* @param f the file for which you want to determine the MIME type
* @return the detected MIME type
*/
private String getMIMEType(File f)
{
String end = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length()).toLowerCase();
String type = "";
if(end.equals("mp3") || end.equals("aac") || end.equals("aac") || end.equals("amr") || end.equals("mpeg") || end.equals("mp4")) type = "audio/*";
else if(end.equals("jpg") || end.equals("gif") || end.equals("png") || end.equals("jpeg")) type = "image/*";
else if(end.equals("pdf")) type = "application/pdf";
else if(end.equals("xls")) type = "application/vnd.ms-excel";
else if(end.equals("doc")) type = "application/msword";
else if(end.equals("zip")) type="application/zip";
else {type="*/*" ;}
//type += "/*";
return type;
}
public static String getMIMEcategory(String aMIMEtype) {
if (aMIMEtype!=null) {
aMIMEtype = aMIMEtype.substring(0,aMIMEtype.lastIndexOf("/",aMIMEtype.length()-1))+"/*";
} else {
aMIMEtype = "*/*";
}
return aMIMEtype;
}'
| 0.888889 |
Create an Intent Intent
|
Is my interval training routine effective for mountain bike training?
|
During these winter months I am currently attending the gym 3 times a week. On each of the days I start my training on an exercise bike with the following:
5 minute warm up
30 minutes, 1 minute hard, 1 minute recovery
5 minute warm down
I am using a specific interval training setting on the bike. I preset the training to level 15, which is a high resistance and as much as I can take.
Hard is a cadence of between 80-90rpm high resistance. Recovery is a cadence of 60prm and the resistance backs off considerably, I imagine to approximately level 7.
My heart rate towards the end of the session reaches 170–190bpm, and I am working flat-out. I turn 30 in March, am 5' 8" and weigh approx 168lbs.
Does this training routine seem sensible for building strength and speed on the mountain? Should I be changing up the training with other types of bike training?
It is also worth noting that after the interval training I perform free weight strength training too.
|
To some extent whether it will be effective depends on your goal. Are you trying to develop endurance or speed?
There's an article at sportsci.org on the "Effects of High Intensisty Intermittent Training on Maximum Oxygen Uptake and Endurance Performance" which compares several different interval training techniques if Endurance is your goal.
| 1 |
Are you trying to develop endurance or speed?
|
What is Cold Iron actually?
|
It came up in Dresden Files, but is not limited to that game, you can find the term in DnD as well. I would like to know what it means.
If you look for Cold Iron on Wikipedia, you only get iron:
"Cold iron is a poetic and archaic term for iron."
This would imply everything made mostly from Fe is cold iron. Clearly, this is not the case, in every game Cold Iron is something special, the every day sword is not made out of it.
The Dresden Files rulebook is not very specific about it:
something that anyone could reasonably get access to, but usually doesn’t carry on them (like cold iron) page 185.
What is cold iron?
How do I create cold iron?
How do I get cold iron?
To make the question easier to understand, compare Cold Iron to Holy Water. You know how it is different from usual Water, you know how you get it or create it.
|
Based on the events of Summer Knight cold iron is, in fact, just iron. Dresden
kills Aurora with hundreds of pixies wielding common hobby knives with plastic casings. The book specifically mentions how the cold iron of the knife blades makes the relatively minor cuts deadly to the Summer Lady.
Referencing your quote, how much steel do you have on you right now? Sure, some people still carry a Leatherman or a pocket knife but most don't in the US these days. However, how easy is it to get one? In Summer Knight Dresden specifically mentions needing to
stop at Walmart prior to the climatic battle but not what he needs,
which is saved for the big reveal at the Stone Table.
| 1 |
How much steel do you have on you right now?
|
Where can I eat dishes that feature in western countries' Chinese restaurants?
|
... apart from western countries like the Australia or the USA themselves.
During my visit to Taiwan, I wasn't able to find the dishes I'd typically encounter in a Chinese restaurant in Australia or the United States, such as sweet and sour pork, honey chicken, Mongolian lamb/beef, and fried ice cream.
I have two main theories on why this is. One is that Chinese restaurant food is totally made up, and has no similarity with food anywhere in the world. In which case, I'd better give up trying to find the right location. This seems to be the case with fried ice cream, which Wikipedia suggests is an artificial modern invention.
The other is that maybe I visited the wrong location. China is a big place, after all. Perhaps visiting another area, such as Inner Mongolia, would find me what I'm looking for, with dishes either the same as, or the un-modified version of what is served in western countries' Chinese restaurants.
The Wikipedia article on Chinese restaurant mentions:
There has additionally been a consequential component of Chinese
emigration of illegal origin, most notably Fuzhou people from Fujian
Province and Wenzhounese from Zhejiang Province in Mainland China,
specifically destined to work in Chinese restaurants in New York City,
beginning in the 1980s.
As Fujian province is right next to Taiwan, and has had a major influence on it, it seems plausible that if some of the "Chinese restaurant" dishes were coming from Fujian, I would have seen them in Taiwan, but I didn't.
Where, if anywhere, can I find the dishes that feature in western countries' Chinese restaurants? Also, how should I identify the right kind of eatery in those countries?
|
These foods are typically unique to where you eat them For example neither deep fried ice cream or honey chicken are "Chinese food" here in Canada. The Wikipedia article on American Chinese food does a pretty job of identifying which North American "Chinese food" dishes map to food you might eat in China and which do not. I don't know if you can construct a similar list for Australian "Chinese food", but look for ingredients like carrots and tomatoes, as well as anything salad-like, to be particular to your home version of Chinese food and less likely to be available in China or other parts of Asia.
| 0.888889 |
Which North American "Chinese food" dishes map to food you might eat in Canada?
|
Is "ages" used only in British English?
|
The OALD says that ages is, "informal, especially BrE."
Is ages as in "I waited for ages" only used in British English?
If it is also used in other English dialects, is there any difference between the usage in those dialects? For example, is ages considered informal in one dialect, but not in another one?
|
In any dialect, it is informal when used hyperbolically, as in “I waited for ages”, or “It's been ages since I saw you”.
From ngrams for ages since I saw,waited for ages in a British English corpus, and from similar ngrams in an American English corpus, it's evident that these two expressions are used slightly more frequently in BE than in AE. I don't recall hearing an American saying something like “I waited for ages”, but I think I have heard “It's been ages since I saw you” numerous times.
| 1 |
In any dialect, it is informal when used hyperbolically, as in "I waited for ages"
|
Can a number have both a periodic an a non-periodic representation in a non-integer base?
|
Fix an algebraic number $\beta$ and consider a complex number $\alpha$ which admits multiple representations in base $\beta$. If one representation of $\alpha$ is ultimately periodic, must every other representation of $\alpha$ be ultimately periodic?
Bonus question: Does this depend on the choice of the set of digits?
Edit: John Bentin showed that this is false in general, even with $\beta \in \Bbb{Q}$. Is this true at least for $\beta$ algebraic integer?
Edit 2: This question came up when trying to solve this problem of mine.
All I know so far is that if $\beta$ is a Pisot integer, i.e. if it is a real algebraic integer greater than $1$ with every conjugate lying in the unit circle, then $\alpha \in \Bbb{Q}(\beta)$ if and only if it has an ultimately periodic expansion (which is stronger than my question).
|
The following counterexample answers the supplementary question added in the edit. Choose the algebraic integer $\sqrt2$ as the base. Then we may expand $1$ in the periodic form $$1=\frac12+\frac14+\cdots+\left(\frac{0}{(\sqrt2)^{2k-1}}+\frac{1}{(\sqrt2)^{2k}}\right)+\cdots.$$But we can also express it in a more irregular expansion:$$1=\frac1{\sqrt2}+\frac14+\frac1{32}+\frac1{64\sqrt2}+\cdots+\frac{a_k}{\sqrt2^k}+\cdots,$$where $a_k=1$ if $$1-\sum_{j=1}^{k-1}\frac{a_j}{\sqrt2^j}>\frac1{\sqrt2^k},$$ with $a_k=0$ otherwise, for $k=1,2,\dots\,$. To show that the irregular expansion is aperiodic, assume the contrary: namely that there exist integers $l\geqslant0$ and $m\geqslant1$ satisfying $$1=\sum_{k=1}^l\frac{a_k}{\sqrt2^k}+\frac1{\sqrt2^{l+1}}\sum_{k=1}^m\frac{a_{l+k}}{\sqrt2^k}\frac1{1-1/\sqrt2^{m}}.$$We may ensure that $l$ is positive by including, if necessary, the first cycle of $m$ terms of the periodic tail in the initial (pre-periodic) length-$l$ segment of the expansion. Since the terminal factor $1/(1-1/\sqrt2^{m})$ is either a positive rational number or the sum of a positive rational number and a positive rational multiple of $\sqrt2,$ the whole of the RHS of the above sum is of this form. Moreover it is not rational---because the initial segment (of length $l$) includes the first term $1/\sqrt2,$ and so the overall coefficient of $\sqrt2$ is at least $\frac12$. But the LHS is rational: a contradiction.
| 1 |
Calculate the supplementary question added in the edit
|
How to color lat/lon points in given RGB data?
|
I am using QGIS on a Mac.
I am working with hydroacoustic data for mapping and interpreting the seafloor.
Data are collected, processed and interpreted. The result is a txt file with Lat and Lon in the first columns followed by R, G and B data, e.g. [54.20,7.78,0.94,0.62,0.37]. The files can have 100,000 lines or more.
I am not really good in GIS but I need to use it for some reasons. I seem to be unable to plot these data in GIS. There is obviously no symbology/style way to tell the system to take the color values from a file (i.e. the next 3 values in the same line of the file). It is so easy in MatLab: scatter(lat, lon, symbolsize, [R G B]) but I can't work easily with multiple layers in Matlab.
|
The feature you want is implemented as "Data defined properties". See Data-defined Styles in QGIS for a first announcement.
It works for me this way:
Load the data as delimited text, and save it as a shapefile with CRS EPSG:4326 WGS84
Right-click on the layer -> Properties -> Style
Leave the topmost dropdown field at Single Symbol
Click on Simple Marker below
On the right, click on Data defined properties
Check Fill Color, then on the epsilon to the right
In the field top left, select color, then color_rgb
Click on Fields and Values, then on the field for red
add a comma
proceed with the green and blue field, and close the bracket
Click OK to leave the forms
My color values are between 0 and 255, but scaling that should be a minor problem for you...
N,E,R,G,B
54.20,7.78,239,158,94
51,8,129,72,122
50.5,7,123,34,55
50,6,23,210,233
51.5,8,233,14,140
52,7.5,23,25,100
53,6,100,23,23
52.5,7,200,40,10
| 1 |
Data defined properties in QGIS
|
How to Magento Debug
|
I have an extension that is giving me an endless loop, and I can't figure out the cause. I tried to follow this (Fundamentals for debugging a Magento store) but can't understand how to do it ? Can anyone help me ?
|
Your question is a little broad, but in general.
Figure out which controller and action method corresponds to the URL that triggers an endless loop
Look at the controller action and figure out how it is calling code in your extension
Add a series of exit(__FILE__ . '::' . __LINE__); lines until you pinpoint the section of code that's an endless loop.
| 0.777778 |
What controller and action method corresponds to the URL that triggers an endless loop?
|
Write a python script that goes through the links on a page recursively
|
I'm doing a project for my school in which I would like to compare scam mails. I found this website: http://www.419scam.org/emails/
Now what I would like to do is to save every scam in apart documents then later on I can analyse them.
Here is my code so far:
import BeautifulSoup, urllib2
address='http://www.419scam.org/emails/'
html = urllib2.urlopen(address).read()
f = open('test.txt', 'wb')
f.write(html)
f.close()
This saves me the whole html file in a text format, now I would like to strip the file and save the content of the html links to the scams:
<a href="2011-12/01/index.htm">01</a>
<a href="2011-12/02/index.htm">02</a>
<a href="2011-12/03/index.htm">03</a>
etc.
If i get that, I would still need to go a step further and open save another href. Any idea how do I do it in one python code?
Thank you!
|
You might also find value in requests and lxml.html. Requests is another way to make http requests and lxml is an alternative for parsing xml and html content.
There are many ways to search the html document but you might want to start with cssselect.
import requests
from lxml.html import fromstring
url = 'http://www.419scam.org/emails/'
doc = fromstring(requests.get(url).content)
atags = doc.cssselect('a')
# using .get('href', '') syntax because not all a tags will have an href
hrefs = (a.attrib.get('href', '') for a in atags)
Or as suggested in the comments using .iterlinks(). Note that you will still need to filter if you only want 'a' tags. Either way the .make_links_absolute() call is probably going to be helpful. It is your homework though, so play around with it.
doc.make_links_absolute(base_url=url)
hrefs = (l[2] for l in doc.iterlinks() if l[0].tag == 'a')
Next up for you... how to loop through and open all of the individual spam links.
| 0.777778 |
How to parse xml and html content?
|
How do I convert these headings into questions?
|
Sectional Differences Divide The Union
The Ongoing Debate over Slavery: 1850-1856
From Compromise to Crisis:1857-1861
Thanks for the help guys!
|
There's not really enough context to turn them into meaningful questions. The first two can be made into questions by adding what is/are, but without knowing what you're trying to ask there's not enough information here to help you.
What were the Sectional Differences that Divided The Union?
What is the Ongoing Debate over Slavery?
| 1 |
What were the Sectional Differences that Divided The Union?
|
Didn't Say Uno Before Running Out of Cards
|
So my family is having a disagreement on the uno rules. Here's what happened:
Player 1 completes turn by playing a regular numbered blue card
Player 2 has 3 cards left. Player 2 plays a blue skip, and plays a red skip. Player 2 has 1 card now. Player 2 plays their last card (a red numbered card).
They are out of cards, having played 3 cards really close together, with no chance for Player 1 to call them out on not saying uno. Player 1 calls it right after Player 2 has already run out of cards.
Here's the question - Player 2 is already out of cards, and never said Uno, and now Player 1 is calling them out on it. Has player 2 already won, or must Player 2 now take 2 cards?
|
From the rules, the hand is over.
http://www.wonkavator.com/uno/unorules.html
When you have one card left, you must yell "UNO" (meaning one).
Failure to do this results in you having to pick two cards from the
DRAW pile. That is, of course if you get caught by the other players.
Once a player has no cards left, the hand is over. Points are scored
(see scoring section) and you start over again. That's UNO in a
nutshell.
Further, you only have until the next player starts playing a card before it is to late to call them out. In this scenario once Player 2 started his 3rd turn (by starting the motion to play his last card), it was too late to call him out.
A player who forgets to say UNO before his card touches the discard
pile, but "catches" himself before any other player catches him, is
safe and is not subject to the penalty. You may not catch a player for
failure to say UNO until his second to last card touches the DISCARD
pile. Also, you may not catch a player for failure to say UNO after
the next player begins his turn. "Beginning a turn is defines as
either drawing a card from the DRAW pile or drawing a card from your
hand to play. If the last card played in a hand is a Draw Two or Wild
Draw Four card, the next player must draw the two or four cards. These
cards are counted when points are totaled. If no one is out of cards
by the time the DRAW pile is depleted, reshuffle and continue play.
In order to call out Player2 and force him to draw cards for not saying 'UNO', Player 1 would have had to say it directly after his second to last card was played (touched the discard pile) but before he started to play his last card. Incredibly short, but possible.
| 1 |
When you have one card left, you must yell "UNO" (meaning one)
|
Is AES key length a size of the key or entropy?
|
While educating my self I'm having hard time to understand what an 128 bit AES key actually means?
Is it a key length or entropy?
Please explain to me trough following example (assuming AES):
Password length in characters (L) = 20 (characters)
Symbols used (N) = 95 (ASCII set)
Entropy = log2 (N^L) = 128 (is this what is called 128bit AES key?)
OR
Key length = L * 8bits = 160 bit key length ? (is this supposed to
be 160bit AES key?)
When somebody says that he's using 128bit AES key, I want to know to what is he referring to, a key length or entropy?
|
When they say they are using a 128 bit AES key, they mean the length of the key is 128 bits. Technically a 128 bit AES key could have 0 bits of entropy, 128 bits of entropy, or anywhere in between.
To be secure, however, the 128 bit key should also have high entropy. Ideally, a 128 bit AES key would also have 128 bits of entropy.
A few side notes
Keep in mind that $\log_2N^L$ only computes the entropy in the key if the $L$ characters in the password were chosen randomly.
There is no such thing as a 160 bit AES key. AES supports key lengths of 128, 192, 256 bits.
| 0.888889 |
The length of a 128 bit AES key is 128 bits .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.