- Category: Programming
- Hits: 3836
1. Download composer_setup.exe for windows
install it -> select php.exe from xampp/php/
2. create a folder where your xampp root folder
Create folder
D:\works\beyond\php\test
D:\works\beyond\php\test\src
D:\works\beyond\php\test\src\public
2.1 Copy composer.phar from C:\ProgramData\ComposerSetup\bin [hidden folder] to X:\test\src
//install slim
3. X:\test\src> php composer.phar require slim/slim
//extra dependencies
4. X:\test\src> composer install
5. SVN commit with vendor folder as ignore. that will take care by composer.phar composer.lock composer.json.
6. Create a file X:\test\src\public\index.php
write your program.
7. RUN xampp and type http://localhost:8888/test/src/public/
FOR REST API
*************
1. Go to xampp/apache/conf/httpd.conf change to doc root/directory to D:/test/public
2. restart the apache
3. api url. http://localhost:8888/hello/vijay
- Category: Programming
- Hits: 3567
1. Download composer_setup.exe for windows
install it -> select php.exe from xampp/php/
2 Copy composer.phar from C:\ProgramData\ComposerSetup\bin [hidden folder] to D:\php\[apache root directory]
3. type to install vendor folder [slim setups]
D:\php> php composer.phar require slim/slim
4. create your root folder (ex: test) and in your index.php..
add ../vendor/autoload.php
ex:index.php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write("Welcome");
});
$app->get('/home/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
5. run apache and in browser http://localhost:8888/test/
- Category: Programming
- Hits: 1818
just create a sample velocity-text.js file.
/** * Created by drvijay on 12-10-2016. */var context = { "name": "velocity"} var initialString = "Hello, ${name}!"; var velocityjs = require("velocityjs"); var renderedString = velocityjs.render(initialString,context); console.log(context); console.log(initialString); console.log(renderedString); // go to cmd type node velocity-text.js
INSTALL
First install velocityjs in your node_modules
npm install velocityjs
Now from your project (where the node_modules mentioned above exists) use browserify
browserify -r velocityjs > velocity.js
This will create a velocity.js file that you can include in your website directly. If you don't have browserify then do npm install -g browserify
Usage
In your webpage js file first require velocityjs
var velocityjs = require("velocityjs");
Now to get the templated html do
var renderedString = velocityjs.render(initialString,context)
Note that velocity does not care if your initial string was html or not, you need to ensure that
- Category: Programming
- Hits: 2134
package com.sftp;
import java.io.File;
import java.io.FileInputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
/**
* @author drvijay
*/
public class SFTPcallInJava
{
public static void main ( String [] args )
{
String SFTPHOST = "192.168.7.99";
int SFTPPORT = 2121;
String SFTPUSER = "vijayjava";
String SFTPPASS = "vijaytest123";
String SFTPWORKINGDIR = "/www/";
Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;
try
{
JSch jsch = new JSch ();
session = jsch.getSession ( SFTPUSER, SFTPHOST, SFTPPORT );
session.setPassword ( SFTPPASS );
java.util.Properties config = new java.util.Properties ();
config.put ( "StrictHostKeyChecking", "no" );
session.setConfig ( config );
session.connect ();
channel = session.openChannel ( "sftp" );
channel.connect ();
channelSftp = (ChannelSftp) channel;
channelSftp.cd ( SFTPWORKINGDIR );
File f = new File ( "D:/Temp/aamlog.txt" );
channelSftp.put ( new FileInputStream ( f ), f.getName () );
}
catch ( Exception ex )
{
ex.printStackTrace ();
}
}
}
- Category: Programming
- Hits: 1903
1. go to cmd prompt in your root project folder
Type npm install nodemailer
2. create mail.js
var express = require('express'); var nodemailer = require("nodemailer"); var smtpTransport = require("nodemailer-smtp-transport") var app = express(); var smtpTransport = nodemailer.createTransport(smtpTransport({ host : "smpt.gmail.com", secureConnection : false, port: 587, auth : { user : "This email address is being protected from spambots. You need JavaScript enabled to view it.", pass : "test123"} })); app.get('/send',function(req,res){ var mailOptions={ from : "This email address is being protected from spambots. You need JavaScript enabled to view it.", to : "This email address is being protected from spambots. You need JavaScript enabled to view it.", subject : "Your Subject", text : "Your Text", html : "HTML GENERATED", /*attachments : [ { // file on disk as an attachment //filename: 'a.txt',path: 'd:/a.txt' // stream this file, use only path property and send the file name in the end, else you may get folder read error} ]*/ } console.log(mailOptions); smtpTransport.sendMail(mailOptions, function(error, response){ if(error){ console.log(error); res.end("error"); }else{ console.log(response.response.toString()); console.log("Message sent: " + response.message); res.end("sent"); } }); }); app.listen(3000,function(){ console.log("Express Started on Port 3000"); });
3. Go to command prompt where the mail.js stored
Type node mail.js
4. open brower
http://localhost:3000/send