Blog Archive

Simple, Easy, Risk and Change

I want to share some of what I’ve been thinking about along those lines. What follows is a collection of some of my evolving thoughts relating to change and complexity. Let me know your thoughts in the comments.

4

Simple vs Easy

A few years ago, the creator of Clojure- did a talk called “Simple made Easy”. It’s an excellent talk, and I highly encourage you to watch it. In the talk, he talks about the difference between simple and easy. One is a measure of complexity, the other of effort.

One of the really interesting takeaways, is that we need to measure complexity separately from the effort that it takes to produce.

Change and Risk

All change introduces risk. Period. The amount of risk that is introduced does vary wildly with each change. Are you changing well understood code? Are you changing simple code? Are you changing well tested code? Are the changes well peer-reviewed?

Change is so risky, that decades ago we started writing software in a manner that reduced the amount of change we would have to do. We built plugin systems. We built configuration files. We built hooks and event systems to try to isolate change to minimize risk.

Optimizing for Simple

I think the reason is that we’ve trained ourselves to optimize for Easy. If you look at frameworks and libraries, they try as hard as possible to make themselves easy to use. They use the term “easy” as a tag-line. And they do so for good reason (marketing).

When you optimize for “easy” it becomes trivial to say “well, I don’t need a test here, the code is too hard to test”. When you optimize for “easy” you can fall into the trap of saying “this is just glue code, it doesn’t need a test”.


function makeFoo(): Foo {
return new Foo();
}


function makeBar(Foo $foo = null): Bar {
return new Bar($foo ?: makeFoo());
}


Screenshot of the active window on Mac

I find myself needing to take screen captures of the currently active window in OS X reasonably frequently. The built-in way to do this on a Mac is to use shift+cmd+4, then press space and then use your mouse to highlight the window and click.

For a good proportion of the time, I’m not using a mouse, so this doesn’t work great.

There’s a built-in command line utility called screencapture which requires you to know the Quartz window id of the window you want to capture, so it’s now a multi-step process to just take a screenshot of the currently active window.

QuickGrab

Fortunately, there’s a little open source utility called QuickGrab which solves this. (The binary quickgrab is in the repo, so you don’t have to compile)

As an aside, that link is to my fork which fixes Chrome. A friend recently discovered that the current master version fails to take screenshots of Chrome if it’s the active window. When I investigated, I discovered that it’s because Chrome creates an invisible window at the top of its stack which needs to be ignored when looking for the active window. That’s what my update does.

QuickGrab is really easy to use. From the command line you simply do:

Enter Alfred

2

Alfred is little app that can run commands for you from a text window or via a hotkey, so this is what I use to trigger QuickGrab.

To use, I ensure that I have the window I want to capture active and then activate Alfred, type screenshot and press return. This then creates a PNG file with a name similar to Screenshot-20160724-1124429.png on my desktop.

I also set up a hotkey for cmd+§ (finally a use for that § key!) which does the same thing.

I’ve created Screenshot.alfredworkflow which does all this, so simply download it and install it into your Alfred and you’re good to go! This workflow includes the quickgrab binary, so you don’t need to get it separately.

You can, of course, edit the workflow once you’ve installed it to change the keyword and the shortcut key to something else, should you want to.

Is SEO right for your business?

This may seem strange coming from an SEO guy, but there are many situations where organic search may not be the best option for a given marketing challenge.

1

1. Budget

This is the first and most common issue we see. The business wants to rank for a given term within a fixed time period for a set budget. Ultimately, you have to survey the landscape; and whether you are a local business or a national business, you must be realistic about what your spend needs to be to effectively move you to where you want to be.

Estimating the cost of SEO projects is often difficult in itself. There are a lot of variables, but, in most cases, by using tools like Majestic and Ahrefs you can get a handle on what the competition looks like and what a ballpark approach to moving forward will look like.

2. Timeframe

The timeframe issue usually crops up along with budget, and there is commonly a desire to be top three within a given time period. Again, you can’t simply dictate how long this will take.

For one, SEO can be and usually is a moving target. Furthermore, if you are on page three and want to rank in the top three listings on page one, then we have to do some work and get a handle on how quickly you can move forward. Typically, as we get closer and closer to the top of the first page, then the improvements can slow down and results can jump around a little.

3. Ad competition

Whilst there is much fuss and bluster regarding Penguin and Panda and other components of the algorithm that aggressively target low-quality content or attempts to manipulate the results, the real war on spam is fought by the page layout team.

Competition in the ad space is fierce as well. Advertisers have a close eye on what keywords are driving results and can sculpt perfect landing pages and ad creative to ensure the organic listings around commercial terms are seeing fewer and fewer clicks.

4. The wrong keywords

We see this often, and it is usually the case that some keywords are unlikely to deliver the goods while others don’t work because there’s no strategy in place to turn those clicks into customers. The best example here would be where informational keyword searches are targeted but the user is dropped onto a specific commercial page.

Often it is not clear how a given set of terms will perform, and as such, we like to conduct some basic testing using PPC to better determine the value of those keywords. Buying 1000 clicks and demonstrating results with some simple sums to determine metrics can help you dodge an SEO bullet.

5. New businesses

Organic search can take time and effort, so if you are setting up in an existing and highly competitive industry and absolutely require fast results, then SEO may not be right for you. Even in the local business space, we can see campaigns take six months or longer to really deliver the goods.

If speed is important to you, you may want to focus on a marketing tactic that can deliver the goods quickly. Then, look at slowly building up your organic traffic in the background whilst carefully measuring the results from your organic campaign.

 

How to convert gridview coulnm in rows using asp.net c#.

I am going to explain how to convert grdiview colunm in rows asp.net c#.This is simple toimplement.I stored database records in datatable and after that i convert all datatable rows into columns and then convert column into rows.After complete this process then i just bind the gridview with converted datatable.I convert gridview column into rows on button click but you can use this as you required.

0Demo1

Run this script in sql server –

CREATE TABLE [dbo].[Articletable](

[ID] [int] NOT NULL,

[Title] [varchar](200) NULL,

[Description] [varchar](400) NULL,

[Author] [varchar](50) NULL

) ON [PRIMARY]

Method for convert column into rows is below-

public static DataTable ConvertGrid(DataTable dt)

{

DataTable dtConvert = new DataTable();

for (int i = 0; i <= dt.Rows.Count; i++)

{

dtConvert.Columns.Add(“Col_”+Convert.ToString(i));

}

for (int i = 0; i < dt.Columns.Count; i++)

{

dtConvert.Rows.Add();

dtConvert.Rows[i][0] = dt.Columns[i].ColumnName;

for (int j = 0; j < dt.Rows.Count; j++)

{

dtConvert.Rows[i][j + 1] = dt.Rows[j][i];

}

}

return dtConvert;

}

For use this above method in project first create a website in visual studio and then add a page and then design your page as shown below-

<%@ Page Language=”C#” AutoEventWireup=”true”CodeFile=”GridRowAsColumns.aspx.cs”

Inherits=”GridRowAsColumns” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title></title>

<link href=”ClassicGridView.css” rel=”stylesheet”type=”text/css” />

</head>

<body>

<form id=”form1″ runat=”server”>

<div style=”margin-left: 50px; margin-top: 40px;”>

<h3>

Convert rows to columns and columns to rows in GridView using c#</h3>

<asp:GridView ID=”GrdSimple” runat=”server” Width=”48%”Font-Names=”Trebuchet MS”>

<HeaderStyle CssClass=”HeaderStyle”HorizontalAlign=”Center” />

<RowStyle CssClass=”RowStyle” HorizontalAlign=”Center” />

<AlternatingRowStyle CssClass=”AltRowStyle”HorizontalAlign=”Center” />

</asp:GridView>

<br />

<asp:Button ID=”btnConvert” runat=”server” Text=”Convert Grid Rows into Columns”

OnClick=”btnConvert_Click” />

</div>

</form>

</body>

</html>

After complete design page then write the c# code in code behind page.As below-

using System;

using System.Web.UI.WebControls;

using System.Data;

using System.Configuration;

using System.Data.SqlClient;

 

public partial class GridRowAsColumns : System.Web.UI.Page

{

SqlConnection con = new SqlConnection();

protected void Page_Load(object sender, EventArgs e)

{

con.ConnectionString = ConfigurationManager.ConnectionStrings[“cn”].ConnectionString;

if (con.State == ConnectionState.Closed)

{

con.Open();

}

GrdSimple.DataSource = dt_Grid();

GrdSimple.DataBind();

}

 

private DataTable dt_Grid()

{

DataTable dt = new DataTable();

string qry = “select * from Articletable”;

SqlDataAdapter adp = new SqlDataAdapter(qry,con);

adp.Fill(dt);

return dt;

}

 

public static DataTable ConvertGrid(DataTable dt)

{

DataTable dtConvert = new DataTable();

for (int i = 0; i <= dt.Rows.Count; i++)

{

dtConvert.Columns.Add(“Col_”+Convert.ToString(i));

}

for (int i = 0; i < dt.Columns.Count; i++)

{

dtConvert.Rows.Add();

dtConvert.Rows[i][0] = dt.Columns[i].ColumnName;

for (int j = 0; j < dt.Rows.Count; j++)

{

dtConvert.Rows[i][j + 1] = dt.Rows[j][i];

}

}

return dtConvert;

}

 

protected void btnConvert_Click(object sender, EventArgs e)

{

GrdSimple.ShowHeader = false;

GrdSimple.DataSource = ConvertGrid(dt_Grid());

GrdSimple.DataBind();

foreach (GridViewRow GridRows in GrdSimple.Rows)

{

GridRows.Cells[0].CssClass = “HeaderStyle”;

GridRows.Cells[0].Font.Bold = true;

}

btnConvert.Text = “Successfully Converted”;

}

}

How to Create table manually and by script in Sql Server 2008.

In this tutorial i will explain how to Create table manually and by script in Sql Server. Table : A Table is a set of values and a table has a specified number of columns, but can have any number of rows.

1

There is two ways to create Sql Table
1. We can create table manually in Sql Server. Open Microsoft SQL Server Management Studio and select Database in which you want to create Table then Right Click on Table Menu and select New Table. Give Proper name, Data Type and Size of each Columns. You can set ID column as Primary Key.See below.

2

Primary key: Primary keys contain unique values and a primary key column cannot contain NULL values.

And in last Right Click on table Tab then click on Save Table and then Give Table Name.See below.

3

2.The second method is use to script for creating Table in SQL Server.

Right click on Database in which you want to make table then click on New Query menu ,New Query window will open right side as below,then write the script and after complete the script press f5.Table Created sucessfully.

4

Create table empoyee

(

EmpID int NOT NULL,

EmpName varchar(50) NOT NULL,

EmpAddress Varchar(50),

EmpMobile varchar(50),

PRIMARY KEY (EmpID)

)

How to bind html dropdownlist with static items in mvc.

I am going to explain how to bind html dropdownlost with static items in mvc.This is simple way to bind dropdownlist with static data if data not coming from database.

 

Use below code to bind dropdownlist : –

@Html.DropDownList(“Status”, new List<SelectListItem>

{

new SelectListItem{ Text=”Process”, Value = “0” },

new SelectListItem{ Text=”Stop”, Value = “1” },

new SelectListItem{ Text=”Pending”, Value = “2” }

})

Difference b/w interface and a class

Difference b/w interface and a class used in android with examples….the example will clear the use of these two and where to use a interface or a class

The key technical differences between an abstract class and an interface are:

  • Abstract classes can have constants, members, method stubs and defined methods, whereas interfaces can only have consts and methods stubs.
  • Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public.
  • When inheriting an abstract class, a concrete child class must define the abstract methods, whereas an an abstract class can extend another abstract class and abstract methods from the parent class don’t have to be defined.
  • Similarly, an interface extending another interface is not responsible for implementing methods from the parent interface. This is because interfaces cannot define any implementation.
  • A child class can only extend a single abstract (or any other) class, whereas an interface can extend or a class can implement multiple other interfaces.
  • A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility.

Interfaces

An interface is an empty shell, there are only the signatures (name / params / return type) of the methods. The methods do not contain anything. The interface can’t do anything. It’s just a pattern.
Implementing an interface consumes very little CPU, because it’s not a class, just a bunch of names, and therefore there is no expensive look-up to do. It’s great when it matters such as in embedded devices.

Abstract classes

Abstract classes, unlike interfaces, are classes. They are more expensive to use because there is a look-up to do when you inherit from them.

Abstract classes look a lot like interfaces, but they have something more : you can define a behavior for them.

Implementation:-

While abstract classes and interfaces are supposed to be different concepts, the implementations make that statement sometimes untrue. Sometimes, they are not even what you think they are.

In Java, this rule is strongly enforced, while in PHP, interfaces are abstract classes with no method declared.

In Python, abstract classes are more a programming trick you can get from the ABC module and is actually using metaclasses, and therefore classes. And interfaces are more related to duck typing in this language and it’s a mix between conventions and special methods that call descriptors (the __method__ methods).

How to create store procedure for insert data in database table in sql server.

I am going to explain how to create store procedure for insert data in table in sql server 2008.This is simple to create store procedure in sql server.

1

For create store procedure in sql server
1.Open Microsoft SQL Server Studio
2.Open DataBase where you want to create store procedure.See below-

2

After select Database then open Programmabilty and right click on StoreProcedure and click on New Store procedure-See below

3

Then new query tab will open in right side,Remove all content from this tab.See below

4

Then write the query as below-

CREATE PROCEDURE sp_InsertEmp
(
@ID int,
@Name varchar(50),
@Address varchar(50)
)
As
Insert INTO tbEmp (ID,Name,Address) VALUES(@ID,@Name,@Address)

How to create login page with proper validation and remember me functionality using asp.net c#

This example show you how to create login page/form funcationality.Here i am matching EmailID and Password.You can simple add this code in your project.I am giving proper table script in this tutorial,simply run script in your SQL Server and configure your web.config file.

Make a table for login details in SQL Server or run table script  in Sql server and insert EmailID and Password manually in table, after run this script table automatically create in your database.Script is here –

CREATE TABLE [dbo].[tblLogin](

[UserID] [int] IDENTITY(1,1) NOT NULL,

[EmailID] [varchar](50) NULL,

[Password] [varchar](50) NULL,

CONSTRAINT [PK_tblLogin] PRIMARY KEY CLUSTERED

(

[UserID] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF,IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON,ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

 

GO

SET ANSI_PADDING OFF

GO

After Create table in Sql Server then open Visual Studio and make a new website using C#, then add new item in website . After add new page in your website then add a label control and Textbox with the name txtEmailID and second is txtPassword and a button control in design page.

<%@ Page Language=”C#” AutoEventWireup=”true”CodeFile=”Login.aspx.cs” Inherits=”Login” %>

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title></title>

<style type=”text/css”>

.style1

{

width: 45%;

}

.style2

{

width: 88px;

}

.style3

{

width: 207px;

}

</style>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<h2 style=”margin-left: 40px;margin-top:130px;”>Login Functionality</h2>

<table class=”style1″ style=”margin-left: 40px;background-color: #E7E7E7; padding: 10px; border: 1px solid Gray;

border-radius: 10px;”>

<tr>

<td class=”style2″>

Email ID :

</td>

<td class=”style3″>

<asp:TextBox ID=”txtEmailID” placeholder=”EmailID”runat=”server” Width=”193px”></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ErrorMessage=”Enter EmailID”

runat=”server” ControlToValidate=”txtEmailID”Style=”color: #FF0000; float: left;

font-style: italic;”></asp:RequiredFieldValidator>

<asp:RegularExpressionValidatorID=”RegularExpressionValidator1″ControlToValidate=”txtEmailID”

runat=”server” ErrorMessage=”Enter the correct EmailID”Style=”color: #FF0000;

margin-left: -95px; float: left;font-style: italic;”ValidationExpression=”\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”></asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td class=”style2″>

Password :

</td>

<td class=”style3″>

<asp:TextBox ID=”txtPassword” placeholder=”Password”TextMode=”Password” runat=”server” Width=”192px”></asp:TextBox>

</td>

<td>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ErrorMessage=”Enter Password”

ControlToValidate=”txtPassword” runat=”server”Style=”color: #FF3300; font-style: italic”></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td class=”style2″>

&nbsp;

</td>

<td class=”style3″>

<asp:Button ID=”btnLogin” runat=”server” Text=”Login”Width=”62px”

OnClick=”btnLogin_Click” />

<asp:CheckBox ID=”chkRememberme”style=”float:right;margin-top:4px;  margin-right: 12px;”Text=”Remember me?” runat=”server” />

</td>

<td>

&nbsp;

</td>

</tr>

<tr>

<td class=”style2″>

&nbsp;

</td>

<td class=”style3″>

<asp:Label ID=”lblErrorMsg” runat=”server” Style=”color: #FF0000″></asp:Label>

</td>

<td>

&nbsp;

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

 

Asynchronous file upload using ajax and jquery in asp.net c#

I am going to expain in this article how create custom properties in webuser controls, where you need to pass a value from your .aspx page to the user control (.ascx). This is possible in several ways but the easiest way is to create a properties of the user control and set it into the .aspx page and access it from the user control

Below  source code  is for how to pass boolean  value to user control-put this on page like below-.

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class CustomPropertiese : System.Web.UI.UserControl

{

private Boolean vp_visible = false;

 

# region Properties

 

public Boolean IsVisible

{

get { return vp_visible; }

set { vp_visible = value; }

}

 

#endregion Properties

 

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

this.Visible = IsVisible;

}

}

}

another example-Here i am passing integer values to the User Control-

Pass attribute to the usercontrols like below-

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;

 

public partial class controls_PremiumVenues : System.Web.UI.UserControl

{

Class obj = new Class();

private int vp_count = 0;

 

# region Properties

 

public int NoOfVenues

{

get { return vp_count; }

set { vp_count = value; }

}

 

#endregion Properties

 

protected void Page_Load(object sender, EventArgs e)

{

BindHotVenues(NoOfVenues);

}

}