Skip to content

Instantly share code, notes, and snippets.

View dancrew32's full-sized avatar
🕶️
🕶

Dan Masquelier dancrew32

🕶️
🕶
View GitHub Profile
@sandro
sandro / bookmarklet_template.js
Created January 29, 2009 05:01
bookmarklet template
// TODO: remove spaces and newlines
javascript:(function(){
s=document.createElement('script');
s.type='text/javascript';
s.src='http://example.com/bookmarklet.js';
document.body.appendChild(s);
})();
// TODO: bookmarklet code needs to be in an anchor tag
// <a href="javascript:(function(){s=document.createElement('script');s.type='text/javascript';s.src='http://example.com/bookmarklet.js';document.body.appendChild(s);})();">My Bookmarklet</a>
@devinus
devinus / gist:453520
Created June 25, 2010 22:09
A Natural Sorting Comparator for JavaScript's Array.prototype.sort
var NUMBER_GROUPS = /(-?\d*\.?\d+)/g;
var naturalSort = function (a, b) {
var aa = String(a).split(NUMBER_GROUPS),
bb = String(b).split(NUMBER_GROUPS),
min = Math.min(aa.length, bb.length);
for (var i = 0; i < min; i++) {
var x = parseFloat(aa[i]) || aa[i].toLowerCase(),
y = parseFloat(bb[i]) || bb[i].toLowerCase();
@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@stagas
stagas / how-to-run-apache-and-node.js-together-the-right-way.markdown
Created December 24, 2010 14:45
How to run Apache and Node.js together (the right way)

Step 1

Get a VPS that offers 2 or more IP addresses.

Step 2

From the WHM cPanel, find the menu item Service Configuration, select Apache Configuration and then click on Reserved IPs Editor.

Step 3

<div id="slideshow">
<img src="http://farm6.static.flickr.com/5243/5373962623_0e23ed169b_t.jpg">
<img src="http://farm6.static.flickr.com/5007/5374562138_30e01a767f_t.jpg" style="display:none">
<img src="http://farm6.static.flickr.com/5288/5374562162_d48ca16567_t.jpg" style="display:none">
<img src="http://farm6.static.flickr.com/5084/5374562208_3e1bbe58cc_t.jpg" style="display:none">
<img src="http://farm6.static.flickr.com/5086/5374562182_5ec5c14403_t.jpg" style="display:none">
</div>
<script type="text/javascript">
var ims = document.getElementById('slideshow').children;
@cloudhead
cloudhead / gist:967157
Created May 11, 2011 19:38
LESS v1.1.0 - What's new

LESS v1.1.0 - What's new

@arguments special variable:

  .box-shadow () { -webkit-box-shadow: @arguments }

string interpolation:

content: "hello @{var}"; // replaced with value of @var

@jonashaag
jonashaag / 0-howto-listfield-django-admin.rst
Created September 7, 2011 09:41
Howto use ListFields in Django's admin

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py

@jkeyes
jkeyes / gist:1242040
Created September 26, 2011 11:20
Compile LESS files when a save is detected
#!/bin/bash
watchmedo shell-command --patterns="*.less" --command=\
'LESS=`echo "${watch_src_path}" | sed s/.less/.css/`; \
echo compile: "${watch_src_path}";\
lessc "${watch_src_path}" "${LESS}"; \
if [ "$?" -eq "0" ]; then echo wrote: "${LESS}"; fi' $*
@ecoleman
ecoleman / gist:1525027
Created December 27, 2011 20:26
hide php variables in tagbar.vim
let g:tagbar_type_php = {
\ 'ctagstype' : 'php',
\ 'kinds' : [
\ 'i:interfaces',
\ 'c:classes',
\ 'd:constant definitions',
\ 'f:functions',
\ 'j:javascript functions:1'
\ ]
@timkelty
timkelty / config.rb
Created January 11, 2012 15:28
Compass config.rb
# Note that while this file is in our config folder, it is
# symlinked to our site folders, so paths are relative from there
# Require gems and Compass plugins
# require 'rgbapng'
# require 'compass-fancybox-plugin'
require 'compass-growl'
# General
output_style = :expanded