I have a JS object I use to store DOM info for easy reference in an elaborate GUI.
It starts like this:
var dom = {
m:{
old:{},
page:{x:0,y:0},
view:{x:0,y:0},
update:function(){
this.old = this;
this.page.x = $(window).width();
this.page.y = $(window).height();
this.view.x = $(document).width();
this.view.y = window.innerHeight || $(window).height();
}
I call the function on window resize:
$(window).resize(function(){dom.m.update()});
The problem is with dom.m.old. I would have thought that by calling it in the dom.m.update() method before the new values for the other properties are assigned, at any point in time dom.m.old would contain a snapshot of the dom.m object as of the last update – but instead, it's always identical to dom.m. I've just got a pointless recursion method.
Why isn't this working? How can I get a static snapshot of the object that won't update without being specifically told to?
Comments explaining how I shouldn't even want to be doing anything remotely like this in the first place are very welcome :)
Let's say I have this code:
val string = "one493two483three"
val pattern = """two(\d+)three""".r
pattern.findAllIn(string).foreach(println)
I expected findAllIn to only return 483, but instead, it returned two483three. I know I could use unapply to extract only that part, but I'd have to have a pattern for the entire string, something like:
val pattern = """one.*two(\d+)three""".r
val pattern(aMatch) = string
println(aMatch) // prints 483
Is there another way of achieving this, without using the classes from java.util directly, and without using unapply?
I'm quite new to Ubuntu, and I don't know how to fix this:
I have been experiencing the problem with window decorations that go away. I have been told that I could correct that with compiz fusion icon, just restarting the graphics whenever it happened. This solution only fixed the problem for like 30 seconds.
Then I found out that the command inside the window decorator had changed, so I only had to reset it to default (/usr/bin/compiz-decorator). The only problem is that it keeps changing the command by itself once or twice a day.
I can live with that, but I would like to find a more permanent solution, if there is one.
I am running Ubuntu 11.10
I'm using Ubuntu server 12.04 inside Virtualbox and everything was working as expected, but since I changed the mac address in Virtualbox network settings the network interface is not being recognized on Ubuntu.
I don't remember the old mac address and everytime Ubuntu starts shows
waiting for network configuration
when I use ifconfig only appears lo (loopback device) and eth0 is lost, how can I fix this problem?
There are similar questions for Linux and Mac, but I'm after a Windows solution here.
The problem is as follows: I want to write several (js) script files in a folder, and have a program monitor that folder for file changes and new files being added, and run a command whenever that happens (to compile them all into one single file).
The solution has to:
Monitor both file changes and new files being added, in a folder.
Run a command only if there is any change.
It would be best if it either is a built-in solution (like a JScript or VBscript snippet), or something that does not require installation.
I use a USB drive to play music in my car. Unfortunately, the car does not sort the music alphabetically and relies on how the music is sorted on the FAT32 drive.
This Windows software here solves the problem. Anything comparable available for me on Ubuntu?
PS: at first I thought it was a file creation date problem askubuntu question. But although I figured out the answer to that question, it didn't solve the problem like I thought it would.
I was finally able to connect to avasys.jp and downloaded and installed iscan_2.28.1-3.ltdl7_amd64.deb iscan-data_1.13.0-1_all.deb. The programs appeared to install correctly.
I then ran sane-find-scanner and got back:
found USB scanner (vendor=0x04b8, product=0x012d) at libusb:001:003
I then ran lsusb and got back:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 04b8:012d Seiko Epson Corp. Perfection V10/V100 (GT-S600/F650)
Bus 001 Device 004: ID 03f0:4817 Hewlett-Packard
Bus 002 Device 002: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
the avasys image scan manual instructed me to run
chmod 0666 /proc/bus/usb/001/003
which returned
chmod: cannot access `/proc/bus/usb/001/003': No such file or directory
In 12.04, no such directory exists. 12.04 appears to deal with USB in another way.
What must I do to get the usb port 001/003 recognized by xsane and sane as the port where the scanner can be located? What must I do to continue installing the scanner?
The popular PTS (Platform Technology Services) technical trainings for partners now include a workshop on Big Data.
First workshop will take place in Milan on July 10-12. (You can register by clicking the link below)
Oracle Big Data
Technical
Workshop
July
10-12,
2012: Cinisello Balsamo, Milan, Italy
For more info contact [email protected]
I have game play scene in which user can zoom in and out. For which I used smooth camera in the following manner.
public static final int CAMERA_WIDTH = 1024;
public static final int CAMERA_HEIGHT = 600;
public static final float MAXIMUM_VELOCITY_X = 400f;
public static final float MAXIMUM_VELOCITY_Y = 400f;
public static final float ZOOM_FACTOR_CHANGE = 1f;
mSmoothCamera = new SmoothCamera(0, 0, Constants.CAMERA_WIDTH,
Constants.CAMERA_HEIGHT, Constants.MAXIMUM_VELOCITY_X,
Constants.MAXIMUM_VELOCITY_Y, Constants.ZOOM_FACTOR_CHANGE);
mSmoothCamera.setBounds(0f, 0f, Constants.CAMERA_WIDTH,
Constants.CAMERA_HEIGHT);
But above thing create problem for me. When user perform zoom in and leave game play scene then other scene behaviour not look good. I already set zoom factor to 1 for this purpose. But now it show camera translation in other scene. Because scene switching time it so much small that player can easily saw translation of camera that I don't want to show. After camera reposition, everything works perfect but how to set camera its proper position.
For example my loading text move from bottom to top or vice versa based on camera movement.
Any more detail you want then I can able to give you.
I upgraded my libcups package to 1.6 in hopes to fix something but I just buggered things up more. So I want to reinstall it to the version on the repository (1.5.3 I think).
I've tried to do a reinstall using
~#: apt-get install --reinstall libcups2
but that tells me it cannot be downloaded so refuses to upgrade.
I can't just do:
~#: apt-get remove libcups2
~#: apt-get install libcups2
as that wants to remove 299 packages along with it. Totaling 668MB so I am hesitant as that will probably take 6 hours to download on my connection.
In order to track the overall user clickstream, I'd like to fire a javascript event, if the user right-clicks, and select "Open in new Tab" (or middle-clicks in most browsers) on a link. Most of these links are linking outside of my site, and I'd like to interfere with overall browser experience (such as: status bar, etc) as little as possible. What options are there to solve this?
I have this
batch.draw(currentFrame, x, y, this.parent.originX, this.parent.originY, this.parent.width, this.parent.height, this.scaleX, this.scaleY,this.rotation);
I want to apply the alpha that it gets from the method, but theres is not overload from the SpriteBatch class that takes the alpha value, is there some wey to apply it? (i did it this way, because this are animation, and i wanted to control them) in my static ones i apply
sprite.draw(SpriteBatch, alpha)
Thanks
Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
I have a collision detection and its working fine, the problem is, that whenever my "bird" is hitting a "cloud", the cloud dissapers and i get some points. The same happens for the "sol" which it should, but not with the clouds.
How can this be changed ? ive tryed a lot, but can seem to figger it out.
Collision Code
- (void)update:(ccTime)dt {
bird.position = ccpAdd(bird.position, skyVelocity);
NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init];
for (CCSprite *bird in _projectiles) {
bird.anchorPoint = ccp(0, 0);
CGRect absoluteBox = CGRectMake(bird.position.x, bird.position.y, [bird boundingBox].size.width, [bird boundingBox].size.height);
NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init];
for (CCSprite *cloudSprite in _targets) {
cloudSprite.anchorPoint = ccp(0, 0);
CGRect absoluteBox = CGRectMake(cloudSprite.position.x, cloudSprite.position.y, [cloudSprite boundingBox].size.width, [cloudSprite boundingBox].size.height);
if (CGRectIntersectsRect([bird boundingBox], [cloudSprite boundingBox])) {
[targetsToDelete addObject:cloudSprite];
}
}
for (CCSprite *solSprite in _targets) {
solSprite.anchorPoint = ccp(0, 0);
CGRect absoluteBox = CGRectMake(solSprite.position.x, solSprite.position.y, [solSprite boundingBox].size.width, [solSprite boundingBox].size.height);
if (CGRectIntersectsRect([bird boundingBox], [solSprite boundingBox])) {
[targetsToDelete addObject:solSprite];
score += 50/2;
[scoreLabel setString:[NSString stringWithFormat:@"%d", score]];
}
}
// NÅR SKYEN BLIVER RAMT AF FUGLEN
for (CCSprite *cloudSprite in targetsToDelete) {
//[_targets removeObject:cloudSprite];
//[self removeChild:cloudSprite cleanup:YES];
}
// NÅR SOLEN BLIVER RAMT AF FUGLEN
for (CCSprite *solSprite in targetsToDelete) {
[_targets removeObject:solSprite];
[self removeChild:solSprite cleanup:YES];
}
if (targetsToDelete.count > 0) {
[projectilesToDelete addObject:bird];
}
[targetsToDelete release];
}
// NÅR FUGLEN BLIVER RAMT AF ALT ANDET
for (CCSprite *bird in projectilesToDelete) {
//[_projectiles removeObject:bird];
//[self removeChild:bird cleanup:YES];
}
[projectilesToDelete release];
}
Two weeks ago, we attempted to make the URLs of ca. 12 pages more search-engine friendly. We changed three things.
1. Make URLs more SEF
from: /????-????/brandname.html (meaning: /aircon-price/daikin.html
to: /????-brandnameinenglish-brandnameinthai.html
We set up 301-redirects from the old to the new URLs. You can find an example and the link to our page here: http://bit.ly/XRoTOK There are no direct external links to the old URLs.
2. Added text to img-links from homepage to brand-pages
Before those changes, we only linked to those brands with a picture, so we added some text under the picture. You can see that here, in the left submenu: http://bit.ly/XRpfoF
3. Minor changes to Title, h1-Tags, Meta Description, etc.
Only minor changes, to better match the on-site optimization with targeted keywords. For example, before we used full brand names, after we used what was really searched for:
from: Mitsubishi Electric Mr. Slim
to: ???? Mitsubishi (means: Aircon Mitsubishi)
Three days after these changes, we noticed a heavy drop (80% loss in non-paid search traffic) in rankings and traffic for those pages, and also for all pages which are sub-categorized. Rankings for all keywords not affected by the changes stayed the same.
Any ideas, what happened, and how we can regain our old rankings? What we already did, was submitting a new sitemap.
Help much appreciated.
Best regards,
David
Hello,
I'm working on a multilingual website, and I want to generate the links in this way:
The site is domain.tld and defaults to English,
It has some subdomains like fr.domain.tld which will be in French, de.domain.tld which will be in German, it.domain.tld which will be in Italian...
when the current page is the index, the links to other languages will be like this:
domain.tld, fr.domain.tld, de.domain.tld, it.domain.tld....
But when we are in another page like domain.tld/my-page, how do we generate the URLs to match the current page but with another subdomain/language using PHP
There is a handy feature in most modern browsers that allows you to go back and see what pages you have visited on a particular day. But what if you don’t want your browser to keep track of your browsing history? Here’s how to disable it. How To Play DVDs on Windows 8 6 Start Menu Replacements for Windows 8 What Is the Purpose of the “Do Not Cover This Hole” Hole on Hard Drives?
I'm using Unity 3D
Let's say the player is an ice cube. You control it like a normal player. On press of a button, ice transforms (with animation) into water. You control it completely different than the ice cube.
Another great example would be: Player is human being and has normal FPS controls. On press of a button human transforms into birds and now has completely different controls.
Now, my question is, what would be easier and better:
make one object with animation transition and to stay in that state of anim. until button is pressed again
make two object: ice and water. Ice has an animation of turning into water. So replace ice (with animation) with water object
And if anyone knows this one too: how to switch between 2 different types of player controls.
IT security organizations are spending too much on data protection for compliance but not enough on securing key trade secrets, the real crown jewels of corporate data.
I found an updated version of John Gruber's regex for url matching in this post by user GianPac, which states it's been adapted to recognize url without protocol or the www part:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/?)(?:[^\s()<]+|(([^\s()<]+|(([^\s()<]+)))))(?:(([^\s()<]+|(([^\s()<]+))))|[^\s`!()[]{};:'\".,<?«»“”‘’]))
Whilst this works in most cases, I found it does not match "google.com". It does match "google.comm" and "google.co.uk", so this must be a small oversight.
The trouble is, I literally hate regex. It's the bane of my life. I just want to try and tweak this one more time to allow for "google.com" - can anyone throw me a pointer? I (think) it's something to do with this part of the code:
+[.][a-z]{2,4}/?)
?
I've read this Q&A and I'm ready to try it with Xubuntu. That is, I'll go from Ubuntu to Xubuntu.
At this moment, my laptop is slow, even after the various optimizations. My question is whether this is the correct way to proceed.
sudo apt-get upgrade # upgrade all existing packages to newest version
sudo do-release-upgrade # upgrade system (takes some hours)
sudo apt-get xubuntu-desktop # switch to Gnome on login
Remove the ubuntu-desktop package (Which command should I use?)
I'm trying to figure out how to get a string from an array starting at some given position. Say we have an array that's arbitrarily long and my string starts at location 1000. If I wanted to get a string from a file I would simply use something like getc or scanf or something. How do I carry out these same functions on an array instead of a file?
*oh, keep in mind that the array is of type int and is full of numerical representations of ASCII characters.
Im trying to make a program that captures a video from the webcam and sound from the microphone but im getting stuck at the part where ive try to make a movie out of still images
ive heard you need to use directshow but it doesnt jet work for me
Does someone know a good piece of example code that captures video and sound and can encode it to a file (divx or something like that) ?
or some suggestions where to look so i can build it myself
(if a other programming language is better for this im happy to know it early. )
In my last question i asked how to best send a string from one view controller to another, both which were on a navigation stack:
http://stackoverflow.com/questions/2898860/pass-string-from-tableviewcontroller-to-viewcontroller-in-navigation-stack
However I just realised I can either pass the path to the file in the app's document's folder as the first (the table view) has already accessed the data in the file should I pass viewcontroller the data to the pushed VC?