Skip to content

Instantly share code, notes, and snippets.

@nisar1
nisar1 / argument option or argument helper - master.cs
Created April 1, 2014 10:11
argument option or argument helper - master
//
// Options.cs
//
// Authors:
// Jonathan Pryor <jpryor@novell.com>
//
// Copyright (C) 2008 Novell (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@nisar1
nisar1 / argment in console application.cs
Created April 1, 2014 09:59
argment in console application
//argment in console application
//1. first you need to use third party dll or code
// NDesk.Options
//2. second you can use it as
using System;
@nisar1
nisar1 / call console application form asp.net.cs
Last active August 29, 2015 13:57
call console application form asp.net
//call console application form asp.net
//-------------------------------------
string path = HttpContext.Current.Server.MapPath("~/bin/txtProcessor.exe");
ProcessStartInfo info = new ProcessStartInfo(path,"");
Process p = new Process();
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo = info;
p.Start();
@nisar1
nisar1 / txt to datagridview.cs
Last active August 29, 2015 13:57
txt to datagridview and vice versa
//method 1 txt to grid
private void Form1_Load(object sender, EventArgs e)
{
var lines = File.ReadAllLines(@"D:\Nisar\workspace\biometric\backup data\ASL_001.TXT");
if (lines.Count() > 0)
{
foreach (var columnName in lines.FirstOrDefault()
.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries))
{
dataGridView1.Columns.Add(columnName, columnName);
@nisar1
nisar1 / downloading an entire web site with wget.txt
Created March 25, 2014 06:11
downloading an entire web site with wget
$ wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.website.org/tutorials/html/
@nisar1
nisar1 / jquery ui table design.js
Created March 25, 2014 05:43
jquery ui table design
//css
jtable td{font-weight: bold;}
//js
$().ready(function(){
$(".jtable th").each(function(){
$(this).addClass("ui-state-default");
});
$(".jtable td").each(function(){
@nisar1
nisar1 / attach and physical loc .sql
Created March 22, 2014 08:40
attach file + physical location
--atach file
CREATE DATABASE [SchoolDB] ON
( FILENAME = N'D:\SchoolDB.mdf' ),
( FILENAME = N'c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SchoolDB_log.ldf' )
FOR ATTACH
GO
--attach file
create database SchoolDB ON
( filename = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\SchoolDB.mdf')
@nisar1
nisar1 / Filling a DataTable or DataSet the Quick Way.cs
Last active August 29, 2015 13:57
filling a datatable or dataset the quick way
private DataTable GetDataTable()
{
string sql = "SELECT Id, Description FROM MyTable";
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
using (SqlCommand myCommand = new SqlCommand(sql, myConnection))
{
myConnection.Open();
using (SqlDataReader myReader = myCommand.ExecuteReader())
{
@nisar1
nisar1 / check constraint.sql
Last active August 29, 2015 13:57
check constraint
--► The CHECK constraint is used to limit the value range that can be placed in a column.
--► If you define a CHECK constraint on a single column it allows only certain values for this column.
--► If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns
-- in the row.
--MySQL:
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
@nisar1
nisar1 / transaction in sp mssql.sql
Last active August 29, 2015 13:57
transaction in sp mssql
create procedure uspContactPersonDeleteSingleItem
@id int
as
begin tran
delete from address where contactpersonid = @id;
if @@ERROR <> 0
begin
rollback tran
return -1
end