Skip to content

Instantly share code, notes, and snippets.

View ghulamostafa's full-sized avatar
:bowtie:
bowie

Ghulam Mustafa ghulamostafa

:bowtie:
bowie
View GitHub Profile
@ghulamostafa
ghulamostafa / Template for a Stored Procedure used by TraditionalTemplate: ghulamostafa
Last active September 16, 2017 03:06
This is a sample for select and insert stored procedures
-- =============================================
-- Author: Ghulam Mustafa
-- Create date: 30-Jun-2017
-- Description: Here goes the description for Select Stored Procedure
-- =============================================
CREATE PROCEDURE SP_NameOfStoredProcedureForSelect
-- Add the parameters for the stored procedure here
@Action varchar(50) = NULL
/*Here goes the rest of the parameters*/
,@result int = 0 output
@ghulamostafa
ghulamostafa / MIMEAttachment.cs
Last active May 8, 2018 15:40
multipart/form-data - Multipart MIME in Web API with form data
public async Task<object> Post()
{
//First check if request is Multipart Content
if (!Request.Content.IsMimeMultipartContent())
{
return "Nope. Not this one.";
}
else
{
//The attachment type
@ghulamostafa
ghulamostafa / SplashScreen.js
Last active July 3, 2018 19:58
Creating a splash screen in React Native using ReactNavigation only.
import React, { Component } from 'react';
import { View, Image } from 'react-native';
import { Container, Content, Footer, Body, Text } from 'native-base';
import { StackActions, NavigationActions } from 'react-navigation';
export default class extends Component {
constructor(props){
super(props);
this.state = {
timer: 5 //The duration you want it to stay in seconds
class HomeScreenGridButton extends StatelessWidget {
final String text;
final Function onTap;
final Color color;
final IconData icon;
final Color iconColor;
final bool disabled;
const HomeScreenGridButton(
@ghulamostafa
ghulamostafa / mssql_user_access.sql
Created May 19, 2019 17:10
Given Access to a Specific User to a Specific Database
--Step 1: (create a new user)
CREATE LOGIN hello WITH PASSWORD='foo', CHECK_POLICY = OFF;
-- Step 2:(deny view to any database)
USE master;
GO
DENY VIEW ANY DATABASE TO hello;
@ghulamostafa
ghulamostafa / compass_bearing.dart
Created June 29, 2019 07:49
Calculating the bearing to a coordinate/location from another coordinate/location in Dart using Math for Compass.
//This function takes two sets of values, say Coordinates and returns the angle bearing to the location.
//a1 and a2 being latitude and longitude of location a
//b1 and b2 being latitude and longitude of location b
double bearing(double a1, double a2, double b1, double b2) {
const double TWOPI = 6.2831853071795865;
const double RAD2DEG = 57.2957795130823209;
// if (a1 = b1 and a2 = b2) throw an error
//double theta = atan2(b1 - a1, a2 - b2);
double theta = math.atan2(b1 - a1, a2 - b2);
if (theta < 0.0)
import 'package:flutter/material.dart';
class ChatConversationScreen extends StatefulWidget {
@override
_ChatConversationScreenState createState() => _ChatConversationScreenState();
}
class _ChatConversationScreenState extends State<ChatConversationScreen> {
var currentAudioIndex = -1; //The index of the currently playing audio. By default it is -1
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
class DownloadFileScreen extends StatefulWidget {
@override
_DownloadFileScreenState createState() => _DownloadFileScreenState();
}
@ghulamostafa
ghulamostafa / Script for SQL Database Backup.sql
Last active August 23, 2021 11:34
MS SQL Server Database Backup Script
DECLARE @name NVARCHAR(256) -- database name
DECLARE @path NVARCHAR(512) -- path for backup files
DECLARE @fileName NVARCHAR(512) -- filename for backup
DECLARE @fileDate NVARCHAR(40) -- used for file name
-- specify database backup directory
SET @path = 'C:\test\'
-- specify filename format
SELECT @fileDate = REPLACE(REPLACE(REPLACE(CONVERT(NVARCHAR(20),GETDATE(),120), '-', ''), ' ', ''), ':', '')
@ghulamostafa
ghulamostafa / read_from_console_in_go_and_cast_to_int.go
Last active November 16, 2021 12:04
Reading from console in Go and cast to integer/int.
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)