Skip to content

Instantly share code, notes, and snippets.

View asahasrabuddhe's full-sized avatar
:octocat:
Chillin'

Ajitem Sahasrabuddhe asahasrabuddhe

:octocat:
Chillin'
View GitHub Profile
@asahasrabuddhe
asahasrabuddhe / permissions.sh
Created April 2, 2018 09:22
Directory and File Permissions
#Find all files in the given path and apply permissions 664 to them
sudo find <path> -type f -exec chmod 664 {} \;
#Find all directories in the given path and apply permissions 775 to them
sudo find <path> -type d -exec chmod 775 {} \;
#Set the group id on the directory so that the files created in this directory in the future are automatically owned by the group
sudo find <path> /var/www -type d -exec chmod g+s {} \;
@asahasrabuddhe
asahasrabuddhe / sysprep.sh
Last active April 3, 2018 09:54
Ubuntu Software Installation
# Skype PPA
dpkg -s apt-transport-https > /dev/null || bash -c "sudo apt-get update; sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common -y"
echo "deb [arch=amd64] https://repo.skype.com/deb stable main" | sudo tee /etc/apt/sources.list.d/skypeforlinux.list
# Add VS Code PPA
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
// Enable target discovery
await Target.setDiscoverTargets({
discover: true
});
// The following function is invoked anytime a tab is created.
Target.targetCreated((params) => {
// If the target is not a page, return
if (params.targetInfo.type !== 'page') {
return;
}
@asahasrabuddhe
asahasrabuddhe / main.go
Created September 18, 2018 11:48
Go Email
package main
import (
"fmt"
"github.com/asahasrabuddhe/pigeon"
"github.com/asahasrabuddhe/pigeon/email"
"github.com/asahasrabuddhe/pigeon/smtp"
"github.com/asahasrabuddhe/pigeon/themes/default"
"github.com/asahasrabuddhe/pigeon/themes/flat"
)
@asahasrabuddhe
asahasrabuddhe / array_merge_doctorapp.php
Created November 15, 2018 05:17
Array Merge Logic for Doctorapp
<?php
$total_services = [
0 => [
'id' => 1,
'name' => 'a'
],
1 => [
'id' => 2,
'name' => 'b'
@asahasrabuddhe
asahasrabuddhe / 000-default.conf
Last active March 31, 2019 08:42
Dockerize your PHP Laravel Development workflow
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
@asahasrabuddhe
asahasrabuddhe / JSONComparer.java
Created March 12, 2019 10:28
Compare and find out differences between two JSON files
import com.google.common.collect.MapDifference;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
@asahasrabuddhe
asahasrabuddhe / closer.go
Last active March 22, 2019 09:14
elegant way to handle errors of deferred functions
func Close(close io.Closer) {
err := close.Close()
if err != nil {
log.Println("error when trying to close resource:", err.Error())
}
}
// example use
defer res.Close() // this gives an warning about unhandled error
@asahasrabuddhe
asahasrabuddhe / benchmark.sh
Last active March 28, 2019 10:09
Run Sysbench Benchmark
#!/bin/sh
csv_file=`echo sysbench-output.log | sed s/\.log\.txt//`
csv_file=$csv_file.csv
echo $csv_file
echo "" >> ${csv_file}
echo "Threads, Total events, Time, Events per second" >> ${csv_file}
echo "" >> $csv_file
syslog_file_name=op.log
for ((i = 1; i <= $(nproc); i = i * 2)); do
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=$i run > op.log
@asahasrabuddhe
asahasrabuddhe / 20-displaylink.conf
Created August 14, 2019 03:50
DisplayLink Configuration for Intel + Xorg