Skip to content

Instantly share code, notes, and snippets.

View portal7's full-sized avatar

Alfredo Severo portal7

  • Buenos Aires, Argentina
View GitHub Profile
var navProps = new Expression<Func<Beer, object>>[]
{
a => a.Ingredients,
a => a.Sizes,
a => a.Hangovers
});
@portal7
portal7 / DataTableResultSet.cs
Last active August 22, 2016 14:00 — forked from OllieJones/DataTableResultSet.cs
C# code for handling Ajax calls for the DataTables.net client table-rendering plugin.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
/// <summary>
/// Resultset to be JSON stringified and set back to client.
/// </summary>
///
namespace DataTables
{
@portal7
portal7 / gist:773710d8309a8028bb08
Created March 22, 2016 16:29 — forked from rXc3NtR1c/gist:ce24e8a3667e50993f1c
October CMS Web.Config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="themes/.*/(layouts|pages|partials)/.*.htm" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
@portal7
portal7 / ApplicationUser.cs
Created March 18, 2016 19:22
Granular permissions with certain requirements for an MVC site
public class ApplicationUser : IPrincipal
{
private readonly RoleSet roles;
public ApplicationUser(RoleSet roles)
{
this.roles = roles;
}
public bool IsInRole(string role)
@portal7
portal7 / importCSVFromFTP_ToMySQLDB.php
Created February 12, 2016 16:47
Connect to FTP Download a CSV and process with PHP to MYSQL Database
<?php
$source = "DespGoods.csv";
$target = fopen("DespGoods.csv", "w");
$conn = ftp_connect("ftp.server.com") or die("Could not connect");
ftp_login($conn,"ftpusername","ftppassword");
ftp_fget($conn,$target,$source,FTP_ASCII);
echo "file downloaded.\n";
@portal7
portal7 / vertical-center-boostrap3.css
Last active November 12, 2015 13:49
Class Center for Vertical Centering on Bootstrap 3
.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one :-) */
display: flex;
align-items: center;
}
using System;
using System.Text;
using System.Security.Cryptography;
public class Program
{
private const string key = "key";
private const string message = "message";
private static readonly Encoding encoding = Encoding.UTF8;
@portal7
portal7 / jquery.json.extender.js
Last active October 30, 2015 14:08
jQuery Json Parser Extender Plugin
/*!
* jQuery.parseJSON() extension (supports ISO & Asp.net date conversion)
*
* Version 1.0 (13 Jan 2011)
*
* Copyright (c) 2011 Robert Koritnik
* Licensed under the terms of the MIT license
* http://www.opensource.org/licenses/mit-license.php
*/
(function ($) {
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<ul></ul>
<script>
using System;
namespace ConsoleApplication1.Migrations
{
using System.Data.Entity.Migrations;
internal sealed class Configuration : DbMigrationsConfiguration<DatabaseContext>
{
public Configuration()
{