Skip to content

Instantly share code, notes, and snippets.


Matteo Cominetti teocomi

View GitHub Profile
View OAuth2 C#
//using DotNetOpenAuth and RestSharp
WebServerClient client = new WebServerClient(
new AuthorizationServerDescription
TokenEndpoint = new Uri("https://myurl/oauth"),
ProtocolVersion = ProtocolVersion.V20
}, "client", "secret");
var token = client.GetClientAccessToken();
teocomi / oauth2-restsharp.cs
Last active March 6, 2023 10:33
OAuth2 C# RestSharp
View oauth2-restsharp.cs
string url = "";
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);
teocomi / gist:396c04320dd77db69393
Created February 25, 2016 18:10
Remove git history
View gist:396c04320dd77db69393
rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <github-uri>
git push -u --force origin master
teocomi / revit-addin-locations.txt
Last active March 16, 2023 02:14
Revit Addin folder location
View revit-addin-locations.txt
Autodesk Revit addins are generally loaded from the following locations.
User Addins:
Machine Addins (for all users of the machine):
Addins packaged for the Autodesk Exchange store:
teocomi / RandomString.cs
Last active July 20, 2016 09:27
Random friendly string
View RandomString.cs
/// <summary>
/// Random ID Generator
/// more ideas:
/// </summary>
/// <param name="length">Length of the string</param>
/// <returns></returns>
public static string RandomString(int length)
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
teocomi / .gitignore
Created September 13, 2016 15:01
Gitignore for Unity projects
View .gitignore
# =============== #
# Unity generated #
# =============== #
teocomi / .gitattributes
Created September 13, 2016 15:04
Gitattributes for Unity projects with support for Git Large File Storage (LFS)
View .gitattributes
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
teocomi / Win32Api.cs
Last active January 28, 2021 14:18
Run Revit commands using Win32 API
View Win32Api.cs
/// <summary>
/// Run Revit commands using Win32 API
/// </summary>
public class Win32Api
private static extern IntPtr GetForegroundWindow();
static extern bool SetFocus(IntPtr hWnd);
teocomi / grasshopper_gui-button-mouseover.cs
Last active February 26, 2022 14:53
Grasshopper GUI Button mouseover
View grasshopper_gui-button-mouseover.cs
using Grasshopper.GUI;
using Grasshopper.GUI.Canvas;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Attributes;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
teocomi /
Last active March 9, 2018 16:28
Select Revit Elements by ID from Dynamo
import clr
import Autodesk
from Autodesk.Revit.DB import ElementId
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import List