Skip to content

Instantly share code, notes, and snippets.

Avatar
😃
Building an open-source LMS

Rajat Saxena rajat1saxena

😃
Building an open-source LMS
View GitHub Profile
View keybase.md

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 Dec 27, 2019
Super Fast Redux Tutorial
View redux.js
const redux = require('redux')
const store = redux.createStore((state = {}, action) => {
switch (action.type) {
case 'demo':
return { demo: true }
default:
return state
}
})
View printableHexString.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 Jun 24, 2018
generate_sha512_of_a_file.kt
View generateChecksum.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 ""
View get_raw_image_data.kt
// 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) {
View index.pug
html
head
title= 'MySQL + Express + React + Webpack'
body
p Hello there!
View index.js
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')
})
View express-react-index.js
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.status(200).send({
data: 'It works!'
})
})
app.listen(3000)
View jsx-calculate-expression.jsx
<button disabled={true}>Press me {3+1} times!</button>;