Monthly Archives: February 2012

nginx startup script problems? Well! No More!

If you have messed with your nginx setup; perhaps you’ve installed it using yum and then you have come to a conclusion that you need passenger for a rails application and therefore you’ve built it again using source; you most probably have a corrupted nginx service control script now!
Well, no worries! You can fix it really easy.
1. use the “-V” switch of nginx to determine its configuration. something like
nginx -V

2. use “whereis” command to find possible locations of nginx executable. like
whereis nginx

3. to make sure you’ve stopped nginx, you can use a combination of “kill” and “pidof” commands. like
kill `pidof nginx`
Please note that I’m using ” ` ” and not ” ‘ “.

4. use a text editor like “vi” to edit the service control script.. it must be in an address like this: “\etc\init.d\nginx”. You may want to use “cp” to keep a copy of this file before you mess with it.
cp \etc\init.d\nginx \etc\init.d\nginx_original
and then
vi \etc\init.d\nginx

5. There should be lines where you can see the script decides where to look for conffile, pidfile and lockfile. edit them as per what you received from that “nginx -V” command

… and you’re finally good to go!
service nginx stop
service nginx start
service nginx status

These all should work now!

‫آخ جون! کار جدید!

خوب بالاخره گویا بعد از مدتها کار تکراری، قراره یه کار جدید با ASP.NET MVC انجام بدم!

به نظر خیلی جذاب میاد! پورتال!!

Convert IEnumerator to IEnumerable

[code lang=”csharp”]
/// <summary>
/// Converts an IEnumerator to an IEnumerable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerator"></param>
/// <returns></returns>
public static IEnumerable<T> ToIEnumerable<T>(this IEnumerator<T> enumerator) {
while (enumerator.MoveNext()) {
yield return enumerator.Current;
}
yield break;
}
[/code]

Convert a generic List to DataTable

/// <summary>
/// Converts an IList to a DataTable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="data"></param>
/// <returns></returns>
public static DataTable ToDataTable<T>(this IList<T> data) {
	PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
	DataTable table = new DataTable();
	for (int i = 0; i < props.Count; i++) {
		PropertyDescriptor prop = props[i];
		table.Columns.Add(
			prop.Name,
			prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) ?
				prop.PropertyType.GetGenericArguments()[0]
				:
				prop.PropertyType
		);
	}
	object[] values = new object[props.Count];
	foreach (T item in data) {
		for (int i = 0; i < values.Length; i++) {
			values[i] = props[i].GetValue(item);
		}
		table.Rows.Add(values);
	}
	return table;
}

بازگشت مجدد و مجدد

نمیدونم! ولی فکر کنم سرنوشت محتوم وبلاگ (های) منه که یکی به بادشون بده!

دفعه اول، محبتهای دوستمون مجتبی خان کیانی کار دستمون داد! دفعه دوم هم محبتهای یه سری دیگه از دوستان باعث شد یه موجود نکبتی به اسم Edward Evi وبلاگ ما رو بترکونه! به هر حال؛ من برگشتم که بنویسم.

این چند وقت که ننوشتم، تقریباً اوستای لینوکس شدم و PHP! کلی با nginx عیاق شدم جاتون خالی! حالا به مرور تعریف می کنم ماجرا رو!

فعلاً بای بای!