Skip to content

Instantly share code, notes, and snippets.

View pedrovasconcellos's full-sized avatar

Pedro Vasconcellos pedrovasconcellos

View GitHub Profile
@pedrovasconcellos
pedrovasconcellos / ResponseModel.cs
Last active January 23, 2020 04:46
Response Model
using System;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Response Model
/// </summary>
public class ResponseModel<T>
{
/// <summary>
@pedrovasconcellos
pedrovasconcellos / RestSharpWithPollyExample.cs
Last active May 16, 2025 12:30
Example using restsharp with polly
using Polly;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
namespace RestSharpWithPolly
@pedrovasconcellos
pedrovasconcellos / MongoDBService.cs
Last active March 28, 2023 04:22
MongoDB Service with method Insert
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver;
namespace VS.Services
{
public class MongoDBService
{
@pedrovasconcellos
pedrovasconcellos / ObjectExtension.cs
Created December 31, 2020 02:59
ObjectExtension with CopyObject and CopyPropertiesTo
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.Linq;
namespace Vasconcellos.Extensions
{
public static class ObjectExtension
{
/// <summary>
@pedrovasconcellos
pedrovasconcellos / getInstagramsIFollow.js
Last active February 9, 2021 16:16
Get Instagrams I Follow
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
function getInstagramsIFollow(amount) {
let instagrams = '';
@pedrovasconcellos
pedrovasconcellos / FollowInstagramUsers.js
Last active February 9, 2021 20:04
Follow Instagram Users
function timer(ms) { return new Promise(res => setTimeout(res, ms)); }
async function FollowInstagramUsers(amount) {
for (var i = 0; i <= amount; i++) {
document.getElementsByClassName("sqdOP L3NKy y3zKF ")[i].click();
console.log(i);
await timer(5000);
}
}
function wait(ms) {
private static T DeepCopy<T>(T other)
{
using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Context = new StreamingContext(StreamingContextStates.Clone);
formatter.Serialize(ms, other);
ms.Position = 0;
return (T)formatter.Deserialize(ms);
@pedrovasconcellos
pedrovasconcellos / base64.js
Created July 19, 2021 18:08
Javascript Base64 UTF8 encoding and decoding
function b64EncodeUnicode(str) {
// first we use encodeURIComponent to get percent-encoded UTF-8,
// then we convert the percent encodings into raw bytes which
// can be fed into btoa.
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
@pedrovasconcellos
pedrovasconcellos / EnumExtension.cs
Last active April 12, 2023 19:04
EnumExtension with GetDescription
using System;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
public static class EnumExtension
{
public static string GetDescription<TEnum>(this TEnum value) where TEnum : Enum
{
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
namespace Vasconcellos.Log