Skip to content

Instantly share code, notes, and snippets.

View romeosierra1's full-sized avatar

Rajbir Singh romeosierra1

  • Amritsar, Punjab, India
View GitHub Profile
@romeosierra1
romeosierra1 / DatabaseHelper.cs
Last active August 2, 2018 05:22
Helper class to perform CRUD operations in ASP.Net Web Forms
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for CRUDHelper
@romeosierra1
romeosierra1 / fileUpload.php
Created July 22, 2018 18:45
File Upload code in PHP with few validations
<?php
$target_dir = "photos/";
$target_file = $target_dir . basename($_FILES["photo"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if (isset($_POST["submit"])) {
$check = getimagesize($_FILES["photo"]["tmp_name"]);
if ($check !== false) {
@romeosierra1
romeosierra1 / database.php
Created July 21, 2018 19:36
PHP Script for CRUD Operations using PDO
<?php
$servername = "your-maria-db-server";
$username = "your-db-username";
$password = "your-db-password";
$dbname = "your-dbanme";
$db = new PDO('mysql:host=' . $servername . ';dbname=' . $dbname, $username, $password);
function selectAnd($entityName, $where = null, $orderBy = null)
@romeosierra1
romeosierra1 / README.txt
Last active January 11, 2018 08:10
Download Offline Installer for Visual Studio 2017 Community in Windows
CoreEditor Workload is required.
You can remove the Workloads as you deem.
Open Command Prompt in the directory where 'vs_community.exe' is downloaded.
Run the command 'vs-community-2017-offline.txt' in the Command Prompt.
Workloads
=========
@romeosierra1
romeosierra1 / Infra.md
Created January 9, 2018 17:01
Setup Angular Infra on Linux (RPM)
@romeosierra1
romeosierra1 / sql-cron.js
Created January 9, 2018 16:57
A Cron Script to schdule a task to perform SQL tasks.
const cron = require('node-cron');
let fs = require('fs');
let sql = require('mssql/msnodesqlv8');
let mssql = require('mssql');
let lastid = 0;
let config = {
driver: 'msnodesqlv8',
connectionString: 'Driver={SQL Server Native Client 10.0};Server=localhost\\Username;Database=Database;Trusted_Connection=yes;'
@romeosierra1
romeosierra1 / index.html
Created September 20, 2017 09:26
AngularJS + NodeJS + MongoDB
<!DOCTYPE html>
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Angular JS file -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
@romeosierra1
romeosierra1 / LAMP Setup
Created September 20, 2017 09:09
Commands for LAMP Setup
sudo dnf update
sudo dnf install nginx
sudo dnf install openssh-server openssh-clients
sudo dnf install httpd
sudo systemctl enable httpd.service
sudo systemctl start httpd
sudo systemctl status httpd
@romeosierra1
romeosierra1 / fedora-25-reso-hyper-v.md
Last active October 23, 2021 17:56
Change Fedora 25 resolution on Hyper-V
  • Open Terminal sudo vi /etc/default/grub
  • Add following line in end GRUB_CMDLINE_LINUX="… quiet splash video=hyperv_fb:1920x1080"
  • Update file
  • Run on terminal sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  • Reboot Virtual Machine

OR

@romeosierra1
romeosierra1 / visitorCount.js
Last active June 9, 2017 10:31
An example using moment.js, bluebird.js and node.js
let moment = require('moment');
let http = require('http');
let url = require('url');
let bluebird = require('bluebird');
let fs = bluebird.promisifyAll(require('fs'));
let visitorCount = 0;
let users = [];
if (visitorCount == 0) {