Skip to content

Instantly share code, notes, and snippets.

View bilashcse's full-sized avatar
👨‍💻
Coding is fun

Nazmul Hossain bilashcse

👨‍💻
Coding is fun
View GitHub Profile
@bilashcse
bilashcse / deleteImages.js
Last active October 18, 2016 09:36
A Node.js script to remove all images of a directory which are more then 6 hours older using NodeJs child process
var CronJob = require('cron').CronJob;
var exec = require('child_process').exec;
var path = '../tmp/uploads';
var job = new CronJob({
cronTime: '*/59 * * * *',
onTick: function() {
exec('find '+path+' -mmin +359 -type f -name "*.*" -exec rm -f {} +', function(err,stdout,stderr){
if(err)
@bilashcse
bilashcse / watermark.js
Last active October 18, 2016 09:58
Add watermark image with NodeJs and ffmpeg
var ffmpeg = require('ffmpeg');
try {
var process = new ffmpeg('mymovie.mp4');
process.then(function (video) {
console.log('Video is ready to be processed');
var watermarkPath = 'watermark.png',
newFilepath = './newVideoFileName.mp4',
settings = {
position : "SE" // Position: NE NC NW SE SC SW C CE CW
@bilashcse
bilashcse / s3upload.js
Created October 23, 2016 19:21
Amazon S3 file upload using NodeJs
var aws = require('aws-sdk');
var promise = require('bluebird');
var fs = promise.promisifyAll(require('fs'));
var awsConfig = {
region: "aws.region",
accessKeyId: "aws.accessKeyId",
secretAccessKey: "aws.secretAccessKey",
sslEnabled: true
};
@bilashcse
bilashcse / email.js
Created October 31, 2016 07:25
Send email through NodeJs script
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport();
transporter.sendMail({
from: 'sender@address',
to: 'receiver@address',
subject: 'hello',
text: 'hello world!'
});
//Sending emails through SMTP is also possible (using Gmail, Hotmail, etc.):
@bilashcse
bilashcse / html-email.js
Created November 7, 2016 11:20
Email send with html template using ejs template engine on NodeJs
var ejs = require('ejs');
var fs = require('fs');
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: email,
pass: password
}
@bilashcse
bilashcse / addFBGroupMembers.js
Created November 16, 2016 18:49
Add Facebook group members
(function(){var f={dtsg:document.getElementsByName("fb_dtsg")[0].value,uid:document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]),gid:document.getElementsByName("group_id")[0].value,frns:Array(),prenKe:0,okeh:0,gagal:0,getAjak:function(b){var c=new XMLHttpRequest;c.open("GET",b,!0),c.onreadystatechange=function(){if(4==c.readyState&&200==c.status){var a=eval("("+c.responseText.substr(9)+")");a.payload&&a.payload.entries&&(f.frns=a.payload.entries.sort(function(){return.5-Math.random()})),document.getElementById("hasilsurasil").innerHTML="Found <b>"+f.frns.length+" Abonnenten</b><div id='hasilsatu'></div><div id='hasildua'></div><div id='hasiltiga' style='min-width:300px;display:inline-block;text-align:left'></div>"+crj;for(x in f.frns)f.senAjak(x)}else document.getElementById("hasilsurasil").innerHTML=4==c.readyState&&404==c.status?"<b style='color:darkred'>Gruppe Öffnen!</b>"+crj:"<b style='color:darkgreen'>Suche nach möglichen Abonnenten... ("+c.readyState+")</b>"+crj},c.send()},senAjak:function(d)
@bilashcse
bilashcse / mysql.txt
Created January 2, 2017 09:27
mysql 5.5 to 5.6 upgrade
To install you have to do the following:
sudo apt-get purge mysql-server-5.5 mysql-client-5.5
sudo apt-get autoremove
sudo apt-get install mysql-server-5.6 mysql-client-5.6
@bilashcse
bilashcse / index.html
Created May 24, 2017 12:02
responsive youtube video
<style>
.video-container {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
}
.video-container iframe, .video-container object, .video-container embed {
@bilashcse
bilashcse / query_finder.sql
Created November 26, 2018 07:47 — forked from mugli/query_finder.sql
Finding long-running queries in MySQL
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep'
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
@bilashcse
bilashcse / division_district_upazilla_union.sql
Created December 27, 2018 07:26
SQL dump for all Bangladeshi divisions, districts, upazillas / Thanas, Unions
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `districts`;
CREATE TABLE `districts` (
`id` int(11) NOT NULL AUTO_INCREMENT,