Skip to content

Instantly share code, notes, and snippets.

// During init
final MainActivityHelper ui = new MainActivityHelper(this);
// ----------------------------------------
// Old usage
Button save_button = (Button) findViewById(R.id.save);
save_button.setOnClickListener(onSave);
// ----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:x="http://filipfracz.net/schemas/android_extensions/1.0"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
x:package="net.filipfracz.samples"
x:className="MainActivityLayoutHelper">
<Window x:Class="MySample.MyCoolWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Button x:Name="ClearButton">Clear</Button>
</Grid>
</Window>
@itsff
itsff / ui.java
Last active December 24, 2015 19:29
Android code generation
EditText name = (EditText)findViewById(R.id.name);
EditText address = (EditText)findViewById(R.id.address);
RadioGroup types = (RadioGroup)findViewById(R.id.types);
Button clear = (Button)findViewById(R.id.clear_button);
@itsff
itsff / cpp_safe_buffer.cpp
Last active December 24, 2015 15:09
C++/CLI implementation of SafeBuffer class that wraps std::unique_ptr<const char*>. This allows for creation of UnmanagedMemoryStream and saves copying of data between the native and managed sides. I still need to figure out how to handle custom deleters.
ref class CppSafeBuffer : public ::System::Runtime::InteropServices::SafeBuffer
{
private:
// TODO: Figure out how to handle a custom deleter
//std::unique_ptr<const char*>::deleter_type _deleter;
public:
CppSafeBuffer(std::unique_ptr<const char*> && bytes,
const std::size_t size)
: ::System::Runtime::InteropServices::SafeBuffer(true)
struct my_element
{
int my_element_data;
/* Placement of container-specific node data can be easily modified for locality
optimization */
struct container__slist_node slist_node;
/* A single element can be linked into multiple containers */
struct container__hash_node hash_node;
@itsff
itsff / hello_bootstrap.html
Created August 1, 2013 19:15
Just messing around
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
@itsff
itsff / magic.cs
Last active December 15, 2015 20:59
Drop your pants!
static void doMagic()
{
var form = new System.Windows.Forms.Form();
form.Text = "Drop your pants!";
form.Width = 800;
form.Height = 500;
var browser = new System.Windows.Forms.WebBrowser();
browser.Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
browser.Size = form.Size;
browser.Navigate("http://www.youtube.com/embed/uIN48CE6L_I?autoplay=1");
@itsff
itsff / TaskHelpers.cs
Created January 31, 2013 07:30
Extensions for Task Parallel Library from ASP.NET MVC project.
/*
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
Microsoft Open Technologies would like to thank its contributors, a list
of whom are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors.
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@itsff
itsff / message types.xml
Created July 10, 2012 17:45
Sample message types
<messages>
<message name="AccountListRequest" msgcat="app" msgtype="123456">
<field name="AccountListRequestID" required="Y" />
</message>
<message name="AccountListResponse" msgcat="app" msgtype="123457">
<field name="AccountListRequestID" required="Y" />
<component name="AccountData" repeats="Y" />
</message>