<button id="click">Click Me</button>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var async1 = function(){
console.log('async1')
var dfd = new $.Deferred();
setTimeout(function(){
console.log('async1 resolved!')
dfd.resolve();
}, 5000);
return dfd.promise();
};
var async2 = function(){
console.log('async2')
var dfd = new $.Deferred();
setTimeout(function(){
console.log('async2 rejected')
dfd.reject();
}, 5000);
return dfd.promise();
};
var async3 = function(){
console.log('async3')
var dfd = new $.Deferred();
setTimeout(function(){
console.log('async3 resolved!')
dfd.resolve();
}, 5000);
return dfd.promise();
};
$('#click').on('click', function(){
async1()
.then(async2) //only fires if async1 resolves
.then(async3 /*only fires if async2 resolves*/, function(){
console.log('don\'t run 3 because 2 got rejected')//fires if anyone up the chain rejects
}).done(function(){ //only fires if the entire chain succeeds
console.log('done fired!')
}).fail(function(){ //only fires if someone in the chain rejects (every 'then' will continue to cascade, but will hit fail callbacks since subsequent 'thens' can't resolve )
console.log('fail fired')
}).always(function(){ //always fires
console.log('always fired')
})
});
});
</script>
Saturday, October 26, 2013
Firing Async Functions in order with $.Deferred
I have been spending quite a bit of time with deferreds and promises in Javascript, and just wanted to share what I have learned with chaining functions sequentially using JQuery's Deferred:
Friday, August 23, 2013
Making Samba Shares Browseable Across Computers and in Finder
I've been working on my new ethernet/wifi combo network setup at home, and i've recently decided to set up shared folders and a backup server hosted on a Raspberry Pi. I was able to configure Samba on each of the devices, ping each other from the terminal and mount drives across the network. One thing I really wanted to enable was making the shares browseable in the network menu of Ubuntu and in Mac's Finder. It turns out there was one simple setting I was missing.
According to the docs for Samba, the simplest way to enable this feature is to designate a WINS server which catalogs and broadcasts share information for all devices in a workgroup. First make sure each device is part of the same WINS WORKGROUP. Then, designate ONE device as the WINS server. I chose my Raspberry Pi backup server. Edit /etc/samba/smb.conf and include this line (or uncomment the existing line in the file):
Here are my global settings on the Pi:
According to the docs for Samba, the simplest way to enable this feature is to designate a WINS server which catalogs and broadcasts share information for all devices in a workgroup. First make sure each device is part of the same WINS WORKGROUP. Then, designate ONE device as the WINS server. I chose my Raspberry Pi backup server. Edit /etc/samba/smb.conf and include this line (or uncomment the existing line in the file):
domain master = yes
Again, make sure only one device has this line added to /etc/samba/smb.confHere are my global settings on the Pi:
[global]
workgroup = WORKGROUP
domain master = yes
server string = %h
wins support = no
dns proxy = no
security = share
encrypt passwords = yes
panic action = /usr/share/samba/panic-action %d
Wednesday, August 7, 2013
Monday, July 29, 2013
Ubuntu 13.04 on the Touchsmart Envy
So tonight I decided to try out Ubuntu 13.04 on my ultrabook by installing it on the unused internal SSD drive after dealing with several kernel panics on 12.04. So far it's much more stable and because it's on the SSD, it boots fast! I like it so far...
Monday, June 24, 2013
Monday, June 17, 2013
New Home Pics
As many of you know, we have been building a new home in West Jordan, Utah. I've been wanting to share pics of the progress, but haven't gotten around to it until now. I'll try to be better about posting more pics regularly going forward. It's come a long way and we are getting really excited for it to be complete.
hole in the ground
Pouring the foundation
Walls!
Stairwell
Back of House
Back
Master Bedroom
Great Room
Fireplace
Basement
Great Room
Great Room
Great Room From Kitchen
Living Room
Basement
Basement
Garage
Garage
Roof Is On
Living Room / Front Door
Living Room
Stairwell
Kitchen/Great Room
Great Room
Great Room
Master Bath
Master Closet
Master Bathroom
Master Bedroom
View from Backyard
2nd Bathroom
Bedroom
Bedroom
Bedroom
West Side of House
Backyard
Great Room
Kitchen Pantry
Fireplace
Great Room / Kitchen
Looking Towards Front Door
Stairs
2nd Bathroom
Bedroom
Bedroom
Master Bedroom
Hallway
Master Bedroom
Stone Accents
Subscribe to:
Posts (Atom)










































































