Skip to content

Instantly share code, notes, and snippets.

View rajat1saxena's full-sized avatar
😃
Building an open-source LMS

Rajat Saxena rajat1saxena

😃
Building an open-source LMS
View GitHub Profile
@rajat1saxena
rajat1saxena / streams_basic_chunking.js
Created August 6, 2017 10:05
Efficiently write large files using Node.js
'use strict';
// this program will result in an "JavaScript heap out of memory"
const fs = require('fs');
const printer = function () {
const fil = fs.createWriteStream('file');
let i = 0;
const MAX_LIM = 1e6;
@rajat1saxena
rajat1saxena / soundreplace.sh
Created January 10, 2017 05:33
A quick shell script to replace the sound of your video
#!/bin/bash
VIDEO=$1
AUDIO=$2
DATE=`date +%Y-%m-%d.%H:%M:%S`
OUTPUT="Output_"$DATE".mp4"
ffmpeg -i $VIDEO -i $AUDIO \
-c:v copy -c:a aac -strict experimental \
-map 0:v:0 -map 1:a:0 $OUTPUT

Keybase proof

I hereby claim:

  • I am rajat1saxena on github.
  • I am rajats (https://keybase.io/rajats) on keybase.
  • I have a public key ASClc_tgXIfd6_e-FSHI_LqXtfyIXRSuMfHyz7f-00r0vwo

To claim this, I am signing this object:

@rajat1saxena
rajat1saxena / redux.js
Created December 27, 2019 14:29
Super Fast Redux Tutorial
const redux = require('redux')
const store = redux.createStore((state = {}, action) => {
switch (action.type) {
case 'demo':
return { demo: true }
default:
return state
}
})
@rajat1saxena
rajat1saxena / printableHexString.kt
Created June 24, 2018 06:18
print_sha512_checksum.kt
fun printableHexString(data: ByteArray): String {
// Create Hex String
val hexString: StringBuilder = StringBuilder()
for (aMessageDigest:Byte in data) {
var h: String = Integer.toHexString(0xFF and aMessageDigest.toInt())
while (h.length < 2)
h = "0$h"
hexString.append(h)
}
return hexString.toString()
@rajat1saxena
rajat1saxena / generateChecksum.kt
Created June 24, 2018 06:16
generate_sha512_of_a_file.kt
private fun generateChecksum(data: ByteArrayOutputStream): String {
try {
val digest: MessageDigest = MessageDigest.getInstance("SHA-512")
val hash: ByteArray = digest.digest(data.toByteArray())
return printableHexString(hash)
} catch (e: Exception) {
e.printStackTrace()
}
return ""
// Get the image's Uri from shared intent etc.
val imageSelected: Uri = intent.getParcelableExtra(Intent.EXTRA_STREAM)
try {
// get the raw file data of the photo
val mInputPFD = contentResolver.openFileDescriptor(imageSelected, "r")
val mContentFileDescriptor = mInputPFD.fileDescriptor
val fIS = FileInputStream(mContentFileDescriptor)
val mGraphicBuffer = ByteArrayOutputStream()
val buf = ByteArray(1024)
while (true) {
const fs = require('fs');
const http = require('http');
const server = http.createServer((req, res) => {
// res.setHeader('Content-Type', 'video/mp4');
const fil = fs.createReadStream('/home/rajat/Videos/apparchitecture.mp4');
const head2 = {
'Content-Type': 'video/mp4',
};
res.writeHead(200, head2);
html
head
title= 'MySQL + Express + React + Webpack'
body
p Hello there!
const express = require('express')
const app = express()
// set the view engine for Express
app.set('view engine', 'pug')
app.get('/', (req, res) => {
// index.pug from 'views' folder will be used
res.render('index')
})