Skip to content

Instantly share code, notes, and snippets.

View biapar's full-sized avatar
🙂

Biagio Paruolo biapar

🙂
View GitHub Profile
@biapar
biapar / ClassGenerator.sql
Created May 28, 2020 08:12
Generate C# class from database table
--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
@biapar
biapar / oauth2-restsharp.cs
Created January 26, 2020 21:36 — forked from teocomi/oauth2-restsharp.cs
OAuth2 C# RestSharp
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 December 10, 2019 15:25 — forked from juucustodio/RotatePage.xaml.cs
Example of setting page navigation animations for your Xamarin.Forms applications - http://julianocustodio.com/animationnavigationpage
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 / gist:e36b59eeb1a9c19a470ba4ee9baad280
Last active January 26, 2019 15:47
Read Email Subject of Office365 Email Box in C#
using Microsoft.Exchange.WebServices.Data;
using System;
using System.Collections.Generic;
namespace ReadEmail365
{
class Program
{
static void Main(string[] args)
@biapar
biapar / gist:03f3c4b65c823cb47e8877ce9240b66a
Created November 23, 2018 16:54 — forked from warrenbuckley/gist:5685180
Login ActionResult in AuthSurfaceController
/// <summary>
/// Handles the login form when user posts the form/attempts to login
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult HandleLogin(LoginViewModel model)
{
if (!ModelState.IsValid)
{
@biapar
biapar / style.css
Created September 6, 2018 19:18
CSS used to customize the Simple Social Icons to match brand color.
/* Simple Social Icons
--------------------------------------------- */
.simple-social-icons li.social-dribbble a {
border: 2px solid #ea4c89 !important;
color: #ea4c89 !important;
}
.simple-social-icons li.social-dribbble a:hover {
background-color: #ea4c89 !important;
@biapar
biapar / gist:3eaa7870b1474f17da0ff27927625de5
Created June 20, 2018 10:10
Example Menu Item in Umbraco
using Umbraco.Core;
using Umbraco.Web;
using Umbraco.Web.Trees;
//https://github.com/marcemarc/uSpinMeRightRound/blob/master/Solution/tooorangey.uSpinMeRightRound/App_Start/RegisterEvents.cs
namespace tooorangey.uSpinMeRightRound.App_Start
{
public class RegisterEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
@biapar
biapar / UmbracoTags.cshtml
Created May 9, 2018 12:25 — forked from amogram/UmbracoTags.cshtml
Using Umbraco Tags in a view
@if (@Model.Content.GetPropertyValue("tags") != null)
{
var tags = Model.Content.GetPropertyValue("tags").TryConvertTo<string>();
string[] tagArray = { };
if (tags.Success)
{
tagArray = tags.Result.Split(',');
}
if (tagArray.Any())
@biapar
biapar / deleting_tons_of_files_in_linux.md
Created March 1, 2018 10:57 — forked from bitkidd/deleting_tons_of_files_in_linux.md
Deleting tons of files in Linux (Argument list too long)

If you’re trying to delete a very large number of files at one time (I deleted a directory with 485,000+ today), you will probably run into this error:

/bin/rm: Argument list too long.

The problem is that when you type something like “rm -rf ”, the “” is replaced with a list of every matching file, like “rm -rf file1 file2 file3 file4” and so on. There is a reletively small buffer of memory allocated to storing this list of arguments and if it is filled up, the shell will not execute the program. To get around this problem, a lot of people will use the find command to find every file and pass them one-by-one to the “rm” command like this:

find . -type f -exec rm -v {} \;

My problem is that I needed to delete 500,000 files and it was taking way too long.

@biapar
biapar / README.md
Created December 18, 2017 07:46 — forked from magnetikonline/README.md
Reset Windows 2012R2 local administrator password.

Reset Windows 2012R2 local administrator password

  • Boot from Microsoft Windows Server 2012R2 DVD/ISO.
  • From the Windows Setup menu, click "Next".
  • Select "Repair your computer".
  • Click on "Troubleshoot".
  • Under Advanced options, click "Command Prompt".

At the command prompt, run the following commands: