Skip to content

Instantly share code, notes, and snippets.

@biapar
biapar / ApiLessController.cs
Last active Jan 24, 2021
Piranha CMS: example of a simple controller to GET data in JSON format for headless use.
View ApiLessController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Piranha;
using Piranha.AspNetCore.Services;
using Piranha.Models;
using PiranhaCMS.Models;
using Microsoft.AspNetCore.Authorization;
@biapar
biapar / JsonController.cs
Created Sep 15, 2020 — forked from icavalheiro/JsonController.cs
Umbraco Json controller based on the ContentType renderer. Use this to return the content as a json instead of a view (great for headless mode)
View JsonController.cs
using Newtonsoft.Json;
using System;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
@biapar
biapar / examples.md
Created Sep 9, 2020 — forked from ErisDS/examples.md
Ghost Filter Query examples
View examples.md

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

@biapar
biapar / examples.md
Created Sep 9, 2020 — forked from ErisDS/examples.md
Ghost Filter Query examples
View examples.md

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

@biapar
biapar / gist:9eaf8c2359ea47a77345987f8d489357
Created May 28, 2020
SQL Server Data Types and Their .NET Framework Equivalents
View gist:9eaf8c2359ea47a77345987f8d489357
SQL Server data type CLR data type (SQL Server) CLR data type (.NET Framework)
varbinary SqlBytes, SqlBinary Byte[]
binary SqlBytes, SqlBinary Byte[]
varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[]
image None None
varchar None None
char None None
nvarchar(1), nchar(1) SqlChars, SqlString Char, String, Char[]
nvarchar SqlChars, SqlString String, Char[]
@biapar
biapar / ClassGenerator.sql
Created May 28, 2020 — forked from ernado-x/ClassGenerator.sql
Generate C# class from database table
View ClassGenerator.sql
--from SO: http://stackoverflow.com/questions/5873170/generate-class-from-database-table
declare @TableName sysname = 'TableName'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
View oauth2-restsharp.cs
string url = "https://myurl.com";
string client_id = "client_id";
string client_secret = "client_secret";
//request token
var restclient = new RestClient(url);
RestRequest request = new RestRequest("request/oauth") {Method = Method.POST};
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", client_id);
request.AddParameter("client_secret", client_secret);
@biapar
biapar / RotatePage.xaml.cs
Created Dec 10, 2019 — forked from juucustodio/RotatePage.xaml.cs
Example of setting page navigation animations for your Xamarin.Forms applications - http://julianocustodio.com/animationnavigationpage
View RotatePage.xaml.cs
using FormsControls.Base;
using Xamarin.Forms;
namespace DemoNavigation
{
public partial class RotatePage : ContentPage, IAnimationPage
{
public IPageAnimation PageAnimation { get; } = new RotatePageAnimation
{
Duration = AnimationDuration.Long,
@biapar
biapar / Descrizione
Created Jan 13, 2016
VestaCP firewall custom script
View Descrizione
-cd /usr/local/vesta/data/firewall
-vim custom.sh
-chmod +x $VESTA/data/firewall/custom.sh
Stop/Start your Firewall service from VestaCP
http://www.lowendtalk.com/discussion/44292/solved-server-with-vestacp-and-firewall-enabled-blocks-dns-lookups
http://www.lowendguide.com/3/networking/iptables-and-vestacp-output-rules-to-allow-dns-lookups/
@biapar
biapar / gist:e36b59eeb1a9c19a470ba4ee9baad280
Last active Jan 26, 2019
Read Email Subject of Office365 Email Box in C#
View gist:e36b59eeb1a9c19a470ba4ee9baad280
using Microsoft.Exchange.WebServices.Data;
using System;
using System.Collections.Generic;
namespace ReadEmail365
{
class Program
{
static void Main(string[] args)