Wednesday, November 2, 2016

linux find and cp/mv to a path

If you want to find for a particular string/date and then do list/copy/move, then below command will help you out

Find .wav files created on Dec 30th
 find . -type f -name "*.wav" -newermt 2016-12-30 ! -newermt 2016-12-31 -exec ls -l {} \;

If above cmd shows proper output then try
find . -type f -name "*.wav" -newermt 2016-12-30 ! -newermt 2016-12-31 -exec cp  {} /dest/path/ \;


Wednesday, October 19, 2016

Node render html file and pass json data to html

Create a server.js file with below code
var express = require('express'),
app = express(),
        http = require('http'),
        httpServer = http.createServer(app);

app.use('/',express.static(path.join(__dirname, '/public')));
app.set('view engine', 'ejs'); // send HTML files
app.engine('html', require('ejs').renderFile);

app.get('test',function(req, res){
 res.render('hello.html',{ 'id' : 'w8m4r9vdfm' });
});

httpServer.listen(8000,"0.0.0.0",function(){
    console.log('http on 8000');
});

Folder structure:
app
  server.js
  public/hello.html

Friday, August 12, 2016

Exclude a folder while copy in linux

let's say you have main Folder application with 3 folders inside
folderA  folderB folderC and want to exclude folderA the you can simply execute below command

rsync -av --progress application /destinationfolder --exclude folderA  

Tuesday, August 2, 2016

Shared library support linux

Shared libs are know by linking its path in /etc/ld.so.conf.d/

Recently i came across an error in asterisk while trying to compile OPUS codec as shared lib support to asterisk

asterisk: error while loading shared libraries: libopus.so

But OPUS was install under /usr/local/lib

Now to make it available to asterisk do

echo '/usr/local/lib' > /etc/ld.so.conf.d/usr_local.conf

then update ldconfig by
ldconfig && ldconfig -v

Thursday, June 23, 2016

Monday, June 13, 2016

WebRTC STUN check and adding multiple STUN servers

var pc = new RTCPeerConnection({iceServers: [
    {urls: 'stun:stun1.l.google.com:19302'},
    {urls: 'stun:stun2.l.google.com:19302'}
]});
pc.createDataChannel("testchannel");
pc.onicecandidate = function(e) {
  if(e.candidate){
    console.log(e.candidate.candidate);
  }
};
pc.createOffer().then(offer => pc.setLocalDescription(offer));

Thursday, May 26, 2016

Adding alias in windows like in Linux

Here doskey cmd is used to set alias.
All alias set using 'doskey' are temporary, once you reopen a new cmd window its gone.

Let see how to set alias like in linux we save it in .bashrc file

IN WINDOWS
First open a notepad and past below commands to test

doskey ls=dir
doskey !=ping google.com -t
doskey mv=ren

save it as alias.cmd,
Open your run window and type %appdata% then enter. Copy the alias.cmd file to this Appdata-Roming folder.

Open regdit from your run window.
Go to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor
Select 'Command processor' Folder and on the right side of window, Right click - New-Expandable string value
Give 'Name' as AutoRun, then right click and modify value as  "%AppData%\alias.cmd"

That's it! Now go to cmd prompt and do
ls and see it its working.

CSS tricks

Mixed paint in background: background: linear-gradient(to right, #b6e358, #38b143) Grid view: display: grid; grid-template-columns: a...