Skip to content

Instantly share code, notes, and snippets.

View teocomi's full-sized avatar

Matteo Cominetti teocomi

View GitHub Profile
//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
teocomi / oauth2-restsharp.cs
Last active March 6, 2023 10:33
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);
@teocomi
teocomi / gist:396c04320dd77db69393
Created February 25, 2016 18:10
Remove git history
//source http://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository
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
teocomi / revit-addin-locations.txt
Last active May 6, 2024 16:34
Revit Addin folder location
Autodesk Revit addins are generally loaded from the following locations.
User Addins:
%appdata%\Autodesk\Revit\Addins\
%appdata%\Autodesk\ApplicationPlugins\
Machine Addins (for all users of the machine):
C:\ProgramData\Autodesk\Revit\Addins\
Addins packaged for the Autodesk Exchange store:
@teocomi
teocomi / RandomString.cs
Last active July 20, 2016 09:27
Random friendly string
/// <summary>
/// Random ID Generator
/// more ideas: http://www.anotherchris.net/csharp/friendly-unique-id-generation-part-2/
/// </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
teocomi / .gitignore
Created September 13, 2016 15:01
Gitignore for Unity projects
# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
/[Bb]uilds/
/[Ll]ibrary/
sysinfo.txt
*.stackdump
@teocomi
teocomi / .gitattributes
Created September 13, 2016 15:04
Gitattributes for Unity projects with support for Git Large File Storage (LFS)
## 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
teocomi / Win32Api.cs
Last active April 24, 2023 07:09
Run Revit commands using Win32 API
/// <summary>
/// Run Revit commands using Win32 API
/// </summary>
public class Win32Api
{
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern bool SetFocus(IntPtr hWnd);
@teocomi
teocomi / grasshopper_gui-button-mouseover.cs
Last active February 26, 2022 14:53
Grasshopper GUI Button mouseover
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
teocomi / dynamo_select-revit-elements-by-id.py
Last active May 2, 2024 06:54
Select Revit Elements by ID from Dynamo
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import ElementId
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("System")
from System.Collections.Generic import List