This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // trivial division | |
| h,i=2;g(j){return j*j>i||i%j++&&g(j);}main(){scanf("%i",&h);for(;h;i++)g(2)&&printf("%i ",i,--h);} | |
| // Wilson's Theory | |
| h,i;m(n){return n?n*m(n-1)%i:1;}main(){scanf("%i",&h);for(;h;)m(i++)+1-i||printf("%i ",i,--h);} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; removal | |
| UPDATE page | |
| , (SELECT category_id as oldcategory, page_order as oldorder FROM page WHERE id = :pgid) as t2 | |
| SET page.page_order = CASE | |
| WHEN id = :pgid THEN -1 | |
| WHEN page.category_id = t2.oldcategory | |
| AND page.page_order > t2.oldorder | |
| THEN page.page_order-1 | |
| ELSE page.page_order | |
| END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE page, (SELECT pageorder as oldorder FROM page WHERE id = :pgid) as t2 SET page.pageorder = CASE | |
| WHEN id = :pgid THEN :neworder | |
| WHEN page.pageorder <= :neworder AND page.pageorder > t2.oldorder THEN page.pageorder-1 | |
| WHEN page.pageorder >= :neworder AND page.pageorder < t2.oldorder THEN page.pageorder+1 | |
| ELSE page.pageorder | |
| END | |
| WHERE page.pageorder >= LEAST(:neworder, t2.oldorder) AND page.pageorder <= GREATEST(:neworder, t2.oldorder); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function privateHandlePut(req, res) { | |
| // do things | |
| } | |
| function publicHandleGet(req, res) { | |
| // do things | |
| } | |
| export.controller = { | |
| publicHandleGet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| universe: everything that isn't this software | |
| can only interface with software through the shell | |
| - user | |
| - monitor | |
| - browser | |
| - database | |
| - file system | |
| - external API | |
| - API on the same machine but different piece of software | |
| - sensors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Bluebird from 'bluebird'; | |
| // assume express, promise-ready ORM (Sequelize, Bookshelf, Mongoose) | |
| function wrap(genFn) { | |
| var cr = Bluebird.coroutine(genFn); | |
| return function (req, res, next) { | |
| cr(req, res, next).catch(next); | |
| } | |
| } |
NewerOlder