Skip to content

Instantly share code, notes, and snippets.

View linhdh's full-sized avatar
😵
I may be slow to respond.

Linh Peach linhdh

😵
I may be slow to respond.
View GitHub Profile
@linhdh
linhdh / ButtonRenderer.cs
Created December 19, 2017 06:47
Circular Button Using Xamarin (Custom Renderer)
class CircularButtonRender : Xamarin.Forms.Platform.Android.ButtonRenderer
{
private GradientDrawable _NormalState, _PressedState;
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
{
base.OnElementChanged(e);
if (Control != null)
{
@linhdh
linhdh / AppDelegate.cs
Last active January 3, 2019 12:13
[Xamarin form] Dropdown control
public void ShowSubviewAt(CGRect rect, UIView subView, Action didFinishAnimation)
{
UIView cover = new UIView();
cover.Frame = new CGRect(0, 0, AppWindow.Bounds.Width, AppWindow.Bounds.Height);
//cover.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
//cover.Opaque = true;
cover.BackgroundColor = UIColor.Clear;
cover.AddGestureRecognizer(new UITapGestureRecognizer(() =>
{
@linhdh
linhdh / SendFileToServer.cs
Last active October 1, 2023 13:08
[C#] MultiPartFormDataContent, Upload multi files to server at a time.
private static void SendFileToServer(string fileFullPath)
{
FileInfo fi = new FileInfo(fileFullPath);
string fileName = fi.Name;
byte[] fileContents = File.ReadAllBytes(fi.FullName);
Uri webService = new Uri(@"http://avalidwebservice.com");
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, webService);
requestMessage.Headers.ExpectContinue = false;
MultipartFormDataContent multiPartContent = new MultipartFormDataContent("----MyGreatBoundary");
@linhdh
linhdh / getBitmap.cs
Created December 21, 2017 15:21
[Xamarin, Android] Get Bitmap from filename
string imagefileName = "testimage.jpg";
// Remove the file extention from the image filename
imagefileName = imagefileName.Replace(".jpg","").Replace(".png","");
// Retrieving the local Resource ID from the name
int id = (int)typeof(Resource.Drawable).GetField(imagefileName).GetValue(null);
// Converting Drawable Resource to Bitmap
var myImage = BitmapFactory.DecodeResource(Forms.Context.Resources, id);
@linhdh
linhdh / Button.cs
Created December 22, 2017 08:36
[Xamarin forms] A button with custom renderer for Android.
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace GoiXe.CustomControls.Common
{
public class Button2 : Xamarin.Forms.Button
{
public enum TextAlignment
@linhdh
linhdh / public-stun-list.txt
Created February 20, 2018 08:56 — forked from mondain/public-stun-list.txt
Public STUN server list
23.21.150.121:3478
iphone-stun.strato-iphone.de:3478
numb.viagenie.ca:3478
s1.taraba.net:3478
s2.taraba.net:3478
stun.12connect.com:3478
stun.12voip.com:3478
stun.1und1.de:3478
stun.2talk.co.nz:3478
stun.2talk.com:3478
@linhdh
linhdh / gist:0f9f2af1685e1f263f1969e6eaf3aec8
Created March 1, 2018 07:22
Setting up a Git server on Windows using Git for Windows and Win32_OpenSSH
You need to download and install:
Win32_OpenSSH
Git for Windows, selecting the "Run Git and included Unix tools from the Windows Command Prompt" when prompted. This option will install a bin folder in Program Files\git that will be placed into your path thus taking possibly taking precedence over other tools.
On Server
Set system environment variable for sshd to pick up the git commands
$gitPath = Join-Path -Path $env:ProgramFiles -ChildPath "git\mingw64\bin"
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'MACHINE')
// See: https://devforums.apple.com/message/1000934#1000934
import Foundation
// Logic
operator prefix ¬ {}
@prefix func ¬ (value: Bool) -> Bool {
return !value
}
@linhdh
linhdh / trial.key
Created September 12, 2018 07:18 — forked from huqi/trial.key
Beyond Compare 4 license for Mac
Beyond Compare 4
Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Windows
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
@linhdh
linhdh / mapnik-v2.2.0-win-32.md
Created July 11, 2019 08:04
Setup Mapnik 2.2.0 release candidate for windows 32 bit