Skip to content

Instantly share code, notes, and snippets.

View puf's full-sized avatar

Frank van Puffelen puf

View GitHub Profile
@puf
puf / gist:1099750
Created July 22, 2011 16:11
Get the Component from a Tridion package
Component component = (Component) engine.GetObject(package.GetValue("Component.ID"));
@puf
puf / Profiler.cs
Last active July 17, 2017 16:29
Tiny C# "manual" profiler (for those days that your proper profiler is proving too difficult to work with)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
public static class Profiler {
private static List<ProfilerFrame> stack = new List<ProfilerFrame>();
private static Dictionary<string, ProfiledBlock> totals = new Dictionary<string, ProfiledBlock>();
private static Action<string> logger;
@puf
puf / Unzip from LINQPad
Last active August 29, 2015 14:01
LINQPad script to unzip all files under a given directory
// This LINQPad script (easily converted into a regular C# program) extracts all zip files under a specific directory.
// makes use of the ZipUtility from http://linqpadsamples.codeplex.com/wikipage?title=Unzip%20a%20file%20using%20COM%20and%20dynamic
var files = Directory.EnumerateFiles(@"C:\Test Data\Gutenberg\pgdvd042010", "*.zip", SearchOption.AllDirectories).ToArray();
var dc = new DumpContainer().Dump();
var index=0;
var count=files.Count();
foreach (var file in files) {
dc.Content = string.Format("{0}/{1}: {2}", index++, count, file);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"TrainingCenterDatabase":{
"Activities":{
"Activity":{
"@Sport":"Biking",
"Id":"2014-06-27T21:09:29Z",
"Lap":{
"@StartTime":"2014-06-27T21:09:29Z",
"TotalTimeSeconds":"1334",
"DistanceMeters":"10702.6",
"MaximumSpeed":"19.416",
@puf
puf / index.html
Last active August 29, 2015 14:05
Chord chart with mail volumes
<html>
<head>
<style>
body {
font: 10px sans-serif;
}
.chord path {
fill-opacity: .67;
stroke: #000;
@puf
puf / gist:c7b0612b6ffbb5f6b1cd
Last active August 29, 2015 14:23
Create a Firebase email/password user in Java
new Firebase("https://yours.firebaseio.com/").createUser("user@domain.com", "password", new Firebase.ValueResultHandler<java.util.Map<String, Object>>() {
public void onSuccess(java.util.Map result) {
System.out.println("Successfully created user account with uid: " + result.get("uid"));
}
public void onError(com.firebase.client.FirebaseError firebaseError) {
System.err.ptinln("Error while creating user " + firebaseError);
}
});
@puf
puf / index.android.js
Created December 14, 2015 17:51
Simple example of a React Native chat app for Android (using Firebase)
'use strict';
var React = require('react-native');
var Firebase = require('firebase');
var {
AppRegistry,
StyleSheet,
Text,
View,
TextInput,
@puf
puf / index.android.js
Created December 14, 2015 17:52
Simple example of a React Native chat app for Android (using Firebase and ReactFire)
'use strict';
var React = require('react-native');
var Firebase = require('firebase');
var ReactFireMixin = require('reactfire');
var {
AppRegistry,
StyleSheet,
Text,
View,
@puf
puf / acknowledge.js
Created January 26, 2016 00:58
Account merging
var ref = new Firebase('https://yours.firebaseio.com/acknowledge');
var users = [];
function $(selector) {
var result = document.querySelectorAll(selector);
return (result.length > 1) ? Array.prototype.slice.call(result) : result[0];
}
function handleAuthResult(error, authData) {
if (error) {