Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
@tugberkugurlu
tugberkugurlu / program.cs
Created February 10, 2014 16:08
Simple C# yield return sample
class Program
{
static void Main(string[] args)
{
IEnumerable<string> values = GetStrings().Take(10);
foreach (string value in values)
{
Console.WriteLine(value);
}
@tugberkugurlu
tugberkugurlu / program.cs
Created February 7, 2014 14:55
C# FtpClient code
using System;
using System.IO;
using System.Net;
using System.Net.FtpClient;
using System.Threading.Tasks;
namespace FtpClientSample
{
class Program
{
class Program
{
static void Main(string[] args)
{
IEnumerable<string> basket1 = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
IEnumerable<string> basket2 = new List<string> { "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };
IEnumerable<string> basket3 = new List<string> { "21", "22", "23", "24", "25", "6", "7", "8", "9", "30" };
foreach (var item1 in basket1)
foreach (var item2 in basket2)
@tugberkugurlu
tugberkugurlu / Program.cs
Last active January 7, 2020 04:19
RavenDB BlogPost and Comments sample.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Raven.Abstractions.Indexing;
using Raven.Client;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
@tugberkugurlu
tugberkugurlu / invoke_ps1.vbs
Created January 7, 2014 13:17
Invoking a PowerShell script from Windows Scheduler silently. This won't bring up the PowerShell console while the script is running.
command = "powershell.exe -nologo -command D:\scripts\backup.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0
@tugberkugurlu
tugberkugurlu / index.html
Created January 6, 2014 16:05
JavaScript version selector I used before. Saving for future :)
<script>
(function () {
$('select[name="ProductVersion"]').change(function (e) {
var $this = $(this),
desiredVersion = $this.val(),
currentPath = document.location.pathname + document.location.search,
currentPathWithoutVersion = currentPath.substring(currentPath.indexOf('/', 1) === -1 ? currentPath.length : currentPath.indexOf('/', 1), currentPath.length),
targetLocation = '/' + desiredVersion + currentPathWithoutVersion;
document.location = targetLocation;
@tugberkugurlu
tugberkugurlu / Program.cs
Last active December 30, 2015 22:09
Type description (object graph) discoveribility through reflection.
public class PersonRequestModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
public class PersonDto
{
public int Id { get; set; }
// Data Layer Model (Entity)
public class Store : IEntity<int>, ISlug, ILocatable
{
public int Id { get; set; }
public string TypeId { get; set; }
[Required]
[StringLength(50)]
public string Name { get; set; }
-- Create Data
-- Create an Employee table.
CREATE TABLE dbo.MyEmployees
(
EmployeeID smallint NOT NULL,
FirstName nvarchar(30) NOT NULL,
LastName nvarchar(40) NOT NULL,
Title nvarchar(50) NOT NULL,
DeptID smallint NOT NULL,
@tugberkugurlu
tugberkugurlu / Program.cs
Created November 26, 2013 15:21
Get Enum names and values
public enum MyEnum : byte
{
A = 0,
B = 1,
C = 2
}
Array enumNames = Enum.GetNames(typeof(MyEnum));
Array enumValues = Enum.GetValues(typeof(MyEnum));
for (int i = 0; i < enumValues.Length; i++)