Skip to content

Instantly share code, notes, and snippets.

View rajankur's full-sized avatar

Raj Ankur rajankur

View GitHub Profile
@rajankur
rajankur / s3_bucket_policy_public.md
Created May 8, 2019 18:10
AWS - S3 Bucket Policy for Public
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadForGetBucketObjects",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
 "Resource": "arn:aws:s3:::[BUCKET_NAME]/*"
@rajankur
rajankur / CRON.md
Last active September 13, 2017 17:22
Setting Up Cron Jobs in Linux
  1. Login to your Server Instance

  2. Run the Command

crontab -e
  1. Select the desired editor to start editing your CRON file.

  2. Add your desired paths/function which you want to schedule. For example

@rajankur
rajankur / countries.php
Created September 11, 2017 08:30
Array of Countries with Continenets
public function countries() {
return $countries = [
["country" => "India", "continent" => "Asia"],
["country" => "United Kingdom", "continent" => "Europe"],
["country" => "United States", "continent" => "North America"],
["country" => "Afghanistan", "continent" => "Asia"],
["country" => "Albania", "continent" => "Europe"],
["country" => "Algeria", "continent" => "Africa"],
["country" => "American Samoa", "continent" => "Oceania"],
["country" => "Andorra", "continent" => "Europe"],
@rajankur
rajankur / AndroidHardwareCodename.java
Created September 1, 2017 07:13
Programatically get codename of your Android Device
String value = Build.DEVICE;
try {
final Class<?> sp = Class.forName("android.os.SystemProperties");
final Method get = sp.getMethod("get", String.class);
value = (String) get.invoke(null, "ro.build.product");
Log.v("UJJ", value);
} catch (Exception ignored) {
}
@rajankur
rajankur / layout_border_bottom
Created June 22, 2017 07:30 — forked from Antarix/layout_border_bottom
Setting specific border i.e top,bottom,left,right or all for Android layout
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<!-- Set the border color of your layout here -->
<stroke android:width="1dp" android:color="#3AFB03" />
<solid android:color="#3AFB03" />
</shape>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dp" >
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@rajankur
rajankur / background.js
Created January 31, 2017 19:39 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@rajankur
rajankur / disable_right_click_jquery.md
Last active October 14, 2016 16:42
Disable Right Click on a Web Page using jQuery

Disable Right Click on a Web Page using jQuery

$(document).ready(function () {
    $("body").on("contextmenu",function(e){
        return false;
    }); 
});
@rajankur
rajankur / admin_middleware_laravel.md
Created October 6, 2016 02:34
Setting up admin authentication in Laravel

Setting up admin authentication in Laravel

  • To setup admin authentication, we need to simply create a middleware and use it in your routes.
  • Create a middleware using artisan
php artisan make:middleware Admin
  • This will create a new file called "Admin.php" in app/Http/middleware.
  • Add following code in handle method
@rajankur
rajankur / amazon_ebs.md
Last active July 3, 2018 16:36
How to Attach EBS Volume in EC2 on Amazon Linux

Making an Amazon EBS Volume Available for Use

  • Right click newly created volume and attach to your instance.
  • Reboot EC2.
  • sudo file -s /dev/xvdb (where xvdb is the name of the volume)
  • if the above command shows data for the device, there is no file system on the device and you need to create one.
  • Make filesystem using sudo mkfs -t ext4 /dev/xvdb.
  • Create a mount point directory for the volume using sudo mkdir mount_point (sudo mkdir /data)
  • Mount the volume at the location: sudo mount device_name mount_point i.e. sudo mount /dev/xvdb /data
  • To mount this EBS volume on every system reboot, add an entry for the device to /etc/fstab file