Skip to content

Instantly share code, notes, and snippets.

sqlite> SELECT * FROM ENTRIES_TAGS WHERE TAG_ID IN (58, 59);
140|58
141|59
142|58
142|59
sqlite> SELECT DISTINCT ENTRIES.ID FROM ENTRIES INNER JOIN ENTRIES_TAGS ON (ENTRIES.ID = ENTRIES_TAGS.ENTRY_ID) WHERE ENTRIES_TAGS.TAG_ID = 59 INTERSECT SELECT DISTINCT ENTRIES.ID FROM ENTRIES INNER JOIN ENTRIES_TAGS ON (ENTRIES.ID = ENTRIES_TAGS.ENTRY_ID) WHERE ENTRIES_TAGS.TAG_ID = 58;
142
@madrobby
madrobby / gist:30223
Created November 29, 2008 10:34 — forked from dhh/gist:29752
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
var s2 = {
Version: '2.0.0a1'
};
s2.fx = new (function(){
var queues = [], globalQueue, heartbeat, activeEffectCount = 0;
this.beatOnDemand = function(dir){
heartbeat[(activeEffectCount += dir) > 0 ? 'start' : 'stop']();
};
Coming soon from yours truly and Amy Hoy!
As a special thank you for my regular readers (you!), <a href="http://javascriptrocks.com/">sign up for the announcement email and get $5 off the regular price</a> when the beta book is out!
<a href="http://javascriptrocks.com/"><img src="http://javascriptrocks.com/coming-soon-opt.png"/></a>
The book will cover all sorts of topics around JavaScript performance, from perceptive loading performance all the way down to selecting between if and case statements.
It's library/framework agnostic, so whether you use Prototype, jQuery, Mootools or any other libs, you'll find that you'll be able to provide faster-loading, better performing JavaScript to your users.
def pack_file(source, target)
puts `java -jar lib/yuicompressor-2.4.1.jar -v #{source} -o #{target}`
`gzip -9 #{target} -c > #{target}.gzip`
puts "#{source}: #{'%.1f' % (File.size(source)/1024.0)}k"
puts "Packed: #{'%.1f' % (File.size(target)/1024.0)}k"
puts "Packed+GZIP: #{'%.1f' % (File.size(target+'.gzip')/1024.0)}k"
puts
end
s2.css = {
PROPERTY_MAP: {
backgroundColor: 'color',
borderBottomColor: 'color',
borderBottomWidth: 'length',
borderLeftColor: 'color',
borderLeftWidth: 'length',
borderRightColor: 'color',
borderRightWidth: 'length',
borderSpacing: 'length',
s2.fx.Opacity = Class.create(s2.fx.Element, {
setup: function() {
var from = this.options.from || 0, to = this.options.to || 1;
this.element.setStyle('opacity:'+from);
this.animate('style', this.element, { style: 'opacity:'+to });
}
});
(function() {
/** section: DOM
* Event
*
* The namespace for Prototype's event system.
*
* <h4>Events: a fine mess</h4>
*
* Event management is one of the really sore spots of cross-browser
var ObjectRange = Class.create(Enumerable, (function() {
function initialize(start, end, exclusive) {
// ...
}
function _each(iterator) {
// ...
}
function include(value) {
var CreditCard = {
CARDS: {
Visa: /^4[0-9]{12}(?:[0-9]{3})?$/,
MasterCard: /^5[1-5][0-9]{14}$/,
DinersClub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
Amex: /^3[47][0-9]{13}$/,
Discover: /^6(?:011|5[0-9]{2})[0-9]{12}$/
},
TEST_NUMBERS: $w('378282246310005 371449635398431 378734493671000 '+
'30569309025904 38520000023237 6011111111111117 '+