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
/<[a-z][\s\S]*>/i.test() |
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
String readFile(String fileName) throws IOException { | |
BufferedReader br = new BufferedReader(new FileReader(fileName)); | |
try { | |
StringBuilder sb = new StringBuilder(); | |
String line = br.readLine(); | |
while (line != null) { | |
sb.append(line); | |
sb.append("\n"); | |
line = br.readLine(); |
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 java.io.BufferedInputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import org.apache.tika.exception.TikaException; | |
import org.apache.tika.metadata.Metadata; | |
import org.apache.tika.parser.AutoDetectParser; | |
import org.apache.tika.parser.ParseContext; |
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 : function (data, type, update_position) { | |
var promise; | |
var self = this; | |
if (type === 'records') { | |
promise = this.importer.add_records(data); | |
} else if (type === 'points') { | |
promise = this.importer.add_points(data); | |
} else { | |
self.logger.error('Invalid import type'); | |
return Q.reject('Invalid import type'); |
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
var fs = require('fs'); | |
fs.writeFile("/tmp/test", "Hey there!", function(err) { | |
if(err) { | |
console.log(err); | |
} else { | |
console.log("The file was saved!"); | |
} | |
}); |
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
// Module Dependencies | |
var Q = require('q'), | |
request = require('request'); | |
// Some URLs to play with, and a queue to keep the code readable | |
var urls = ['google.com', 'twitter.com', 'facebook.com'], | |
queue = []; | |
// A standard NodeJS function: a parameter and a callback; the callback | |
// will return error (if any) as first parameter and result as second |
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
crypto.createHash('sha1').update(content).digest('hex'); |
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
node -e "var fs= require('fs'); console.log(JSON.stringify(fs.readdirSync('.'),null,4));" |
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
var something=999; | |
var something_cachedValue=something; | |
function doStuff() { | |
if(something===something_cachedValue) {//we want it to match | |
setTimeout(doStuff, 50);//wait 50 millisecnds then recheck | |
return; | |
} | |
something_cachedValue=something; | |
//real action |
OlderNewer