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 / Most Used SQL Query.sql
Created July 10, 2023 07:43
Get the most used queries from SQL
SELECT TOP ( 10 )
dbname = DB_NAME( qt.dbid )
, qt.objectid
, qs.execution_count
, query_text = SUBSTRING(
qt.text, qs.statement_start_offset / 2 + 1
, ( CASE
WHEN qs.statement_end_offset = -1 THEN LEN( CONVERT( nvarchar(MAX), qt.text )) * 2
ELSE qs.statement_end_offset
END - qs.statement_start_offset ) / 2 )
@ghulamostafa
ghulamostafa / Sentry Installation Digital Ocean.txt
Last active May 11, 2022 06:45
Installation instructions for Sentry on Digital Ocean Docker
Get Ubuntu with NGINX
sudo apt update
sudo apt upgrade
# install Docker
# https://docs.docker.com/engine/install/ubuntu/
git clone https://github.com/getsentry/self-hosted.git --branch 22.4.0 <tag>
cd self-hosted
./install.sh
@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"
)
@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), '-', ''), ' ', ''), ':', '')
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();
}
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
@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)
@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;
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 / 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