Skip to content

Instantly share code, notes, and snippets.

View asimmon's full-sized avatar

Anthony Simmon asimmon

View GitHub Profile
@asimmon
asimmon / mupdf-xamarin-android-render-pdf.cs
Last active November 20, 2015 15:07
Rendering all pages of a PDF file to PNG with the MuPDF Xamarin Android library
var pdf = new MuPDFCore(this, pdfFilepath);
var cookie = new MuPDFCore.Cookie(pdf);
var count = pdf.CountPages();
for (int i = 0; i < count; i++)
{
var size = pdf.GetPageSize(i);
int pageWidth = (int)size.X;
int pageHeight = (int)size.Y;
@asimmon
asimmon / mupdf-xamarin-android-view-pdf.cs
Last active November 20, 2015 15:07
Using the MuPDF viewer included in the MuPDF Xamarin Android library
var uri = Uri.Parse("/mnt/sdcard/some.pdf");
var intent = new Intent(this, typeof (MuPDFActivity));
intent.SetAction(Intent.ActionView);
intent.SetData(uri);
StartActivity(intent);
@asimmon
asimmon / ionic-login-form.html
Created November 20, 2015 14:20
Centered login form with Ionic Framework HTML
<ion-view id="login" hide-nav-bar="true">
<ion-content padding="true" scroll="false">
<form>
<div class="row responsive-md">
<div class="col col-50 col-offset-25">
<div class="header padding text-center">
<img src="img/logo.png" alt="Your logo here"/>
</div>
@asimmon
asimmon / ionic-login-form.css
Created November 20, 2015 14:21
Centered login form with Ionic Framework CSS
#login {
background: #1c2627 url("../img/login_bg.jpg") no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
.scroll-content {
display: table !important;
width: 100% !important;
@asimmon
asimmon / oracle-sql-to-csv-cursor.sql
Created November 20, 2015 15:09
SQL query results to CSV using cursor
DECLARE
v_items_cursor SYS_REFCURSOR;
v_csv CLOB;
BEGIN
OPEN v_items_cursor FOR
SELECT * FROM items;
v_csv := cursor_to_csv(v_items_cursor);
END;
@asimmon
asimmon / oracle-sql-to-csv-raw-query.sql
Created November 20, 2015 15:10
SQL query results to CSV using raw queries
DECLARE
v_csv CLOB;
BEGIN
SELECT query_to_csv('SELECT * FROM items') INTO v_csv FROM dual;
END;
@asimmon
asimmon / oracle-sql-to-csv-result.txt
Last active November 20, 2015 15:15
SQL query results to CSV result
ITEM_ID;NAME;PRICE
1;mi;328
2;Duis gravida praesent;5
3;ac mattis semper;353
4;volutpat nunc sit;431
5;pede blandit;433
6;eros;452
7;ac orci;243
8;felis ullamcorper viverra;250
9;lorem, luctus ut;494
@asimmon
asimmon / oracle-sql-to-csv-cursor-src.sql
Created November 20, 2015 15:13
SQL query results to CSV source code
FUNCTION cursor_to_csv (
p_cursor IN OUT SYS_REFCURSOR
)
RETURN CLOB
IS
l_cursor_id INTEGER DEFAULT dbms_sql.open_cursor;
l_colval VARCHAR2 (2096);
l_buffer VARCHAR2 (32767) DEFAULT '';
l_status INTEGER;
i_colcount NUMBER DEFAULT 0;
@asimmon
asimmon / cache-result-aop-example-attr.cs
Created November 20, 2015 15:34
Caching method results with AOP (decorate)
[CacheResult(Duration = 1000)]
public string Process(string arg)
{
return Guid.NewGuid().ToString("N");
}
@asimmon
asimmon / cache-result-aop-example-call.cs
Last active October 25, 2016 14:27
Caching method results with AOP, call
Console.WriteLine(worker.Process("foo"));
Console.WriteLine(worker.Process("foo"));
Console.WriteLine(worker.Process("foo"));
Console.WriteLine("Sleeping 2 seconds...");
Thread.Sleep(2000);
Console.WriteLine(worker.Process("foo"));
// result