Skip to content

Instantly share code, notes, and snippets.

View Neferetheka's full-sized avatar

Galaad Linosfil Neferetheka

View GitHub Profile
/*
* From Google IO 2014 app
* Copyright 2014 Google Inc. All rights reserved.
*
* 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
@Neferetheka
Neferetheka / Reflection.php
Created July 23, 2014 13:23
PHP method to create an array from an object using Reflection
/**
* Awesome method to create an array from an object using Reflection. Useful for JSON serialization
* @return array : array of object properties.
*/
public function asArray()
{
$reflectionClass = new ReflectionClass(get_class($this));
$array = array();
foreach ($reflectionClass->getProperties() as $property) {
$property->setAccessible(true);
@Neferetheka
Neferetheka / Android annotations Gradle build file
Created September 5, 2013 13:22
Correct Gradle build file to use Android annotations library
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5+'
}
}
apply plugin: 'android'
@Neferetheka
Neferetheka / TaskHelper.cs
Created August 16, 2013 21:54
Utility class to simplify tasks usage on Windows Phone 7/8
using Microsoft.Phone.Tasks;
using System;
namespace Tools
{
public abstract class TaskHelper
{
/// <summary>
/// Launch a share task
/// </summary>
@Neferetheka
Neferetheka / ISHelper.cs
Created August 16, 2013 20:00
Helper to manage Isolated Storage on Windows phone
using System;
using System.IO;
using System.IO.IsolatedStorage;
namespace Tools
{
public abstract class ISHelper
{
private const string directory = "Storage";
@Neferetheka
Neferetheka / TaskHelper
Created August 8, 2013 18:15
TaskHelper for Windows Phone
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
@Neferetheka
Neferetheka / Read File on Windows Phone
Last active December 20, 2015 18:09
Read a file in assets on Windows Phone
private string GetResourceContent(string path)
{
var resource = App.GetResourceStream(new Uri(path, UriKind.Relative));
StreamReader reader = new StreamReader(resource.Stream, Encoding.UTF8);
return reader.ReadToEnd();
}
<main>
<input placeholder="Search, or say Google" x-webkit-speech autocomplete="off" />
<header></header>
<section class="card">
<h1><strong>32 minutes</strong> to Consol Energy Center</h1>
<h2>McKnight Road</h2>
<div class="map"></div>
@Neferetheka
Neferetheka / Mobile UA detection
Created July 16, 2013 10:18
Allows to detect common mobile platforms
isAndroid = function(){
return navigator.userAgent.toLowerCase().indexOf("android") > -1;
}
isIOS = function(){
return navigator.userAgent.match( /(iPod|iPhone|iPad)/ );
}
isWP = function(){
return navigator.userAgent.indexOf("Windows Phone OS") > -1;
}
isBB = function(){
@Neferetheka
Neferetheka / gist:3426203
Created August 22, 2012 14:37
Regex to search through html text
//Adapted from http://stackoverflow.com/questions/3460004/regexp-to-search-replace-only-text-not-in-html-attribute
var reg = new RegExp("(?![^<>]*>) *("+search+") *([^ \d])", "g");
var resultsWithoutHTML = text.replace(reg, "toReplace");