id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
4a4e5974-f132-4d5c-8692-947672fb779a | @Override
public void execute(BrainFuckData data, BrainFuckCode code) {
if (data.getCurrentCharFromArray() == 0) {
code.changeCurrentPositionOn(1);
} else {
BrainFuckServices services = new BrainFuckServices();
code.changeCurrentPositionOn(-services.getLoopLength... |
f036c79a-69c4-43a4-8349-871e731efac7 | public BrainFuckCode(List<Command> code) {
this.code = code;
this.currentPosition = 0;
} |
59042d13-3ddd-493e-8c97-4a565d7a0003 | public List<Command> getCode() {
return code;
} |
5bdd96ad-5ad9-4416-aded-c1ffcae36836 | public int getCurrentPosition() {
return currentPosition;
} |
76748d4b-1b77-44ae-a925-0b293255f048 | public void changeCurrentPositionOn(int deltaCurrentPosition) {
this.currentPosition += deltaCurrentPosition;
} |
7f697630-b702-42f1-a0db-23fb55c5a4bf | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BrainFuckCode that = (BrainFuckCode) o;
if (currentPosition != that.currentPosition) return false;
if (code != null ? !code.equals(that.code) :... |
9ad599e3-e683-40a8-96f1-39de46f9083b | @Override
public int hashCode() {
int result = code != null ? code.hashCode() : 0;
result = 31 * result + currentPosition;
return result;
} |
8c3af415-6979-450d-8220-5fc680de176a | public BrainFuckData() {
this.charArray = new char[30000];
this.currentIndexInArray = 0;
} |
ba156d3c-8310-4e75-909c-5a494d7e44cf | public char getCurrentCharFromArray() {
return charArray[currentIndexInArray];
} |
76974342-9310-4210-9316-3e4fafda063e | public void setCurrentCharToArray(char charToArray) {
this.charArray[currentIndexInArray] = charToArray;
} |
0290a3e5-c1d3-4aac-a827-b9768aabac81 | public int getCurrentIndexInArray() {
return currentIndexInArray;
} |
189f732b-1bec-49bb-8c5c-e77f786e9c87 | public void setCurrentIndexInArray(int currentIndexInArray) {
this.currentIndexInArray = currentIndexInArray;
} |
b78589ea-5b8d-4bbf-8310-ed43ebac2279 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BrainFuckData that = (BrainFuckData) o;
if (currentIndexInArray != that.currentIndexInArray) return false;
if (!Arrays.equals(charArray, that.c... |
b873b572-5125-4dd5-a530-ba326ad14314 | @Override
public int hashCode() {
int result = Arrays.hashCode(charArray);
result = 31 * result + currentIndexInArray;
return result;
} |
96ef55e1-35fd-4cd4-acf6-7472d6dfa671 | public SyntaxErrorBrainFuckCodeException(String s) {
super(s);
} |
61a602bd-866c-47a8-ad09-17112bca241e | public static void main(String[] args) {
final String helloWorld = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++\n" +
" .>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.\n" +
" ------.--------.>+.>.";
BrainFuckData data = new BrainFuckData();
BrainFuckCompiler comp... |
5714e47c-90a6-4412-a6f9-7779fd71ef6f | public static String[] extendArray(String[] in) {
String[] out = new String[in.length + 1];
for (int i = 0; i < in.length; i++) {
out[i] = in[i];
}
return out;
} |
87600cd2-7fb2-4701-8fab-5f830f6bd52a | public static boolean containsArgument(String findee, String[] args) {
for (int i = 0; i < args.length; i++) {
if (args[i].equalsIgnoreCase(findee)) {
return true;
}
}
return false;
} |
0f01b57f-7b72-4d35-877e-e04d3a052d80 | public static String encryptString(String s, String encryption, String textEncoding) throws UnsupportedEncodingException, NoSuchAlgorithmException {
// Set up to process password
MessageDigest md = MessageDigest.getInstance(encryption);
// Set to digest our password
md.... |
cbcb8f53-a8b0-4599-9e00-a3c40e7b0104 | public static void setNativeLookAndFeel()
throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
String os = System.getProperty("os.name");
if (os.startsWith("Linux")) {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gt... |
0d867dbf-39da-433e-91f7-d28aa93e19c9 | public static String[] readFlatFile(String file)
throws FileNotFoundException, IOException {
Scanner in = new Scanner(new FileReader(new File(file)));
String[] out = new String[linesInFile(new File(file))];
int i = 0;
while (in.hasNext()) {
MyStringUtil.extendArra... |
38504fed-897f-4f81-8a55-676fa13255a6 | public static void writeFlatFile(String[] theString, PrintWriter out) {
for (int i = 0; i < theString.length; i++) {
out.println(theString[i]);
}
out.flush();
} |
dae874a0-24ed-4897-a671-acb1e5b899a9 | public static void writeCSVLine(String[] line, String delimiter, PrintWriter out) {
String output = "";
for (int i = 0; i < line.length; i++) {
output = output + line[i] + delimiter;
}
out.write(output);
System.out.println(output);
} |
f23ab117-f113-48a5-81e9-a5ceef85633c | public static void writeCSVLine(String[] line, PrintWriter out) {
writeCSVLine(line, ",", out);
} |
7fe6a2fa-8e17-487d-abd2-66a38053489e | public static String getFriendlyFileName(File theFile) {
return theFile.getName().substring(0, theFile.getName().indexOf("."));
} |
df8f8a4c-edbc-4b93-b188-89da82e0365d | public static int linesInFile(File theFile) throws FileNotFoundException, IOException {
BufferedReader reader = new BufferedReader(new FileReader(theFile));
int lines = 0;
while (reader.readLine() != null) {
lines++;
}
reader.close();
return lines;
} |
b9e0495b-a27b-484f-b500-e91d32182fa0 | public static String[][] readCSVFile(File theFIle, String delimiter)
throws FileNotFoundException, IOException {
ArrayList list = new ArrayList();
Scanner line = new Scanner(theFIle);
line.useDelimiter("\n");
while (line.hasNext()) {
ArrayList columns = new Arra... |
4c9f735f-269c-4a28-b9a6-b4cc606cb650 | InputStreamToOutputStream(InputStream in, OutputStream out) {
this.in = in;
this.out = out;
running = true;
} |
1f8f5d9c-6d2d-4149-a277-d201f0dde4da | public void stop() {
running = false;
} |
fe1974c5-1a04-45bc-ad19-a77871cddec7 | public void start() {
running = true;
if (wt == null) {
wt = new WriteThread();
wt.start();
}
} |
b2327b57-df58-40f4-880d-843d9195a659 | public InputStream getInputStream() {
return in;
} |
8c102f42-29a5-434b-b92d-bc3748d3481e | public OutputStream getOutputStream() {
return out;
} |
e1fc73a3-fbf8-4056-af2b-675d459773d5 | @Override
public void run() {
while (running) {
try {
out.write(in.read());
} catch (IOException ex) {
}
}
wt = null;
} |
0910f5ac-0371-46e6-93a1-3ed51e00320a | public MicrophoneRecorder() {
this(new AudioFormat(
8000.0F, // Sample rate
16, // Sample Size
1, // Channels
true, // Signed
false // BigEndian
));
} |
98f84048-41ab-49d6-ad58-f878563560c3 | public MicrophoneRecorder(AudioFormat format) {
super();
this.format = format;
} |
f88473c4-36ab-449b-91f7-acc5b16c106a | public void start() {
thread = new Thread(this);
thread.setName("Capture");
thread.start();
} |
b4b8de11-f0fb-4819-bda1-3f61b610d763 | public void stop() {
thread = null;
} |
cd1edf35-b9f2-44f9-8a1f-ed9493494018 | @Override
public void run() {
duration = 0;
line = getTargetDataLineForRecord();
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final int frameSizeInBytes = format.getFrameSize();
final int bufferLengthInFrames = line.getBufferSize() / 8;
final int buf... |
101cb8fa-8f5e-440e-9f90-8e2522df8b79 | private TargetDataLine getTargetDataLineForRecord() {
TargetDataLine line;
final DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
if (!AudioSystem.isLineSupported(info)) {
return null;
}
// get and open the target data line for capture.
... |
f651766a-5f11-4171-9a14-d8ed24a0c072 | public AudioInputStream getAudioInputStream() {
return audioInputStream;
} |
4a2d49db-a441-468c-8dfe-7998f3f41264 | public AudioFormat getFormat() {
return format;
} |
7455d0f1-69f1-4bd9-8b03-310067dca84d | public void setFormat(AudioFormat format) {
this.format = format;
} |
d4e2faf6-b48f-44c4-ba52-338a2301d8e2 | public Thread getThread() {
return thread;
} |
684ecd85-9778-48f2-a023-140be4b0ecc0 | public double getDuration() {
return duration;
} |
01b1a4fa-f6a2-4499-bdf8-a4ade5af5d1c | public PatientTiler(SlideIndex index, int tileWidth,
int tileHeight,
double zoom,
String outputDir) {
super(tileWidth, tileHeight, zoom, outputDir);
this.index = index;
} |
1d08b17d-cf40-4abc-adc7-14a42e2aeb15 | public Future<Void> tile(Patient patient) {
return pool.submit(new PatientFetchTask(patient, tileWidth, tileHeight, zoom, index, outputDir));
} |
5da230f9-3f6a-4b99-9bf3-e79911629bb1 | public Future<Void> tilePatients(final Collection<Patient> targets) {
return pool.submit(new RecursiveAction() {
@Override protected void compute() {
List<FetchTask> tasks = new LinkedList<>();
for (Patient patient : targets) {
tasks.add(new Patien... |
f908d702-2321-4821-a006-8f433340ab42 | @Override protected void compute() {
List<FetchTask> tasks = new LinkedList<>();
for (Patient patient : targets) {
tasks.add(new PatientFetchTask(patient, tileWidth, tileHeight, zoom, index, outputDir));
}
invokeAll(tasks);
... |
130b25eb-cb19-4f7c-b217-a61248e7100a | public TileTask(OpenSlideImage slide, int x, int y, int tileWidth, int tileHeight, double zoom, String outputDir) {
this.slide = slide;
this.x = x;
this.y = y;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.zoom = zoom;
writer = new Writer(outputD... |
9ee51fd3-c11f-428c-bb4c-08bc6361db76 | @Override protected void compute() {
try {
BufferedImage tile = slide.getRegion(x,
y,
(int) (tileWidth * zoom),
(int) (tileHeight * zoom),
... |
6087309a-2383-4b14-a82b-102a59f6c29d | public URLTiler(int tileWidth, int tileHeight, double zoom, String outputDir) {
this.outputDir = outputDir;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.zoom = zoom;
} |
2b4dac2a-169d-434c-993a-bd5793963435 | public Future<Void> tile(final String target) {
return pool.submit(new FetchTask(target, tileWidth, tileHeight, zoom, outputDir));
} |
92af45a5-8b1c-4285-85d2-af66a8900058 | public Future<Void> tile(final Collection<String> targets) {
return pool.submit(new RecursiveAction() {
@Override protected void compute() {
List<FetchTask> tasks = new LinkedList<>();
for (String target : targets) {
tasks.add(new FetchTask(target,... |
49ff852a-8ed3-45d4-b797-c23c867dbd75 | @Override protected void compute() {
List<FetchTask> tasks = new LinkedList<>();
for (String target : targets) {
tasks.add(new FetchTask(target, tileWidth, tileHeight, zoom, outputDir));
}
invokeAll(tasks);
} |
9299cc7a-2b09-4299-98c2-ffdf5d611a1f | public PatientFetchTask(Patient patient, int tileHeight,
int tileWidth,
double zoom,
SlideIndex index,
String outputDir) {
super(patient.getIdentifier(), tileHeight, tileWidth, zoom, outputDir);
... |
fa62cf00-9827-42d9-8249-812af7a50503 | @Override protected void compute() {
System.out.println("Fetching " + target);
fetcher.updateSlides(patient, index);
for (OpenSlideImage slide : patient.getSlideSet()) {
tile(slide);
}
patient.clearSlides();
} |
e3ec91b5-bb94-4914-b355-771d9dab5402 | public FetchTask(String target, int tileHeight, int tileWidth, double zoom, String outputDir) {
this.target = target;
this.tileHeight = tileHeight;
this.tileWidth = tileWidth;
this.zoom = zoom;
this.outputDir = outputDir;
fetcher = new Fetcher();
} |
3a42140a-cf72-45cf-925b-e75f30a8e29e | @Override protected void compute() {
try {
System.out.println("Fetching "+target);
final OpenSlideImage slide = fetcher.fetch(target);
tile(slide);
} catch (IOException e) {
System.err.println("Failed to fetch " + target + " because of " + e);
}
... |
4b854975-95b0-4802-bc70-d41e9daca4d3 | protected void tile(OpenSlideImage slide) {
List<TileTask> tilingTasks = new LinkedList<>();
for (int y = 0; y < slide.getHeight(); y += tileHeight) {
for (int x = 0; x < slide.getWidth(); x += tileWidth) {
tilingTasks.add(new TileTask(slide, x, y, tileWidth, tileHeight, zoom... |
b3575035-d9bf-4a42-b9a1-c65a39fa3514 | public OpenSlideImage(String path) throws IOException {
this(new File(path));
} |
ed78dad9-ce9c-4b8e-9bf2-5e0b91567272 | public OpenSlideImage(File file) throws IOException {
this.file = file;
slide = new OpenSlide(file);
} |
c584d899-2cc6-4703-8c6c-c104f301fad2 | public int getWidth() {
return (int) slide.getLevel0Width();
} |
68117a7b-9cd1-4745-bbb7-21e499b1c6f9 | public int getHeight() {
return (int) slide.getLevel0Height();
} |
4f0c7b9e-a2cc-4c4a-a192-a77f00a145a5 | public BufferedImage getRegion(int xOffset, int yOffset, int width, int height) throws IOException {
// Build a bufferedimage
BufferedImage region = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g2 = region.createGraphics();
slide.paintRegion(g2, 0, 0, xOffse... |
b6b0a5b2-9c97-43ce-b56d-329dca212734 | public BufferedImage getRegion(int xOffset, int yOffset, int width, int height, double divider) throws
IOException {
// Build a bufferedimage
BufferedImage region = new BufferedImage((int) (width / divide... |
70068eba-cd92-4f64-819b-d43d275b7b05 | public BufferedImage getThumbnail() throws IOException {
return slide.createThumbnailImage(MAX_THUMBNAIL);
} |
fc39a20e-9d54-438d-ada5-9a022ebcdf54 | public void close() throws IOException {
slide.close();
} |
6f90639a-9746-4e0f-8ff4-cd7370cbe061 | public File getFile() {
return file;
} |
df5cbf5a-9c7a-4854-881c-f50b2055130b | public static void main(String[] args) throws IOException, InterruptedException {
Fetcher.setDownloadPath("/tmp/slides/");
Writer.setFileType("jpeg");
final ClinicalFetcher nationwideFetcher = new ClinicalFetcher(CLINICAL_URL);
final SlideIndex slideIndex = new SlideIndex(SLIDE_URL);
... |
07ad8583-f3ce-422d-b4ba-cac8dd121c78 | public Patient(String site, String identifier) {
this.site = site;
this.identifier = identifier;
slides = new HashMap<>();
clinicalData = new LinkedHashMap<>();
} |
7b8459c5-1628-4149-a9f3-19da25f4a30b | public String getSite() {
return site;
} |
475c99ef-a253-4225-ac1d-6b122a401cec | public void setSite(String site) {
this.site = site;
} |
5d211f77-1682-472f-bbce-40c23aa2ba9c | public String getIdentifier() {
return identifier;
} |
878cf85c-ac91-4f5d-9fd9-d8be986aa913 | public void setIdentifier(String identifier) {
this.identifier = identifier;
} |
bb4efc71-b196-4b63-adc2-53dde8edc44e | public Map<String, OpenSlideImage> getSlides() {
return slides;
} |
770674af-b93f-4282-8702-591a6eca927e | public Collection<OpenSlideImage> getSlideSet() {
return slides.values();
} |
811c5ab0-475d-465c-897c-29d4e631a468 | public void clearSlides() {
Iterator<Map.Entry<String, OpenSlideImage>> slideIterator = slides.entrySet().iterator();
while (slideIterator.hasNext()) {
Map.Entry<String, OpenSlideImage> entry = slideIterator.next();
try {
entry.getValue().close();
} ca... |
e282576e-9bb3-43e6-a3a3-f114889d3104 | public void addSlide(String id, OpenSlideImage slide) {
slides.put(id, slide);
} |
3bc05867-73fb-4d8f-b0d0-593aa089910b | public void removeSlide(String id) {
slides.remove(id);
} |
ecc27fc7-df46-4cea-b24c-08fd7b2b0845 | public Map<String, String> getClinicalData() {
return clinicalData;
} |
21598bac-c7ed-4b3c-b4e3-2b3bdd32aba2 | public Set<String> getClinicalMarkers() {
return clinicalData.keySet();
} |
abd4b8db-4264-4e4b-9c34-42c82170aa44 | public String getClinical(String key) {
return clinicalData.get(key);
} |
a834f6e9-3b49-4c25-828f-8afd688f5d9e | public String addClinical(String key, String value) {
return clinicalData.put(key, value);
} |
f26275de-bd14-4dfd-80ed-96655c53221b | public String removeClinical(String key) {
return clinicalData.remove(key);
} |
6bd64ef3-397b-44fc-ab4b-e036aada62f5 | public static Optional<Patient> fromSample(String sample) {
String[] parts = sample.split("-");
if (parts.length >= 3) {
// First part is 'TCGA'
// Second part is Site
String site = parts[1];
// Third part is patient
String identifier = parts[2... |
0f13abde-51a9-44f9-8bb9-05023f930f86 | @Override public String toString() {
return "Patient{" +
"site='" + site + '\'' +
", identifier='" + identifier + '\'' +
", clinical=" + clinicalData + ", " + slides.size() + " slides}";
} |
c1f56360-4597-49a9-8802-a55a97eae30c | public SlideIndex(String rootUrl) {
this.rootUrl = rootUrl;
} |
c9638283-a7de-44d2-a77d-eedbe4aee296 | public synchronized Multimap<String, String> getSlideUrls() {
if (slideUrls == null) {
slideUrls = fetch();
}
return slideUrls;
} |
bdfb03a9-9e97-4d1c-a9de-822279d271ff | private Multimap<String, String> fetch() {
return scrapePage(rootUrl);
} |
7f728c80-f6b1-4e0a-a040-22bf84017e2e | private Multimap<String, String> scrapePage(String url) {
ListMultimap<String, String> urls = LinkedListMultimap.create();
try {
Document doc = Jsoup.connect(url).get();
Elements links = doc.select("a");
for (Element link : links) {
String text = link.... |
6de3113b-c220-4725-8928-4ef515b362bc | public Collection<String> getSlideUrls(String identifier) {
return getSlideUrls().get(identifier);
} |
28214831-0e2f-4a6b-852d-9d7606a14b94 | public Collection<String> getSlideUrls(String site, String patient) {
return getSlideUrls(site + "-" + patient);
} |
9800de33-110b-490e-b0cc-5d1dc0057079 | public Collection<String> getSlideUrls(Patient patient) {
return getSlideUrls(patient.getSite(), patient.getIdentifier());
} |
4350103f-2110-4f89-ab3c-fc049defa537 | public ClinicalFetcher(String url) {
this.url = url;
} |
9c00087f-a1e0-412f-b6de-b933c89f7f93 | public Multimap<String, Patient> getSites() {
if (patients == null) {
patients = fetch();
}
return patients;
} |
edbc08e2-e50b-46ef-a4c6-bafffe739005 | public Collection<Patient> getPatients() {
return getSites().values();
} |
bf321869-511c-4ce0-9643-708f568e5a1f | private Multimap<String, Patient> fetch() {
ListMultimap<String, Patient> patients = LinkedListMultimap.create();
try (Scanner reader = new Scanner(new URL(url).openStream(), "UTF-8")) {
// Find the target columns first line
findColumns(reader.nextLine());
while (rea... |
2d63ee07-c2c9-4a78-9402-efa86596e689 | private void findColumns(String s) {
columns = s.split("\t");
} |
399a5977-28bc-4070-8afe-059d0302b6e4 | private Optional<Patient> parsePatient(String line) {
String[] parts = line.split("\t");
String barcode = parts[0];
Optional<Patient> patient = Patient.fromSample(barcode);
if (patient.isPresent() && parts.length >= 2) {
for (int i = 1; i < columns.length; i++) {
... |
ae352ead-b4a1-4fc9-88c0-81b6ff801b40 | public Writer(String path) {
this.path = path;
File dir = new File(path);
if (!dir.exists()) {
try {
Files.createDirectory(dir.toPath());
} catch (IOException e) {
System.err.println("Failed to create directory for tiles");
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.