Skip to content

Instantly share code, notes, and snippets.

filters.source:
function(doc, req) {
if(!req.query.source)
throw("Please provide a query parameter `source`.");
if (doc.source && doc.source == req.query.source)
return true;
else
return false;
}
[Tue, 14 Sep 2010 05:44:03 GMT] [error] [<0.98.0>] {error_report,<0.30.0>,
{<0.98.0>,crash_report,
[[{pid,<0.98.0>},
{registered_name,[]},
{error_info,
{exit,
{{badmatch,{error,eacces}},
[{couch_file,init,1},
{gen_server,init_it,6},
{proc_lib,init_p_do_apply,3}]},
//Response produced when using no credentials,
//$ curl http://minion:5984/cgm/_fti/_design/couchapp/user
//
{"error":"unauthorized","reason":"You are not authorized to access this db."}
May your signals all trap
May your references be bounded
All memory aligned
Floats to ints rounded
Remember ...
Non-zero is true
++ adds one
Arrays start with zero
[root@limbo /]# chmod 777 /var/import/cass
[root@limbo /]# su hubprod -c "touch /var/import/cass/test.txt"
touch: cannot touch `/var/import/cass/test.txt': Permission denied
@MrTrick
MrTrick / gist:815611
Created February 8, 2011 00:44
Encryption / Decryption : Alice and Bob (and Eve!) [DRAFT]
Encryption / Decryption : Alice and Bob (and Eve!) [DRAFT]
Overview:
* Teams must devise a novel ciphering scheme in a short amount of time.
* Each team nominates a 'transmitter', who attempts to securely send a given message back to their team.
* Each team attempts to decode their own message, and intercept the messages of other teams.
Scenario:
Two types of documents (well four, but two in this use case)
Roles:
{
"_id": "role:00000390_student_11009_2010_AUT_U_1_S_group4",
"_rev": "1-82412c94266f8be1d4374313d586860d",
"doc_type": "role",
"source": "admin",
"status": "active",
"role_type": "student",
CREATE TABLE 'AcademicSubjectAssociation' (
'login' char(40) NOT NULL default '',
'subject' char(7) NOT NULL default '',
'year' int(11) NOT NULL default '2000',
'semester' char(10) NOT NULL default 'autumn', /* enum('autumn','winter','spring','summer') NOT NULL default 'autumn', */
'association' char(10) NOT NULL default 'tutor', /*enum('coordinator','assessor','lecturer','tutor','liaison','marker','admin','markedit','other','listowner','proposer','propadmin') NOT NULL default 'tutor',*/
UNIQUE ('login','subject','year','semester','association')
);
CREATE INDEX 'asa_login2' ON 'AcademicSubjectAssociation' ('login','subject','year','semester');
CREATE INDEX 'asa_login3' ON 'AcademicSubjectAssociation' ('login','subject');
@MrTrick
MrTrick / gist:958570
Created May 6, 2011 07:42
Updating the design document without blocking other users
[minion@minion cgm]$ php tools/update_couch_design.php
Access granted.
Building staging design...done.
Uploading staging design...done.
Rebuilding all views (this may take a long time, you can track progress in the futon status window) ... done. Elapsed time: 12 seconds
Rebuilding lucene views (this may take a long time, too) ... done. Elapsed time: 8 seconds
Uploading production design...done.
Checking view signatures...done. Both signatures are: 7bfe586167ab93ee5c5320833b336201
Testing a production view (this should be immediate) ...done. Elapsed time: 0 seconds
Testing a production lucene view (this should be immediate) ...done. Elapsed time: 8 seconds
<?
....
//Build and load the design into an object
echo "Building staging design...";
chdir('../install/couchapp');
$ddocstr = shell_exec('couchapp push --export');
$ddoc = json_decode($ddocstr);
$ddoc_staging = clone $ddoc;