code
stringlengths
1
2.08M
language
stringclasses
1 value
CodeMirror.defineMode("python", function(conf, parserConf) { var ERRORCLASS = 'error'; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]"); var singleDelimiters = pa...
JavaScript
/* * Pig Latin Mode for CodeMirror 2 * @author Prasanth Jayachandran * @link https://github.com/prasanthj/pig-codemirror-2 * This implementation is adapted from PL/SQL mode in CodeMirror 2. */ CodeMirror.defineMode("pig", function(_config, parserConfig) { var keywords = parserConfig.keywords, ...
JavaScript
CodeMirror.modeInfo = [ {name: 'APL', mime: 'text/apl', mode: 'apl'}, {name: 'Asterisk', mime: 'text/x-asterisk', mode: 'asterisk'}, {name: 'C', mime: 'text/x-csrc', mode: 'clike'}, {name: 'C++', mime: 'text/x-c++src', mode: 'clike'}, {name: 'Cobol', mime: 'text/x-cobol', mode: 'cobol'}, {name: 'Java', mime...
JavaScript
CodeMirror.defineMode("sass", function(config) { var tokenRegexp = function(words){ return new RegExp("^" + words.join("|")); }; var keywords = ["true", "false", "null", "auto"]; var keywordsRegexp = new RegExp("^" + keywords.join("|")); var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\...
JavaScript
CodeMirror.defineMode("apl", function() { var builtInOps = { ".": "innerProduct", "\\": "scan", "/": "reduce", "⌿": "reduce1Axis", "⍀": "scan1Axis", "¨": "each", "⍣": "power" }; var builtInFuncs = { "+": ["conjugate", "add"], "−": ["negate", "subtract"], "×": ["signOf", "mu...
JavaScript
CodeMirror.defineMode("diff", function() { var TOKEN_NAMES = { '+': 'positive', '-': 'negative', '@': 'meta' }; return { token: function(stream) { var tw_pos = stream.string.search(/[\t ]+?$/); if (!stream.sol() || tw_pos === 0) { stream.skipToEnd(); return ("error "...
JavaScript
CodeMirror.defineMode("turtle", function(config) { var indentUnit = config.indentUnit; var curPunc; function wordRegexp(words) { return new RegExp("^(?:" + words.join("|") + ")$", "i"); } var ops = wordRegexp([]); var keywords = wordRegexp(["@prefix", "@base", "a"]); var operatorChars = /[*+\-<>=&|]/...
JavaScript
CodeMirror.defineMode("xml", function(config, parserConfig) { var indentUnit = config.indentUnit; var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1; var Kludges = parserConfig.htmlMode ? { autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, ...
JavaScript
/** * Link to the project's GitHub page: * https://github.com/pickhardt/coffeescript-codemirror-mode */ CodeMirror.defineMode('coffeescript', function(conf) { var ERRORCLASS = 'error'; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b"); } var singleOperators...
JavaScript
CodeMirror.defineMode("gfm", function(config) { var codeDepth = 0; function blankLine(state) { state.code = false; return null; } var gfmOverlay = { startState: function() { return { code: false, codeBlock: false, ateSpace: false }; }, copyState: function(...
JavaScript
(function() { var mode = CodeMirror.getMode({tabSize: 4}, "gfm"); function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } MT("emInWordAsterisk", "foo[em *bar*]hello"); MT("emInWordUnderscore", "foo_bar_hello"); MT("emStrongUnderscore", "[strong __][em&strong _f...
JavaScript
// TODO actually recognize syntax of TypeScript constructs CodeMirror.defineMode("javascript", function(config, parserConfig) { var indentUnit = config.indentUnit; var jsonMode = parserConfig.json; var isTS = parserConfig.typescript; // Tokenizer var keywords = function(){ function kw(type) {return {ty...
JavaScript
//mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara CodeMirror.defineMIME("text/mirc", "mirc"); CodeMirror.defineMode("mirc", function() { function parseWords(str) { var obj = {}, words = str.split(" "); for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } var...
JavaScript
CodeMirror.defineMode("velocity", function() { function parseWords(str) { var obj = {}, words = str.split(" "); for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } var keywords = parseWords("#end #else #break #stop #[[ #]] " + "#{...
JavaScript
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { var htmlFound = CodeMirror.modes.hasOwnProperty("xml"); var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain"); var aliases = { html: "htmlmixed", js: "javascript", json: "application/json", c...
JavaScript
(function() { var mode = CodeMirror.getMode({tabSize: 4}, "markdown"); function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } MT("plainText", "foo"); // Code blocks using 4 spaces (regardless of CodeMirror.tabSize value) MT("codeBlocksUsing4Spaces", " [comment fo...
JavaScript
CodeMirror.defineMode("gas", function(_config, parserConfig) { 'use strict'; // If an architecture is specified, its initialization function may // populate this array with custom parsing functions which will be // tried in the event that the standard functions do not find a match. var custom = []; // The...
JavaScript
CodeMirror.defineMode("sql", function(config, parserConfig) { "use strict"; var client = parserConfig.client || {}, atoms = parserConfig.atoms || {"false": true, "true": true, "null": true}, builtin = parserConfig.builtin || {}, keywords = parserConfig.keywords || {}...
JavaScript
CodeMirror.defineMode('z80', function() { var keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i; var keywords2 = /^(call|j[pr]|ret[in]?)\b/i; var keywords3 = /^b_?(call|jump)\...
JavaScript
// Don't take these too seriously -- the expected results appear to be // based on the results of actual runs without any serious manual // verification. If a change you made causes them to fail, the test is // as likely to wrong as the code. (function() { var mode = CodeMirror.getMode({tabSize: 4}, "xquery"); fun...
JavaScript
/* Copyright (C) 2011 by MarkLogic Corporation Author: Mike Brevoort <mike@brevoort.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the right...
JavaScript
CodeMirror.defineMode("http", function() { function failFirstLine(stream, state) { stream.skipToEnd(); state.cur = header; return "error"; } function start(stream, state) { if (stream.match(/^HTTP\/\d\.\d/)) { state.cur = responseStatusCode; return "keyword"; } else if (stream.mat...
JavaScript
CodeMirror.defineMode("jinja2", function() { var keywords = ["block", "endblock", "for", "endfor", "in", "true", "false", "loop", "none", "self", "super", "if", "as", "not", "and", "else", "import", "with", "without", "context"]; keywords = new RegExp("^((" + keywords.joi...
JavaScript
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) { var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true}); var cssMode = CodeMirror.getMode(config, "css"); var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes; scriptTypes.push({matches: /^(?:text|a...
JavaScript
CodeMirror.defineMode("properties", function() { return { token: function(stream, state) { var sol = stream.sol() || state.afterSection; var eol = stream.eol(); state.afterSection = false; if (sol) { if (state.nextMultiline) { state.inMultiline = true; state.n...
JavaScript
// block; "begin", "case", "fun", "if", "receive", "try": closed by "end" // block internal; "after", "catch", "of" // guard; "when", closed by "->" // "->" opens a clause, closed by ";" or "." // "<<" opens a binary, closed by ">>" // "," appears in arglists, lists, tuples and terminates lines of code // "." resets in...
JavaScript
CodeMirror.defineMode("vb", function(conf, parserConf) { var ERRORCLASS = 'error'; function wordRegexp(words) { return new RegExp("^((" + words.join(")|(") + "))\\b", "i"); } var singleOperators = new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]"); var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\...
JavaScript
CodeMirror.defineMode('tiki', function(config) { function inBlock(style, terminator, returnTokenizer) { return function(stream, state) { while (!stream.eol()) { if (stream.match(terminator)) { state.tokenize = inText; break; } stream.next(); } if (ret...
JavaScript
CodeMirror.defineMode("rust", function() { var indentUnit = 4, altIndentUnit = 2; var valKeywords = { "if": "if-style", "while": "if-style", "else": "else-style", "do": "else-style", "ret": "else-style", "fail": "else-style", "break": "atom", "cont": "atom", "const": "let", "resource": "fn", "let": ...
JavaScript
CodeMirror.defineMode("d", function(config, parserConfig) { var indentUnit = config.indentUnit, statementIndentUnit = parserConfig.statementIndentUnit || indentUnit, keywords = parserConfig.keywords || {}, builtin = parserConfig.builtin || {}, blockKeywords = parserConfig.blockKeywords || {}, ...
JavaScript
/*** |''Name''|tiddlywiki.js| |''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror| |''Author''|PMario| |''Version''|0.1.7| |''Status''|''stable''| |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]| |''Documentation''|http://code...
JavaScript
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's // CodeMirror 1 mode. // highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting CodeMirror.defineMode("lua", function(config, parserConfig) { var indentUnit = config.indentUnit; function prefixRE(words) { ...
JavaScript
/* * See LICENSE in this directory for the license under which this code * is released. */ CodeMirror.defineMode("sieve", function(config) { function words(str) { var obj = {}, words = str.split(" "); for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } var keywords = words(...
JavaScript
CodeMirror.defineMode("commonlisp", function (config) { var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/; var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/; var symbol = /[^\s'`,@()\[\]";]/; var type;...
JavaScript
CodeMirror.defineMode("changes", function() { var headerSeperator = /^-+$/; var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /; var simpleEmail = /^[\w+.-]+@[\w.-]+/; return { token: function(stream) { ...
JavaScript
// Quick and dirty spec file highlighting CodeMirror.defineMode("spec", function() { var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/; var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|Au...
JavaScript
CodeMirror.defineMode("r", function(config) { function wordObj(str) { var words = str.split(" "), res = {}; for (var i = 0; i < words.length; ++i) res[words[i]] = true; return res; } var atoms = wordObj("NULL NA Inf NaN NA_integer_ NA_real_ NA_complex_ NA_character_"); var builtins = wordObj("list q...
JavaScript
CodeMirror.defineMode("haskell", function() { function switchState(source, setState, f) { setState(f); return f(source, setState); } // These should all be Unicode extended, as per the Haskell 2010 report var smallRE = /[a-z_]/; var largeRE = /[A-Z]/; var digitRE = /[0-9]/; var hexitRE = /[0-9A-...
JavaScript
CodeMirror.defineMode('rst-base', function (config) { /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// function format(string) { var args = Array.prototype.slice.call(arguments, 1); retur...
JavaScript
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara CodeMirror.defineMode("tcl", function() { function parseWords(str) { var obj = {}, words = str.split(" "); for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } var keywords = parseWords("Tcl safe after append ...
JavaScript
CodeMirror.defineMode("go", function(config) { var indentUnit = config.indentUnit; var keywords = { "break":true, "case":true, "chan":true, "const":true, "continue":true, "default":true, "defer":true, "else":true, "fallthrough":true, "for":true, "func":true, "go":true, "goto":true, "if":true, "import":...
JavaScript
CodeMirror.defineMode("vbscript", function() { var regexVBScriptKeyword = /^(?:Call|Case|CDate|Clear|CInt|CLng|Const|CStr|Description|Dim|Do|Each|Else|ElseIf|End|Err|Error|Exit|False|For|Function|If|LCase|Loop|LTrim|Next|Nothing|Now|Number|On|Preserve|Quit|ReDim|Resume|RTrim|Select|Set|Sub|Then|To|Trim|True|UBound|UC...
JavaScript
(function() { var mode = CodeMirror.getMode({tabSize: 4}, "text/x-scss"); function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); } MT('url_with_quotation', "[tag foo] { [property background][operator :][string-2 url]([string test.jpg]) }"); MT('url_with_double_quotes'...
JavaScript
(function() { var mode = CodeMirror.getMode({tabSize: 4}, "css"); function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } // Requires at least one media query MT("atMediaEmpty", "[def @media] [error {] }"); MT("atMediaMultiple", "[def @media] [keyword not] [attribute...
JavaScript
CodeMirror.defineMode("css", function(config) { return CodeMirror.getMode(config, "text/css"); }); CodeMirror.defineMode("css-base", function(config, parserConfig) { "use strict"; var indentUnit = config.indentUnit, hooks = parserConfig.hooks || {}, atMediaTypes = parserConfig.atMediaTypes || {}, ...
JavaScript
/* LESS mode - http://www.lesscss.org/ Ported to CodeMirror by Peter Kroon <plakroon@gmail.com> Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues GitHub: @peterkroon */ CodeMirror.defineMode("less", function(config) { var indentUnit = config.indentUnit, type; function ret(style, tp) {typ...
JavaScript
/** * Author: Hans Engel * Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun) */ CodeMirror.defineMode("clojure", function () { var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2", ATOM = "atom", NUMBER = "number", BRACKET = ...
JavaScript
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08) // This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com) CodeMirror.defineMode("perl",function(){ // http://perldoc.perl.org var PERL={ // null - magi...
JavaScript
CodeMirror.defineMode('smalltalk', function(config) { var specialChars = /[+\-\/\\*~<>=@%|&?!.,:;^]/; var keywords = /true|false|nil|self|super|thisContext/; var Context = function(tokenizer, parent) { this.next = tokenizer; this.parent = parent; }; var Token = function(name, context, eos) { th...
JavaScript
CodeMirror.defineMode("haxe", function(config, parserConfig) { var indentUnit = config.indentUnit; // Tokenizer var keywords = function(){ function kw(type) {return {type: type, style: "keyword"};} var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); var operator = kw("operator"), atom...
JavaScript
// CodeMirror version 3.13 // // CodeMirror is the only global var we claim window.CodeMirror = (function() { "use strict"; // BROWSER SNIFFING // Crude, but necessary to handle a number of hard-to-feature-detect // bugs and behavior differences. var gecko = /gecko\/\d/i.test(navigator.userAgent); var ie ...
JavaScript
// TODO number prefixes (function() { // Really primitive kill-ring implementation. var killRing = []; function addToRing(str) { killRing.push(str); if (killRing.length > 50) killRing.shift(); } function getFromRing() { return killRing[killRing.length - 1] || ""; } function popFromRing() { if (killR...
JavaScript
/** * Supported keybindings: * * Motion: * h, j, k, l * gj, gk * e, E, w, W, b, B, ge, gE * f<character>, F<character>, t<character>, T<character> * $, ^, 0, -, +, _ * gg, G * % * '<character>, `<character> * * Operator: * d, y, c * dd, yy, cc * g~, g~g~ * >, <, >>, << * *...
JavaScript
(function() { // A minilanguage for instantiating linked CodeMirror instances and Docs function instantiateSpec(spec, place, opts) { var names = {}, pos = 0, l = spec.length, editors = []; while (spec) { var m = spec.match(/^(\w+)(\*?)(?:='([^\']*)'|<(~?)(\w+)(?:\/(\d+)-(\d+))?)\s*/); var name =...
JavaScript
var tests = [], debug = null, debugUsed = new Array(), allNames = []; function Failure(why) {this.message = why;} Failure.prototype.toString = function() { return this.message; }; function indexOf(collection, elt) { if (collection.indexOf) return collection.indexOf(elt); for (var i = 0, e = collection.length; i <...
JavaScript
var Pos = CodeMirror.Pos; function forEach(arr, f) { for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]); } function addDoc(cm, width, height) { var content = [], line = ""; for (var i = 0; i < width; ++i) line += "x"; for (var i = 0; i < height; ++i) content.push(line); cm.setValue(content.join("\n")); }...
JavaScript
#!/usr/bin/env node var lint = require("./lint/lint"); lint.checkDir("mode"); lint.checkDir("lib"); lint.checkDir("addon"); var ok = lint.success(); var files = new (require('node-static').Server)('.'); var server = require('http').createServer(function (req, res) { req.addListener('end', function () { files...
JavaScript
/** * Helper to test CodeMirror highlighting modes. It pretty prints output of the * highlighter and can check against expected styles. * * Mode tests are registered by calling test.mode(testName, mode, * tokens), where mode is a mode object as returned by * CodeMirror.getMode, and tokens is an array of lines tha...
JavaScript
var page = require('webpage').create(); page.open("http://localhost:3000/test/index.html", function (status) { if (status != "success") { console.log("page couldn't be loaded successfully"); phantom.exit(1); } waitFor(function () { return page.evaluate(function () { var output = document.getEle...
JavaScript
// AST walker module for Mozilla Parser API compatible trees (function(exports) { "use strict"; // A simple walk is one where you simply specify callbacks to be // called on specific nodes. The last two arguments are optional. A // simple use would be // // walk.simple(myTree, { // Expressio...
JavaScript
/* Simple linter, based on the Acorn [1] parser module All of the existing linters either cramp my style or have huge dependencies (Closure). So here's a very simple, non-invasive one that only spots - missing semicolons and trailing commas - variables or properties that are reserved words - assigning to a ...
JavaScript
/*********************************************************************** A JavaScript tokenizer / parser / beautifier / compressor. This version is suitable for Node.js. With minimal changes (the exports stuff) it should work on any JS platform. This file contains the tokenizer/parser. It is a port to Java...
JavaScript
// Acorn is a tiny, fast JavaScript parser written in JavaScript. // // Acorn was written by Marijn Haverbeke and released under an MIT // license. The Unicode regexps (for identifiers and whitespace) were // taken from [Esprima](http://esprima.org) by Ariya Hidayat. // // Git repositories for Acorn are available at //...
JavaScript
namespace = "comment_"; (function() { function test(name, mode, run, before, after) { return testCM(name, function(cm) { run(cm); eq(cm.getValue(), after); }, {value: before, mode: mode}); } var simpleProg = "function foo() {\n return bar;\n}"; test("block", "javascript", function(cm) { ...
JavaScript
var code = '' + ' wOrd1 (#%\n' + ' word3] \n' + 'aopop pop 0 1 2 3 4\n' + ' (a) [b] {c} \n' + 'int getchar(void) {\n' + ' static char buf[BUFSIZ];\n' + ' static char *bufp = buf;\n' + ' if (n == 0) { /* buffer is empty */\n' + ' n = read(0, buf, sizeof buf);\n' + ' bufp = buf;\n' + ' }\n' + '\n' + ' return ...
JavaScript
/**@license *| __ _____ ________ __ *| / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / / *| __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / *| / / // // // // // ___// / / // / / // ___// / / / / // // /\ /...
JavaScript
/*! * jQuery Form Plugin * version: 3.27.0-2013.02.06 * @requires jQuery v1.5 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Project repository: https://github.com/malsup/form * Dual licensed under the MIT and GPL licenses: * http://malsup.github.com/mit-license.txt * http:/...
JavaScript
/* ### jQuery Star Rating Plugin v4.11 - 2013-03-14 ### * Home: http://www.fyneworks.com/jquery/star-rating/ * Code: http://code.google.com/p/jquery-star-rating-plugin/ * * Licensed under http://en.wikipedia.org/wiki/MIT_License ### */ /*# AVOID COLLISIONS #*/ ;if(window.jQuery) (function($){ /*# AVOID COLLISION...
JavaScript
function table( filas, columnas ) { var tabla="table"; var celda="td"; var fila="tr"; for ( i=1; i<=filas; i++ ) { print( "<"+fila+">"); for ( j=1; j<=columnas; j++ ) { print ("<"+celda+">fila "+i+" columna "+i+"</"+celda+">"); } print ("</"+fila+">\n"); } print ("</"+tabla+">"); }
JavaScript
$(document).ready(function() { $("#contador").change(function(){ $.post('/contador/'+$('#contador').val(), function( data) { $('#Resultado').html('Resultado '+ data.resultado); }); }); $("#creador").change(function(){ $.ajax({ type: "PUT", url: '/contador/'+$('#creador').val...
JavaScript
var express=require('express'); var app = express.createServer(); var contadores = new Array; contadores['contador1'] = 5; contadores['contador2'] = 6; var puerto=process.argv[2]?process.argv[2]:8080; app.get('/contador/suma/:id1/:id2', function( req,res ) { res.send( "La suma solicitada es: " + req.params.id1 + "...
JavaScript
var express=require('express'); var contador = 0; var app = express.createServer(); app.get('/contador.html', function (req, res) { res.send('<html><head><title>Visión en html</title></head><body>Se han contabilizado ' + contador + ' eventos.</body></html>'); }); app.get('/contador.json', function (req, res) { res....
JavaScript
importClass(java.util.Random); r = new Random(); dado = r.nextInt(6)+1; print( ' -----' ); switch(dado) { case 1: print ( '| |' ); print ( '| * |' ); print ( '| |' ); break; case 2: print ( '| * |' ); print ( '| |' ); print ( '| * |' ); break; case 3: print ( '| * |' ); print ( '...
JavaScript
var lee = java.io.FileInputStream; var convierte = java.io.InputStreamReader; var bufea = java.io.BufferedReader; var f = new lee("jornada.txt"); var codificado = new convierte(f, "iso-8859-1"); var br = new bufea(codificado); var s = "var quiniela = " + br.readLine(); f.close(); eval(s); maxnombre=0; for(i=0; i<quini...
JavaScript
var fs = require('fs'); var express=require('express'); var app = express.createServer(); var contadores = new Array; var portada = fs.readFileSync('T2.5.html','utf8'); app.get('/', function (req, res) { res.send(portada); }); app.get('/js/:page', function (req, res) { var js = fs.readFileSync(req.params.pa...
JavaScript
var db_name=process.argv[2]; var fichero=process.argv[3]; var db = require('nano')('http://morfeo.iriscouch.com/').use(db_name); fs = require('fs'); fs.readFile(fichero, 'utf8', function(err,datos) { if (err) { return console.log(err); }; var lineas = datos.split("\n"); var resultados = new Ar...
JavaScript
var fs = require('fs'); var express=require("express"); var app = express(); var contadores = new Array; var portada = fs.readFileSync('T2.6.html','utf8'); app.get('/', function (req, res) { res.send(portada); }); app.get('/js/:page', function (req, res) { var js = fs.readFileSync(req.params.page); res....
JavaScript
var request = require('request'); var url ='http://search.twitter.com/search.json?q=%23aapugr&src=hash'; console.log(""); console.log("***Realizando búsqueda del hastag #aapugr en Twitter"); console.log(""); request(url, function (error, response, body) { if (!error && response.statusCode == 200) { eval("var es...
JavaScript
function Partido(local,visitante) { this.local = local; this.visitante=visitante; this.resultado=null; this.setResultado = setResultado; this.toString = toString; } function setResultado( esteResultado ) { if ( esteResultado == '1' || esteResultado=='x' || esteResultado=='2' ) this.resultado = esteRes...
JavaScript
var app = require('http').createServer(handler) , io = require('socket.io').listen(app) , fs = require('fs') app.listen(8080); var inicializado = new Array; function handler (req, res) { fs.readFile(__dirname + '/T2.7.html', function (err, data) { if (err) { res.writeHead(500); return res.end('...
JavaScript
var express=require('express'); var app = express.createServer(); var contadores = new Array; contadores['definible']=0; var puerto=process.argv[2]?process.argv[2]:8080; app.get('/contadores.html', function (req, res) { var frase = '<html><head><title>contadores en html</title></head><body>'; for(var i in contadores...
JavaScript
var http=require('http'); var puerto=process.argv[2]?process.argv[2]:8080; http.createServer(function (req, res) { var split_url=req.url.split("/"); if ( split_url[1] == '' ) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Portada'); } else if ( split_url[1] == 'cafe' ) { res...
JavaScript
var saludo = new Object; saludo = { primero : 'Programmer: Hello world!!!', segundo : 'World: Hi bro!', tercero : 'Programmer: O.o' }; for (i in saludo) console.log( saludo[i] );
JavaScript
print( 'Hola, Mundo' );
JavaScript
var contador = 0; var http=require('http'); http.createServer(function (req, res) { if (req.url === '/favicon.ico') { res.writeHead(200, {'Content-Type': 'image/x-icon'} ); res.end(); return; } res.writeHead(200, {'Content-Type': 'text/html'}); res.end('<html><head><title>Contador de visitas</title>...
JavaScript
var rest = require('restler'); var url = 'http://127.0.0.1:8080/contador/suma/'; rest.get( url + process.argv[2] + '/' + process.argv[3]).on('complete', function( data ) { console.log( data ); } );
JavaScript
var request; function cuenta() { request = new XMLHttpRequest(); var contador=document.getElementById('contador').value; var peticion_str = '/contador/'+contador; request.open('POST', peticion_str , true); request.onreadystatechange= escribe_resultado ; request.send(null); } function crea() { request = n...
JavaScript
function(doc) { if (doc.res_local) { var quiniela; if ( doc.res_local > doc.res_visitante ) { quiniela='1'; } else if ( doc.res_local < doc.res_visitante ) { quiniela='2'; } else { quiniela='X'; } emit(quiniela); } }
JavaScript
// ==UserScript== // @name Blogalia // @namespace http://geneura.org/projects/greasemonkey // @description Cambia cosas en la portada de blogalia // @include http://www.blogalia.com/ // @include http://blogalia.com/ // ==/UserScript== var table = document.getE...
JavaScript
document.writeln( 'Hola, Mundo' );
JavaScript
#!/usr/local/bin/node var nano = require('nano')('http://localhost:5984/'); var db_name = "ahora_no"; var db = nano.use(db_name); db.insert( { _id : 'expid_instanceid', vector: [ 11,22,33], type: 'mine' }, function (error,http_body,http_headers) { console.log(http_body); } );
JavaScript
// ==UserScript== // @name Blogalia // @namespace http://geneura.org/projects/greasemonkey // @description Cambia cosas en la portada de blogalia // @include http://www.blogalia.com/ // @include http://blogalia.com/ // ==/UserScript== GM_log('Aquí estoy'); var ...
JavaScript
#!/usr/bin/smjs var tabla="table"; var celda="td"; var fila="tr"; print( "<"+tabla+">"); for (i=1; i<=3; i++ ) { print( "<"+fila+">"); for ( j=1; j<=3; j++ ) { print ("<"+celda+">"+i*j+"</"+celda+">"); } print ("</"+fila+">\n"); } print ("</"+tabla+">");
JavaScript
// ==UserScript== // @name Blogalia // @namespace http://geneura.org/projects/greasemonkey // @description Cambia cosas en la portada de blogalia // @include http://www.blogalia.com/ // @include http://blogalia.com/ // ==/UserScript== function putComentarios( r...
JavaScript
// ejecutar con rhino lee_quiniela.js <argumento> function lee_resultados( file_name ) { var FileReader = java.io.FileReader; var BufferedReader =java.io.BufferedReader; var f = new FileReader(file_name); var br = new BufferedReader( f ); var resultados= new Array; var line = new String; while ((line = b...
JavaScript
var id = process.argv[2]; var db = require('nano')('http://localhost:5984/') .use("ahora_no"); db.get( id, null, do_stuff ); // ------------------------------------------------------------------------------- function do_stuff( error,data) { console.log(data); var result = 0; for (var i in data.vector...
JavaScript
// ==UserScript== // @name Blogalia // @namespace http://geneura.org/projects/greasemonkey // @description Cambia cosas en la portada de blogalia // @include http://www.blogalia.com/ // @include http://blogalia.com/ // ==/UserScript== GM_log('Aquí estoy'); var ...
JavaScript
#!/usr/bin/node var request = require('request'); var url ='http://api.twitter.com/1/statuses/public_timeline.json'; request(url, function (error, response, body) { if (!error && response.statusCode == 200) { console.log(JSON.parse(body)); } else { console.log(error); } })
JavaScript
// De Diego Toral en http://pastebin.com/Md65QLnT // Funciona con gjs g.js const Gtk = imports.gi.Gtk; const GLib = imports.gi.GLib; // Initialize the gtk Gtk.init(null, 0); let mwindow = new Gtk.Window ({type : Gtk.WindowType.TOPLEVEL}); let label = new Gtk.Label ({label : "Hello World"}); // Set the window title...
JavaScript
// ==UserScript== // @name Blogalia // @namespace http://geneura.org/projects/greasemonkey // @description Cambia cosas en la portada de blogalia // @include http://www.blogalia.com // @include http://blogalia.com // ==/UserScript== GM_log('Aquí estoy'); GM_lo...
JavaScript