Skip to content

Instantly share code, notes, and snippets.

View rodrigoratan's full-sized avatar
🏠
Working from home

Rodrigo Ratan rodrigoratan

🏠
Working from home
View GitHub Profile
@garyjohnson
garyjohnson / ExtensionMethods.cs
Created April 22, 2012 14:22
WinRT Reflection Extension Methods
using System;
using System.Reflection;
namespace SharpSerializer
{
public static class ExtensionMethods
{
public static PropertyInfo GetProperty(this Type type, String propertyName)
{
return type.GetTypeInfo().GetDeclaredProperty(propertyName);
@dsplaisted
dsplaisted / AsyncPortableTask.cs
Created July 8, 2012 05:36
Portable task wrappers
// An implementation of IPortableTask which wraps an actual Task.
// This has to go in a project targeting a platform or platforms which support Task and async/await
using System;
using System.Threading.Tasks;
namespace PortableTasks
{
public class AsyncPortableTask : IPortableTask
{
@ainsofs
ainsofs / PagedResult<T>
Last active March 15, 2019 03:37
Web Api Config - Can be used for DnnApiController
// For returning objects
public class PagedResult<T> {
public List<T> Items { get; set; }
public long CurrentPage { get; set; }
public long ItemsPerPage { get; set; }
public long TotalItems { get; set; }
public long TotalPages { get; set; }
public string Text { get; set; }
public int ItemsDisplayed { get; set; }
@Kadrian
Kadrian / get-dht11-data.py
Last active August 4, 2019 17:53
Get Temperature and Humidity from DHT11 module with Raspberry Pi and RPi.GPIO
import RPi.GPIO as GPIO
import time
import traceback
# Helper
def bin2dec(string_num):
return str(int(string_num, 2))
def setup_gpio(port):
GPIO.setmode(GPIO.BCM)
@idreamsi
idreamsi / pythonscript.py
Last active September 9, 2021 20:58
Python script for Telegram
# -*- coding: utf-8 -*-
#!/usr/bin/python
import subprocess
import os
import picamera
import time
import shlex
from datetime import datetime
from datetime import timedelta
import datetime as dt
@bdukes
bdukes / NoDefaultCss.ascx
Created April 11, 2016 21:11
Replace or Remove DNN's Default CSS
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
<dnn:DnnCssExclude runat="server" Name="dnndefault" />
@NickCraver
NickCraver / ExampleUsage.cs
Last active November 27, 2021 04:24
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{
@ech01
ech01 / DnnScheduleExample.cs
Last active September 13, 2021 18:41
DNN Scheduler Example
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using DotNetNuke.Services.Mail;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
@alfeugds
alfeugds / CurrencyConverter.cs
Last active July 13, 2023 06:01
Xamarin Forms Currency Mask for Entry fields
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using Xamarin.Forms;
namespace MyProject.Util
{
/// <summary>
/// Converter for using in Entry fields for masked input of currency.
/// <para>The binded property must be of type decimal, and must invoke the PropertyChangedEventArgs event whenever the value is changed, so that the desired mask behavior is kept.</para>
@JoanM
JoanM / BynderCurl.cs
Created December 9, 2016 14:55
Async Curl to Bynder
public async Task<string> DoCurlAsync()
{
using (var httpClient = new HttpClient())
using (var httpResonse = await httpClient.GetAsync("https://www.bynder.com"))
{
return await httpResonse.Content.ReadAsStringAsync();
}
}