Skip to content

Instantly share code, notes, and snippets.

View iBener's full-sized avatar

Ibrahim Bener iBener

  • Ankara
  • 15:18 (UTC +03:00)
View GitHub Profile
public class Compiler
{
/// <summary>
/// Compile all the projects of the solution
/// </summary>
public void Compile(Solution solution)
{
foreach (var project in solution.Projects)
{
Compile(project);
@iBener
iBener / Result.cs
Last active July 5, 2022 09:29
Result struct for service returns
public readonly struct Result<T>
{
public Result(T value)
{
IsSuccess = true;
Value = value;
Exception = null;
}
public Result(Exception e)
@iBener
iBener / TCKimlikNoUret.html
Created April 5, 2017 11:54
Random T.C. identity number generator.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlsn="http://www.w3.org/1999/xhtml">
<head>
<title>TC NO Üreticisi</title>
<meta http-equiv="content-type" content="text/html" charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@iBener
iBener / DbContextExtensions.cs
Last active August 9, 2016 11:33
Execute a query and map it to a list of dynamic objects. Source: ChristineBoersen, https://github.com/aspnet/EntityFramework/issues/2344#issuecomment-172641417
public static class DbContextExtensions
{
public static IEnumerable<dynamic> SqlQuery(this DbContext dbContext, string Sql, Dictionary<string, object> Parameters = null)
{
using (var cmd = dbContext.Database.Connection.CreateCommand())
{
cmd.CommandText = Sql;
if (cmd.Connection.State != ConnectionState.Open)
cmd.Connection.Open();
@iBener
iBener / ModalForm
Created June 1, 2016 09:44
jQuery modal form
HTML:
<a class="js-open-modal" href="#" data-modal-id="popup">Click Me</a>
<div id="popup" class="modal-box">
<header>
<a href="#" class="js-modal-close close">×</a>
<h3><a href="http://www.jqueryscript.net/tags.php?/Modal/">Modal</a> Title</h3>
</header>
<div class="modal-body row">
public static IPlugin LoadPlugin(string dllPath)
{
var dllBytes = File.ReadAllBytes(dllPath);
var an = AssemblyName.GetAssemblyName(dllPath);
var assembly = Assembly.Load(dllBytes);
var pluginType = typeof(IPlugin);
foreach(Type type in assembly.GetTypes())
{
if(!type.IsInterface && !type.IsAbstract)
{