Skip to content

Instantly share code, notes, and snippets.

View MelnikovIG's full-sized avatar
💭
🚀

Igor Melnikov MelnikovIG

💭
🚀
View GitHub Profile
@MelnikovIG
MelnikovIG / Program.cs
Created July 10, 2018 20:34
Create instance without executing ctors
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
public static class ClientTypesGenerator
+ {
+ private static Dictionary<string,string> foundTypes = new Dictionary<string, string>();
+
+ public static void Generate()
+ {
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+
+ var controllerMethods = assemblies
+ .SelectMany(x => x.GetTypes())
@MelnikovIG
MelnikovIG / recover-deleted-branch.sh
Created May 18, 2018 12:22 — forked from umayr/recover-deleted-branch.sh
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@MelnikovIG
MelnikovIG / SwaggerTypescriptModelGeneration.txt
Last active May 15, 2018 11:15
Swagger TypeScript models generation
1) https://github.com/swagger-api/swagger-codegen
generate models only DsupportingFiles need to import models.ts, it is improts all models, nice work with common types, use modle naming from json file
```
set output=C:\Temp\SwaggerTests\swaggerCli
set swaggerCli=C:\Temp\SwaggerTests\swaggerCli\swagger-codegen-cli-2.2.1.jar
set swaggerJson=http://localhost:5001/swagger/v1/swagger.json
java -jar -Dmodels -DsupportingFiles=models.ts %swaggerCli% generate -l typescript-angular2 -i %swaggerJson% -o %output%
@RD /S /Q %output%\api
@MelnikovIG
MelnikovIG / CLRProfiling
Created May 4, 2018 15:35
CLRProfiling
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace CLRProfiling
{
class Program
{
static void Main(string[] args)
{
@MelnikovIG
MelnikovIG / Barbeque.cs
Created May 4, 2018 10:44 — forked from ForNeVeR/Barbeque.cs
Bool not equal to true neither to false.
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
[StructLayout(LayoutKind.Explicit)]
internal struct Barbeque
{
[FieldOffset(0)] public int Barbe;
[FieldOffset(0)] public bool Que;
@MelnikovIG
MelnikovIG / ReplaceMethodsInType.cs
Last active May 7, 2018 07:19
Replace Methods in type (work only on full framework)
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
namespace ConsoleApp2
{
public static class MethodReplacer
{
public static unsafe void Replace(MethodInfo methodToReplace, MethodInfo methodToInject)
@MelnikovIG
MelnikovIG / gist:548b750b6cb2edff607eee36263ae8f6
Created April 23, 2018 09:00
Popular social networks error responses
1) Instagram
Request
GET https://api.instagram.com/v1/tags/nofilter/media/recent?access_token=ACCESS_TOKEN HTTP/1.1
User-Agent: Fiddler
Host: api.instagram.com
Response
@MelnikovIG
MelnikovIG / Download specific folder only from repository
Last active April 11, 2018 13:08
Download specific folder only from repository
Use http://www.gitzip.com/
@MelnikovIG
MelnikovIG / CreateStaticClass.cs
Created January 12, 2018 13:39 — forked from ForNeVeR/CreateStaticClass.cs
Static class creation test.
using System;
using System.Reflection;
class Program
{
static void Main(string[] args)
{
var allocate = typeof(RuntimeTypeHandle).GetMethod("Allocate", BindingFlags.NonPublic | BindingFlags.Static);
var math = allocate.Invoke(null, new[] { typeof (Math) });