Skip to content

Instantly share code, notes, and snippets.

View pictos's full-sized avatar
🐒
Creating tools for you

Pedro Jesus pictos

🐒
Creating tools for you
  • Brasil
View GitHub Profile
@pictos
pictos / CSharp8.cs
Created October 28, 2019 20:08
Exemple of features of C#8 (It's not mine)
interface IProcessor<T,U> where T: unmanaged, IResult
{
T ProcessSingle(int x);
async IAsyncEnumerable<T> ProcessMany(int[] xs, int batch)
{
static T[] ProccessBatch(Func<int,T> func, Span<int> list, in Range range)
{
(_, int length) = range.GetOffsetAndLenght(list.length);
using var batcher = new Batcher<T>(stackalloc T[length]);
@pictos
pictos / MainActivityWorker.cs
Created April 15, 2019 15:53
MainActivity do Woker
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.OS;
using AndroidX.Work;
namespace BackgroundWork.Droid
{
@pictos
pictos / LocalWorker.cs
Last active April 15, 2019 15:31
Using Work in Xamarin.Android
using System;
using Android.Content;
using Android.Util;
using AndroidX.Work;
using Xamarin.Essentials;
namespace BackgroundWork.Droid
{
public class LocalWorker : Worker
{
public static async Task SaveSessionAsync(string json)
{
try
{
File = Path.Combine(FileSystem.AppDataDirectory, "login.json");
using (var file = new FileStream(File, FileMode.Create))
using (var output = new StreamWriter(file, Encoding.UTF8))
await output.WriteAsync(json);
}
catch (System.Exception ex)
using VisualTest.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(Xamarin.Forms.Picker), typeof(MyPicker), new[] { typeof(VisualTest.TestVisual) })]
namespace VisualTest.iOS
{
using Android.Content;
using VisualTest.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Xamarin.Forms.Picker), typeof(MyPicker), new[] { typeof(VisualTest.TestVisual) })]
namespace VisualTest.Droid
{
public class MyPicker : PickerRenderer
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:VisualTest"
x:Class="VisualTest.MainPage"
Visual="Material">
<ContentPage.BindingContext>
<local:MainViewModel/>
</ContentPage.BindingContext>
using Foundation;
namespace Cocos2D {
[BaseType (typeof (NSObject))]
interface Camera {
[Static, Export ("getZEye")]
nfloat ZEye { get; }
[Export ("restore")]
void Restore ();
// JavaScript
var React = require('react-native');
var { NativeModules, Text } = React;
var Message = React.createClass({
getInitialState() {
return { text: 'Goodbye World.' };
},
componentDidMount() {
// Objective-C
#import "RCTBridgeModule.h"
@interface MyCustomModule : NSObject <RCTBridgeModule>
@end
@implementation MyCustomModule