Skip to content

Instantly share code, notes, and snippets.

View hanssens's full-sized avatar

Juliën Hanssens hanssens

View GitHub Profile
@hanssens
hanssens / ExtractAllExtensions.csx
Last active November 18, 2015 22:59
ScriptCS script that extracts all unique file extensions from a directory
using System.IO;
// extracts all file extensions from a specified directory
// and spits them out in the console
var path = Directory.GetCurrentDirectory();
var root_path = new DirectoryInfo(path);
// this fetches all file info, extracts the extension,
// filters the unique ones and sorts them, before outputting it
@hanssens
hanssens / kendo.html
Last active August 29, 2015 14:23
Empty, clean Kendo UI snippet
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.dataviz.min.css">
@hanssens
hanssens / app.data.js
Created March 26, 2015 14:14
app.data.js | extensions for kendo datasources and data operations
/**
* Provides data interoptability, such as datasources and raw enum values.
*
* USAGE
* 1. Include the file as <script src="app.data.js"></script>
* 2. Call it globally using, like for example:
*
* var pong = api.data.ping();
*
* REMARKS
@hanssens
hanssens / QuotesController.cs
Created January 13, 2015 15:13
Dynamic parameter in WebAPI controller.
public class QuotesController : ApiController
{
/// <summary>
/// Expects filter.quote to have a string value...
/// </summary>
public string Get([FromUri]dynamic filter)
{
var raw_json = JsonConvert.DeserializeObject(filter);
return raw_json.quote.ToString();
@hanssens
hanssens / Executor.rb
Created January 8, 2015 08:22
Simple wrapper for http request and parsing JSON
##
# Simple JSON wrapper
require 'json'
require 'net/http'
class Executor
def initialize
@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
@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 / 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 / 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 / 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