Skip to content

Instantly share code, notes, and snippets.

@sasajib
sasajib / bucket-policies-primer.md
Created August 17, 2020 09:33 — forked from krishnasrinivas/bucket-policies-primer.md
Explanation of bucket polices by example

Bucket Policy

Bucket policy is an access policy available for you to grant anonymous permissions to your Minio resources. Bucket policy uses JSON-based access policy language.

This section presents a few examples of typical use cases for bucket policies. The policies use testbucket strings in the resource value. To test these policies, you need to replace these strings with your bucket name. For more information please read Amazon S3 access policy language

Granting Read-Only Permission to an Anonymous User

The following example policy grants the s3:GetObject permission to any public anonymous users. This permission allows anyone to read the object data under testbucket, which is useful for when you have publicly readable assets. A typical example is a website assets stored in testbucket.

@sasajib
sasajib / create-thumbnails
Created April 7, 2020 02:17 — forked from johnnyg/create-thumbnails
Generate thumbnails and output media info
#!/bin/bash
parse_time() {
IFS=' ' read -ra PART <<< "$1"
seconds=0
for i in "${PART[@]}"; do
number=$(expr match $i '\([0-9]\+\)')
unit=$(expr match $i '[0-9]*\([a-z]\+\)')
case $unit in
h)
@sasajib
sasajib / LEPP.md
Created March 10, 2020 07:52 — forked from cham11ng/LEPP.md
LEPP Setup - Ubuntu 16.04 LTS

A Relatively Secure Server Stack Setup in Ubuntu 16.04 LTS

Anup Dhakal

Sagar Chamling

Introduction

In this guide, LEPP stands for Linux, Nginx (pronounced as Engine-X) , Postgres and PHP (PHP Hypertext Preprocessor).

@sasajib
sasajib / clean-up-boot-partition-ubuntu.md
Created October 16, 2018 22:24 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@sasajib
sasajib / loop_aria2.sh
Created December 21, 2017 20:57 — forked from jonbakerfish/loop_aria2.sh
aria2 downloads a list of files, loop until all file are finished
#!/bin/bash
aria2c -j5 -i list.txt -c --save-session out.txt
has_error=`wc -l < out.txt`
while [ $has_error -gt 0 ]
do
echo "still has $has_error errors, rerun aria2 to download ..."
aria2c -j5 -i list.txt -c --save-session out.txt
has_error=`wc -l < out.txt`
sleep 10
@sasajib
sasajib / util.js
Last active September 19, 2017 18:56
Javascript Utils
//[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17]]
function grouped(arr, limit){
return arr.map((data, index) => {
return index % limit === 0 ? arr.slice(index, index + limit) : null;
}).filter((item) => { return item; })
}
//range crete [0,1,2,3,4...number]
function range(number){
return Array.from(new Array(number), (x,i) => i)
@sasajib
sasajib / run.sh
Created May 19, 2017 22:15 — forked from jakub300/run.sh
Compile headless shell (Chromium)
# Based on:
# http://www.zackarychapple.guru/chrome/2016/08/24/chrome-headless.html
# https://www.chromium.org/developers/how-tos/get-the-code
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
apt-get update
apt-get install -y curl git htop man unzip vim wget python
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:`pwd`/depot_tools
mkdir Chromium && cd Chromium
@sasajib
sasajib / case_class.py
Created March 29, 2017 19:18 — forked from wickman/case_class.py
case-class like thing in python
# E.g. TaskClass = CaseClass('name', 'owner', 'pid')
# task1 = TaskClass(name = "hello", owner = "brian", pid = 15)
# task2 = TaskClass(name = "world", owner = "brian", pid = 13)
# tasks = [task1, task2]
#
# filter(lambda task: task.where(owner = "brian"), tasks) => [task1, task2]
# filter(lambda task: task.where(owner = "brian", pid = 13), tasks) => [task2]
#
# matcher = TaskClass(pid = 13)
# filter(lambda task: task.match(matcher), tasks) => [task2]
@sasajib
sasajib / AkkaStreamSparkIntegration.scala
Created March 11, 2017 20:09 — forked from lloydmeta/AkkaStreamSparkIntegration.scala
Example for how to connect Akka Stream and Spark Streaming by turning creating a Flow element that feeds into an InputDstream
import akka.actor._
import akka.stream.scaladsl.Flow
import org.apache.spark.streaming.dstream.ReceiverInputDStream
import org.apache.spark.streaming.receiver.ActorHelper
import akka.actor.{ ExtensionKey, Extension, ExtendedActorSystem }
import scala.reflect.ClassTag
object AkkaStreamSparkIntegration {
package tech.webstar.utils
import scala.collection.mutable
/**
* @author sasajib
*/
trait BoundedQueue[A] extends mutable.Queue[A] {
def maxSize: Int
override def +=(a: A): this.type = {