Skip to content

Instantly share code, notes, and snippets.

View quickgrid's full-sized avatar

Asif Ahmed quickgrid

View GitHub Profile
@quickgrid
quickgrid / TimeIntervalRegex.sh
Created April 1, 2016 03:49
The code below uses regex to read line by line and store the data read in three separate variables. The regular expression print data only for matching time within 8:00 to 10:00
#!/bin/bash
c=0
grep -E -w "8:[0-5][0-9]|9:[0-5][0-9]|10:00?" log.txt | while read ip time city ; do
echo "Logged in at $time with ip $ip and city $city "
c=$(( $c + 1 ))
echo "Found so far: $c"
@quickgrid
quickgrid / GrepRegexExactEmailMatch.sh
Created April 1, 2016 03:31
Bash GREP regex match exact email addresses and show in terminal with color highlight.
#!/bin/bash
grep --color -E -w "^[A-Za-z0-9._]+@[A-Za-z0-9.]+\.[A-Za-z]{2,6}" "EmailAddress.txt"
@quickgrid
quickgrid / SpecificLinesEmailGrepRegex.sh
Created April 1, 2016 03:22
The code below gets lines 5 to 10 from input file and perform the given email address regular expression and show the exact match output on console.
#!/bin/bash
head -10 "EmailAddress.txt" | tail -6 | grep --color -E -w "^[A-Za-z0-9._]+@[A-Za-z0-9.]+\.[A-Za-z]{2,6}"
@quickgrid
quickgrid / EvenLinePrinter.sh
Created April 1, 2016 03:09
Reads the input file line by line in while loop then checks if the number is even or odd using if condition and finally prints even lines.
#!/bin/bash
i=1
while read line
do
var=$(( $i % 2 ))
if [ $var -eq 0 ]; then
echo "$line"
fi
@quickgrid
quickgrid / FaxNumbers.txt
Created April 1, 2016 03:05
Sample Fax Numbers for testing various bash codes
+(country code)-(area code)-(fax number)
+1-212-9876543
+44-208-1234567
+443-208434-12345674
+233-11-114567
+190-209-1234567
+1-212-9876543
+44-208-1234567
+443-208434-12345674
+233-11-114567
@quickgrid
quickgrid / activity_main.xml
Created March 24, 2016 09:33
It is a layout file example showing implementation of multple scroll views.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
@quickgrid
quickgrid / 8086 asm diamond print using user input.asm
Created March 14, 2016 17:28
Prints diamond on console taking user input. Don't input 0 or 1 otherwise fix code yourself.
;Author:quickgrid
;Site: http://quickgrid.blogspot.com
;Code: 8086 assembly diamond print dual loop explained code
org 100h
.stack 100h
.data
@quickgrid
quickgrid / Even Odd Checker Loop Label Explanation.asm
Last active April 1, 2016 03:02
Check 8086 assembly even odd in loop.
;Author:quickgrid
;Site: http://quickgrid.blogspot.com
;Code: Even odd check using loop in 8086 assembly explained code
.model small
.stack 100h
.data
@quickgrid
quickgrid / Even Odd Checker Explanation.asm
Created March 14, 2016 16:38
This 8086 assembly code checks even or odd and prints their output. The code is explained in comments line by line.
;Author:quickgrid
;Site: http://quickgrid.blogspot.com
;Code: Even odd check 8086 assembly code
;predefined macro for speed coding
;define any code here that is reduandant
newline macro
@quickgrid
quickgrid / forktest.c
Last active April 1, 2016 03:03
This code is to create process in Linux and trace the flow
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
int main(int argc, char *argv[]){
printf("1.Process PID: %d\n", (int)getpid());