Skip to content

Instantly share code, notes, and snippets.

View hanssens's full-sized avatar

Juliën Hanssens hanssens

View GitHub Profile
@hanssens
hanssens / C# Template
Last active August 29, 2015 13:56 — forked from adambyram/C# Template
C# build template for CodeRunner on OSX
using System;
using System.Collections.Generic;
using System.Linq;
namespace CodeRunnerCSharp
{
class Program
{
public static void Main (string[] args)
{
@hanssens
hanssens / prettify.hanssens.css
Created June 9, 2014 18:56
Hanssens.com' custom Prettify Code Syntax
/* Based on Twitter Bootstrap style http://twitter.github.com/bootstrap/ */
.prettyprint .com { color: #93a1a1; }
.prettyprint .lit { color: #195f91; }
.prettyprint .pun, .prettyprint .opn, .prettyprint .clo { color: #93a1a1; }
.prettyprint .fun { color: #dc322f; }
.prettyprint .str, .prettyprint .atv { color: #D14; }
.prettyprint .kwd, .prettyprint .linenums .tag { color: #1e347b; }
.prettyprint .typ, .prettyprint .atn, .prettyprint .dec, .prettyprint .var { color: teal; }
.prettyprint .pln { color: #48484c; }
@hanssens
hanssens / PrototypeBootstrap.js
Created June 25, 2014 07:44
Simple Javascript Prototype sample, used for quick copy/paste...
// Simple Javascript Prototype sample, used for bootstrapping classes ;)
var App = function() {
// define a custom function 'Ping()'
App.prototype.Ping = function () {
console.log("Pong!");
};
};
@hanssens
hanssens / globals.js
Created August 19, 2014 12:36
Globals.js - Provides generic global functions, helpers and extensions.
/*
* Globals.js - Provides generic global functions, helpers and extensions.
*/
/*
* Function: isNullOrEmpty()
* @value: determines if the object is null, empty or undefined.
*/
function isNullOrEmpty(value) {
return (value == null || value == "" || value == "undefined");
@hanssens
hanssens / ListAllPropertyNamesAndValues.cs
Last active August 29, 2015 14:08
List all property names and values with reflection
/// <summary>
/// Iterates through each and every property for the specified object and lists its value, including nulls.
/// </summary>
static void ListAllPropertyNamesAndValues(object obj)
{
var t = obj.GetType();
var properties = t.GetProperties();
foreach (var prop in properties)
{
@hanssens
hanssens / JsonpFilterAttribute.cs
Last active August 29, 2015 14:08
JSONP FilterAttribute for ASP.NET MVC
public class JsonpFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(
ActionExecutedContext filterContext)
{
if (filterContext == null)
throw new ArgumentNullException("filterContext");
//
// see if this request included a "callback" querystring
@hanssens
hanssens / extract_urls_from_file.rb
Created October 31, 2014 11:51
Reads a file and extracts all url's from it.
require 'open-uri'
require 'uri'
# start off by reading the file
text = ""
File.open("whatever.txt", "r") do |f|
f.each_line do |line|
text << line
end
end
@hanssens
hanssens / index.lock.file.exists.md
Created November 18, 2014 13:02
Git - Frequently Used Restore Commands

Error

fatal: Unable to create '/path/my_proj/.git/index.lock': File exists.

If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.

Fix it using:

rm -f ./.git/index.lock

@hanssens
hanssens / gist:a72ec94112817e27493d
Created November 26, 2014 21:21
Open new, second instance of Xamarin Studio
open -n "/Applications/Xamarin Studio.app"
@hanssens
hanssens / webhttpclient.exe
Created December 17, 2014 19:52
WebHttpClient - Command Line tool for quickly creating a httprequest
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace WebHttpClient