Skip to content

Instantly share code, notes, and snippets.

View Cheesebaron's full-sized avatar
🧀
Send cheese please

Tomasz Cielecki Cheesebaron

🧀
Send cheese please
View GitHub Profile
<cheesebaron.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your main content inside here -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="App1.App1" android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<application android:label="App1" android:icon="@drawable/Icon"></application>
<uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>
var registrationId = string.Empty;
var allRegistrations = await hubClient.GetAllRegistrationsAsync(10);
foreach (var registration in allRegistrations)
{
switch (deviceType)
{
case NotificationSubscriptionV1.DeviceTypes.Android:
{
var reg = registration as GcmRegistrationDescription;
[Activity(Label = "DialogActivity", Theme = "@style/PopupTheme")]
public class DialogActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
ShowAsPopup(this, Resource.Layout.Main);
}
@Cheesebaron
Cheesebaron / urlstuff.cs
Created August 12, 2014 12:30
Just a simple LINQ query to split an URL's query into a key/value dictionary. Useful in PCL's where there is not HttpUtility class.
static Dictionary<string, string> QueryToKeyValueDictionary(string url)
{
return
url.Substring(url.IndexOf('?') + 1)
.Split('&')
.Select(pair => pair.Split('='))
.ToDictionary(val => val[0], val => Uri.UnescapeDataString(val[1]));
}
@Cheesebaron
Cheesebaron / MockLocationSource.cs
Created September 25, 2014 15:36
Random MockLocationSource
using System;
using System.Threading;
using System.Threading.Tasks;
using Android.Gms.Maps;
using Android.Gms.Maps.Model;
using Android.Locations;
using Android.OS;
namespace RunForYourLife
{
public static void TryRequestWhenInUseAuthorization(this CLLocationManager locationManager)
{
if (locationManager.RespondsToSelector(new Selector("requestWhenInUseAuthorization")))
locationManager.RequestWhenInUseAuthorization();
}
public static void TryRequestAlwaysAuthorization(this CLLocationManager locationManager)
{
if (locationManager.RespondsToSelector(new Selector("requestAlwaysAuthorization")))
locationManager.RequestAlwaysAuthorization();
@Cheesebaron
Cheesebaron / Activity.cs
Last active August 29, 2015 14:08
MapFragment inside a ScrollView
public class MyActivity : Activity
{
private GoogleMap _map;
private HorizontalScrollView _hsv;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.rtc);
@Cheesebaron
Cheesebaron / HangMan.java
Last active August 29, 2015 14:10
Shitty hangman
import java.util.*;
public class HangMan {
private static String[] words = {
"motherboard", "case", "powersupply", "harddrive", "mouse", "keyboard", "peripheral",
"graphicscard", "processor", "latency", "ping", "gaming", "resolution", "watercooling",
"cache", "memory", "chipset", "intel", "notebook", "desktop", "aliasing" };
public static void main(String[] args) {
Random rand = new Random();
@Cheesebaron
Cheesebaron / CodeShareReport.linq
Last active August 29, 2015 14:11 — forked from praeclarum/CodeShareReport.cs
LinqPad script counting lines. Yay \o/
// based on https://gist.github.com/praeclarum/1608597
void Main()
{
var projects = new List<Solution> {
new Solution {
Name = "Windows 8",
ProjectFiles = new List<string> {
"C:\\vcs\\git\\MastersThesis\\NoiseSentinelApp\\NoiseSentinelApp.Store\\NoiseSentinelApp.Store.Windows\\NoiseSentinelApp.Store.Windows.csproj",
"C:\\vcs\\git\\MastersThesis\\NoiseSentinelApp\\NoiseSentinelApp.Store\\NoiseSentinelApp.Store.Shared\\NoiseSentinelApp.Store.Shared.projitems",