Skip to content

Instantly share code, notes, and snippets.

View nukedbit's full-sized avatar
🏠
Working from home

Sebastian Faltoni nukedbit

🏠
Working from home
View GitHub Profile
@nukedbit
nukedbit / options_fix.cs
Last active August 29, 2015 13:56
ASP.NET WCF/REST OPTIONS error 405 method not allowed
//On Global.asax.cs
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
@nukedbit
nukedbit / web.config
Last active August 29, 2015 13:56
Enable Permalinks for wordpress on windows server
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<rewrite>
<rules>
<rule name="Imported Rule 2" stopProcessing="true">
@nukedbit
nukedbit / MvxIocSupportingTest.cs
Created June 22, 2014 14:22
MvvmCross Ioc Test support with real plugin loading for WindowsStore
// MvxIoCSupportingTest.cs
// (c) Copyright Cirrious Ltd. http://www.cirrious.com
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
// Contributions and inspirations noted in readme.md and license.txt
//
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
// Modified by Sebastian Faltoni www.nukedbit.it
using Cirrious.CrossCore.Core;
using Cirrious.CrossCore.IoC;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace AssetVersion.Sdk.HttpClients
{
public abstract class HttpClientSyncronous<T> where T : class
{
@nukedbit
nukedbit / TapGesture.cs
Created August 11, 2014 20:17
Add Tap Gesture to Xamarin.Forms Image Control
ImageView.GestureRecognizers.Add (new TapGestureRecognizer()
{
Command = new Command (() => contentPage.DisplayAlert ("Titolo", "Messaggio", "Cancel"))
});
var client = new HttpClient();
var result = client.GetAsync(new Uri("http://www.google.ti")).ConfigureAwait(false).GetAwaiter().GetResult();
@nukedbit
nukedbit / AutofacGlobalFilterProvider.cs
Created December 2, 2014 22:36
AutofacGlobalFilterProvider for asp.net mvc vnext
public class AutofacGlobalFilterProvider : IGlobalFilterProvider
{
private readonly IReadOnlyList<IFilter> _filters;
public AutofacGlobalFilterProvider(IOptions<MvcOptions> optionsAccessor, IEnumerable<IFilter> customFilters)
{
var filters = optionsAccessor.Options.Filters.ToList();
filters.AddRange(customFilters);
@nukedbit
nukedbit / ChoiceCell.java
Created February 6, 2015 20:29
ChoiceCell with controller
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package touchfx.model;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@nukedbit
nukedbit / mysql_fsharp.fsx
Created April 1, 2015 21:23
mysql_fsharp
#r @"bin/Debug/MySql.Data.dll"
#r @"bin/Debug/FSharp.Data.SqlProvider.dll"
open System
open System.Linq
open FSharp.Data.Sql
open MySql.Data
let resPath = __SOURCE_DIRECTORY__ + @"/bin/Debug/"
@nukedbit
nukedbit / EnumerableExtensions.cs
Created November 12, 2015 17:05
Split IEnumerable in chunks
{
public static class EnumerableExtensions
{
public static IEnumerable<T[]> Split<T>(this IEnumerable<T> source, int chunkSize)
{
int index = 0;
var chunk = new T[chunkSize];
foreach (var item in source)
{
chunk[index] = item;