Skip to content

Instantly share code, notes, and snippets.

View robinraju's full-sized avatar

Robin Raju robinraju

View GitHub Profile
@robinraju
robinraju / radial-progress-bar.tsx
Last active March 5, 2024 16:17
React circular progress bar component
import React from "react"
interface ProgressBarProps {
progress?: number
size?: number
progressColor?: string
trackColor?: string
strokeWidth?: number
showText?: boolean
textColor?: string
@robinraju
robinraju / MD5Hash.scala
Created May 22, 2023 13:34
Generate MD5 hash of a string
import java.nio.charset.Charset
import java.security.MessageDigest
object MD5Hash {
def md5(value: String): String = {
val Utf8 = Charset.forName("UTF-8")
MessageDigest
.getInstance("MD5")
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import cats.implicits._
import io.circe.{ Codec, Decoder, Encoder }
// circe codec for serializing ZonedDateTime into JSON
object CirceDateTimeUtil {
val dateFormatter: DateTimeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME
@robinraju
robinraju / MD5.scala
Last active February 22, 2022 07:59
MD5 hash using Scala
import java.nio.charset.Charset
import java.security.MessageDigest
def md5(value: String): String = {
val Utf8 = Charset.forName("UTF-8")
MessageDigest
.getInstance("MD5")
.digest(value.getBytes(Utf8))
.foldLeft(new StringBuilder) { case (sb, byte) =>
@robinraju
robinraju / AkkaHttpServer.scala
Last active February 22, 2022 10:18
Starting an Akka HTTP server (akka-http version 10.2.8)
import scala.concurrent.ExecutionContext
import scala.concurrent.duration.DurationInt
import scala.util.{ Failure, Success }
import akka.Done
import akka.actor.{ ActorSystem, CoordinatedShutdown }
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Route
object AkkaHttpServer {
@robinraju
robinraju / PrevNext.scala
Created February 20, 2020 16:05
SCALA: Find the previous and next elements of an item in a list
def getPrevAndNext[A](lst: List[A], el: A): Option[(Option[A], A, Option[A])] = {
lst match {
case Nil => None
case x :: Nil if x == el => Some(None, x, None)
case _ :: Nil => None
case x :: y :: Nil if x == el => Some(None, x, Some(y))
case x :: y :: Nil if y == el => Some(Some(x), y, None)
case x :: y :: z :: zs if x == el => Some(None, x, Some(y))
case x :: y :: z :: zs if y == el => Some(Some(x), y, Some(z))
case _ => getPrevAndNext(lst.tail, el)
@robinraju
robinraju / .htaccess
Created October 10, 2018 09:34 — forked from jacobovidal/.htaccess
Upgrade Insecure Requests via .htaccess or meta tag to prevent mixed content
<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>
@robinraju
robinraju / angular-connectivity-detection.ts
Last active July 26, 2018 17:14
Detecting internet connectivity status inside angular application
import {Component, OnDestroy, OnInit} from '@angular/core';
import {fromEvent, Observable, Subscription} from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, OnDestroy {
onlineEvent: Observable<Event>;
$ df
This will list all mounted devices
$ sudo umount /dev/sdc<?>
where <?> is a number, look it up. Then, next:
$ sudo dd bs=4M if=input.iso of=/dev/sdc<?>
where input.iso is the input file, and /dev/sdc<?> is the USB device you're writing to.
@robinraju
robinraju / ConnectionUtil.java
Created August 4, 2016 12:20
Ignoring SSL certificate – javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
public class ConnectionUtil {
public static void trustConnection(){