Skip to content

Instantly share code, notes, and snippets.

View kad1r's full-sized avatar

Kadir Avcı kad1r

View GitHub Profile
@kad1r
kad1r / License.cs
Last active December 16, 2015 02:19
License for cpu Id, hdd Id, bios Id
//CPU ID
string sQuery = "SELECT ProcessorId FROM Win32_Processor";
ManagementObjectSearcher oManagementObjectSearcher = new ManagementObjectSearcher(sQuery);
ManagementObjectCollection oCollection = oManagementObjectSearcher.Get();
foreach (ManagementObject oManagementObject in oCollection)
{
sProcessorID = (string)oManagementObject["ProcessorId"];
}
//HDD ID
ManagementObjectSearcher searcher = new
@kad1r
kad1r / projectList.cs
Created April 11, 2013 23:30
This code gives you the list of projects which are in the open solution in visual studio.
string slnPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.Parent.FullName;
List<string> projects = new List<string>();
foreach (string f in Directory.GetFiles(slnPath))
{
if (f.Contains(".sln"))
{
string[] arr = System.IO.File.ReadAllLines(f);
for (int i = 0; i < arr.Length; i++)
{
if (arr[i].StartsWith("Project"))
@kad1r
kad1r / getProjects.cs
Created April 16, 2013 21:01
Get all projects in the solution with C#
public static List<string> GetSolutionList()
{
List<string> prj = new List<string>();
// "VisualStudio.DTE.11.0"
// this represents your visual studio version
// 11.0 means vs2012
// 10.0 means vs2010
// 9.0 means vs2005
for (int i = 1; i < ((EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.11.0")).Solution.Projects.Count + 1; i++)
{
@kad1r
kad1r / dropSP.sql
Created April 16, 2013 21:22
Drop all stored procedures in database
-- first drop function
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'p'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
exec('drop procedure ' + @procName)
@kad1r
kad1r / gist:6046439
Last active December 20, 2015 01:08
HttpPost
public static string GetHtmlPage(string _url)
{
String strResult;
WebResponse objResponse;
WebRequest objRequest = HttpWebRequest.Create(_url);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
sr.Close();
@kad1r
kad1r / htmlTopdf_itextsharp
Created July 29, 2013 15:19
You can convert your html to pdf with itextsharp dll. Just make sure your html tags closed well.
// Namespaces
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
// Lets consider your html looks like HTML.
string HTML = "<table style=\"width:800px;\"><tr><td style=\"width:100px;\">FOO</td><td style=\"width:10px\">:</td><td>BLABLABLA ...</td></tr></table>";
@kad1r
kad1r / _async function
Created August 1, 2013 07:49
Async calls in ASP.Net
delegate void _asyncFunction(params object[] args);
static void Main()
{
_asyncFunction _delegate = new _asyncFunction(Foo);
_delegate.BeginInvoke(new object[] { "fooo" }, null, null);
}
static void Foo(params object[] args)
{
@kad1r
kad1r / find.js
Created August 1, 2013 07:59
Get input hidden types and checkboxes ...
function hiddenByName() {
// consider you have a div or table which name is dvHiddenValues
// consider you have a hidden inputs which name is myHdValues
var arrList = new Array();
// that gives you the list of hidden inputs which name is myHdValues
var hiddenList = document.getElementById('dvHiddenValues').document.getElementsByName('myHdValues');
for (var i = 0; i < hiddenList.length; i++) {
arrList.push(hiddenList[i].value);
}
}
@kad1r
kad1r / CreateThumbFromVideo.cs
Created September 26, 2013 21:59
Create a thumbnail image from video with ffmpeg with .net
using System;
using System.Diagnostics;
using System.IO;
using System.Web;
namespace WebApp.HelperClass
{
public class CreateThumbFromVideo
{
/// <summary>
// I have ping list like Wordpress, and I'm getting it from db.
// string[] listToPing = dtGetPingList.Rows[0]["pinglist"].ToString().Split(',');
private void sendPings(string[] listToPing)
{
for (int i = 0; i < listToPing.Count; i++)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(listToPing[i].ToString());
request.Method = "POST";
request.ContentType = "text/xml";