This file contains 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
package commands | |
import scala.sys._ | |
import play.api._ | |
import java.io.File | |
/** | |
* Run command in play environment. | |
* | |
* Assume, that we have in play 'app' directory subdirectory 'commands' |
This file contains 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
#include <stdio.h> | |
int main(int argc, char** argv) | |
{ | |
printf("sizeof(int)=%d, sizeof(long)=%d, sizeof(long long)=%d\n", sizeof(int), sizeof(long), sizeof(long long)); | |
long long check[3]; | |
check[0]=1; | |
printf("x1=%d, x2=%d, x3=%d\n", check[0],check[0],check[0]); | |
return 0; | |
} |
This file contains 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
File in = null; | |
File out = null; | |
try { | |
in = System.out(“input”,read); | |
try { | |
out = System.out(“out”, write); | |
copy(in,out) | |
} finally { | |
out.close(); | |
} |
This file contains 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
try { | |
in = System.openForRead(“name”); | |
out = System.openForWriting(“output”); | |
return copy(in,out); | |
} finally { | |
if (in!=null) { | |
try { | |
in.close(); | |
} finally { | |
if (out!=null) { |
This file contains 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
{ | |
auto in = File(“input”,"r"); | |
scope(exit){ in.close(); } | |
auto out = File(“output”,"w"); | |
scope(exit){ out.close(); } | |
out.copyFrom(in); | |
} |
This file contains 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
func CopyFile(dstName, srcName string) (written int64, err error) { | |
src, err := os.Open(srcName) | |
if err != nil { | |
return | |
} | |
defer src.Close() | |
dst, err := os.Create(dstName) | |
if err != nil { | |
return |
This file contains 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(students) { | |
var retval = [ ]; | |
for(var s in students) { | |
if (students.hasOwnProperty(s)) { | |
if (s.course == 4) { | |
retval.add(s.name) | |
} | |
} | |
} | |
return retval; |
This file contains 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(students) { | |
var retval = [ ]; | |
for(var s in students) { | |
if (students.hasOwnProperty(s)) { | |
if (students[s].course == 4) { | |
retval.add(students[s].name) | |
} | |
} | |
} | |
return retval; |
This file contains 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
object JobAction { | |
def apply(f: JobRequest => Result) = process(mustBeAuthenticated=false)(f) | |
def authenticated = process(mustBeAuthenticated=true) _ | |
def owner(id: ObjectId) = process(mustBeAuthenticated=true, optUserId = Option(id)) _ | |
def admin = process(mustBeAuthenticated=true, mustBeAdmin=true) _ |
This file contains 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
package controllers | |
import models.Account | |
import play.api.mvc._ | |
import org.bson.types.ObjectId | |
import play.api.mvc.Results._ | |
import play.api.i18n.Messages | |
object JobAction { |
OlderNewer