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
package catbot; | |
import javax.imageio.ImageIO; | |
import java.awt.*; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
public class ImageGenerator { | |
public static void main(String[] args) { |
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
package demosql | |
import java.sql.* | |
class ServerDatabase { | |
val conn: Connection | |
init { |
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
// | |
// main.swift | |
// SwiftShowcase | |
// | |
import Foundation | |
struct Struct1 { | |
let constant : CGFloat = 10 | |
} |
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
package org.kilonet; | |
import org.apache.commons.io.FileUtils; | |
import org.apache.commons.io.IOUtils; | |
import org.apache.commons.lang3.StringEscapeUtils; | |
import org.apache.commons.lang3.StringUtils; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; |
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
/* | |
* The author disclaims copyright to this source code. In place of | |
* a legal notice, here is a blessing: | |
* | |
* May you do good and not evil. | |
* May you find forgiveness for yourself and forgive others. | |
* May you share freely, never taking more than you give. | |
* | |
*/ | |
package org.hibernate.dialect; |
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
package org.kilonet; | |
import org.apache.commons.io.FileUtils; | |
import org.apache.commons.io.IOUtils; | |
import org.apache.commons.lang3.StringEscapeUtils; | |
import org.apache.commons.lang3.StringUtils; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; |
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
File urlImage = new File("path to file"); | |
BufferedImage img = ImageIO.read(urlImage); | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
ImageIO.write(img, "jpg", baos); | |
baos.flush(); | |
byte[] bytes = baos.toByteArray(); | |
baos.close(); |
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
private static void testPostgreSql()throws SQLException { | |
try { | |
Class.forName("org.postgresql.Driver"); | |
} catch (ClassNotFoundException e) { | |
System.out.println("Where is your JDBC Driver?"); | |
e.printStackTrace(); | |
return; | |
} | |
String url = "jdbc:postgresql://127.0.0.1:5432/postgres"; |
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
public boolean segmentsIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { | |
double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); | |
if (d == 0) return false; | |
double xi = Math.floor(((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d); | |
double yi = Math.floor(((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d); | |
if (xi < Math.min(x1, x2) - 15 || xi > Math.max(x1, x2) + 15) return false; | |
if (xi < Math.min(x3, x4) - 15 || xi > Math.max(x3, x4) + 15) return false; | |
if (yi < Math.min(y1, y2) - 15 || yi > Math.max(y1, y2) + 15) return false; | |
if (yi < Math.min(y3, y4) - 15 || yi > Math.max(y3, y4) + 15) return false; | |
/*Косяки с вычислениями в double*/ |
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 javax.sound.midi.MidiChannel; | |
import javax.sound.midi.MidiSystem; | |
import javax.sound.midi.Synthesizer; | |
public class TestMidi { | |
public static void main(String[] args) { | |
try { | |
Synthesizer synthesizer = MidiSystem.getSynthesizer(); | |
synthesizer.open(); |