The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| PASSWORD_PATH = ".password" | |
| PASSWORD_ID_PATH = ".password_id" | |
| # Make sure to have installed vagrant-triggers plugin | |
| # > vagrant plugin install vagrant-triggers | |
| # After the first `vagrant up` stop the VM and execute the following steps |
| exports.arity_decorator = function(fun) { | |
| function wrapped() { | |
| if(arguments.length != fun.length) | |
| throw new Error("Y U NO USE RIGHT?!") | |
| fun.apply(this, arguments) | |
| } | |
| return wrapped; | |
| } | |
| > function foo(x,y) { | |
| if(arguments.length > 2) throw new Error("Stupid no method overloading lameness error"); | |
| ... args = Array.prototype.join.call(arguments, ","); | |
| ... console.log('X:' + x + ' Y:' + y + ' Args:' + args) | |
| ... } | |
| > foo(1,2) | |
| X:1 Y:2 Args:1,2 | |
| > foo(1,2,3,4,5) | |
| X:1 Y:2 Args:1,2,3,4,5 |
| #!/usr/bin/env python | |
| """ | |
| Add php-serve.py to your PATH, then, from whatever directory is the root | |
| of your PHP application, just run: | |
| $ php-serve.py | |
| You can optionally specify a port number as an argument. By default, | |
| port 8000 is used: |
| var partial = exports.partial = function partial(fn) { | |
| var args = arguments, | |
| func = fn; | |
| [].shift.apply(args); | |
| return function() { | |
| var _args = args; | |
| [].push.apply(_args, arguments); | |
| return func.apply(func, _args); | |
| }; | |
| }; |
| #!/usr/bin/env python | |
| ### Requires latest boto (cuz I checked in code to boto a moment ago) | |
| import uuid | |
| from boto.mturk.connection import MTurkConnection | |
| from boto.mturk.question import Question, QuestionForm, QuestionContent | |
| from boto.mturk.question import AnswerSpecification, FreeTextAnswer | |
| from boto.mturk.question import Overview | |
| #from boto.mturk.qualification import Qualifications # these exist! |
| import pylibmc | |
| import Queue | |
| import logging | |
| import functools | |
| """ | |
| This is a transparent pool library that wraps a pylibmc client | |
| from MemcachePool import mc | |
| mc.get(key) |
| javascript:(function(){setInterval(function(){var%20i,a,s;a=document.getElementsByTagName('link');for(i=0;%20i<a.length;%20i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href){var%20h=s.href.replace(/(&|\?)forceReload\=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new%20Date().valueOf())}}},3000)})() |