Skip to content

Instantly share code, notes, and snippets.

View svrooij's full-sized avatar

Stephan van Rooij svrooij

View GitHub Profile
@svrooij
svrooij / options.js
Last active December 25, 2015 12:09
Ninja Blocks Presence Widget
return {
"name": "Ping Presence",
"deviceMap": [
{deviceId:264},
{deviceId:261}
]
}
@svrooij
svrooij / security_failure.cs
Last active January 2, 2016 07:19
Security failure for mobile apps!This is a sample found on the internet, and this is way their are a lot of mobile apps that are broken. You can easily make it talk to an other server....
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
Console.WriteLine("Certificaat: {0}",certificate.Subject);
Console.WriteLine("SslPolicy: {0}",sslPolicyErrors);
return true; //This row is the problem. If you don't know why, I wouldn't use apps from your company!
};
@svrooij
svrooij / TintImageStringElement.cs
Last active August 29, 2015 14:02
Use tinted images in MonoTouchDialog ImageStringElement
using System;
using MonoTouch.UIKit;
namespace MonoTouch.Dialog
{
public class TintImageStringElement : ImageStringElement
{
public UIColor TintColor { get; set; }
public TintImageStringElement (string caption, UIImage image):base(caption,image.ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate))
{
TintColor = UIColor.FromRGB (102, 51, 102);
@svrooij
svrooij / resolve.cs
Last active August 29, 2015 14:18
Resolve exchange alias to SMTP-address
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://serv/EWS/exchange.asmx");
service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain");
//Never use this part in production!!
//ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
// {
// return true;
// };
@svrooij
svrooij / index.html
Created April 26, 2015 09:36
Improve your mobile webapp
<html>
<head>
<title>Your nice webapp</title>
<!-- add from here -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="iOS 8 web app">
<meta name="viewport" content="initial-scale=1">
</head>
@svrooij
svrooij / functions.php
Created May 1, 2015 18:31
Wordpress email with Gmail
// add the following to your themes functions.php file
// Off course, you should never change the parent theme and put all the changes in a child theme
add_action( 'phpmailer_init', 'gmail_phpmailer_init' );
function gmail_phpmailer_init( PHPMailer $phpmailer ) {
$phpmailer->Host = 'smtp.gmail.com';
$phpmailer->Port = 587;
$phpmailer->Username = 'pietje_puk@gmail.com'; // Full username (with @gmail.com)
$phpmailer->Password = 'your_secret_password'; // Your own password
$phpmailer->SMTPAuth = true; // Gmail requires authentication
@svrooij
svrooij / Ninjablock_to_local_mqtt.sh
Last active January 14, 2021 02:44
Ninjablock to local MQTT server
# This describes how you can connect your ninjablock to your own mqtt server
# It is not the best manual, so please provide feedback
# First of you have to start with the "beta" image found at: https://discuss.ninjablocks.com/t/unstable-brand-new-image-for-your-block/1666
# Or direct link if you must: http://ninjablocks-nightly.s3.amazonaws.com/block/ubuntu_armhf_trusty_sterling_block-unstable_2014-07-16_1044.img.gz
# Then put that on an sdcard (like you normally would)
# Put it in the ninjablock
# Let it boot!!
# power off (upon first boot it creates a ssh key (needed for enabling ssh))
# power on
@svrooij
svrooij / gist:837c7d139c3813c10200
Created January 18, 2016 19:47
Verifying that +svrooij is my blockchain ID. https://onename.com/svrooij
Verifying that +svrooij is my blockchain ID. https://onename.com/svrooij
@svrooij
svrooij / Blog.cs
Created June 15, 2016 13:05
EntityFramework default properties
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
namespace YourNamespace
{
[Table("Blogs")]
// We inherit the EntityBase class here (with Id, CreatedAt and UpdatedAt)
@svrooij
svrooij / StringExtensions.cs
Created June 27, 2016 10:32
Youtube link to Embed code in C#
using System.Text.RegularExpressions;
namespace YourNamespace
{
internal static class StringExtensions
{
//http://stackoverflow.com/questions/3652046/c-sharp-regex-to-get-video-id-from-youtube-and-vimeo-by-url
static readonly Regex YoutubeVideoRegex = new Regex(@"youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase);
static readonly Regex VimeoVideoRegex = new Regex(@"vimeo\.com/(?:.*#|.*/videos/)?([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
// Use as