Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View silppuri's full-sized avatar

Petri Avikainen silppuri

View GitHub Profile
<?xml version="1.0"?>
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_8e8dc5f69a98cc4c1ff3427e5ce34606fd672f91e6" Version="2.0" IssueInstant="2014-07-17T01:01:48Z" Destination="http://sp.example.com/demo1/index.php?acs" InResponseTo="ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685">
<saml:Issuer>http://idp.example.com/metadata.php</saml:Issuer>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:EncryptedAssertion>
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Type="http://www.w3.org/2001/04/xmlenc#Element">
React = require("react")
classnames = require("classnames")
ReadOnly = (CompositeComponent) -> class extends React.Component
render: ->
<CompositeComponent
{...@props}
className={classnames("read-only": @props.read)}
readOnly={@props.read}
var submitStream = $('#search-form').asEventStream('submit');
submitStream.doAction(".preventDefault")
.flatMapLatest(function (e) {
var searchString = $(e.target).children('#search').val()
if (searchString !== "") {
return Bacon.constant(searchString);
} else {
return Bacon.never();
}
@silppuri
silppuri / gist:8013616
Last active December 31, 2015 16:29
Late night playtime with es6 arrow functions
var arr = [25,26,29,59,16,1325,3];
var id = (x) => _ => x;
var gt = (b) => a => a > b;
arr.filter(gt(25)); // [26, 29, 59, 132]
var people = [
{name: "John", age: 45},
{name: "Fantomas", age: 34},
{
"name": "",
"version": "0.0.0",
"description": "",
"main": "index.js",
"devDependencies": {
"watchify": "~0.3.0"
},
"dependencies": {
"browserify": "~2.35.4",
(function (num) {
console.time("1")
setTimeout(function() {
console.timeEnd("1")
}, num)
})(1000)
@silppuri
silppuri / newton.hs
Last active December 25, 2015 12:49
-- newton's method for sqrt
goodEnough :: Double -> Double -> Bool
goodEnough guess x = abs(x - guess * guess) / x < 0.00001
improveGuess :: Double -> Double -> Double
improveGuess guess x = (guess + x / guess) / 2
sqrtIter :: Double -> Double -> Double
sqrtIter guess x
| goodEnough guess x = guess
/*
* Runs pdflatex and bibtex on filechange.
* This assumes you have main.tex
* in the folder where command is run.
*
* Usage: node change-wathcer.js somedir &
*/
'use strict';
var fs = require('fs'),
exec = require('child_process').exec,
@silppuri
silppuri / gist:5597352
Created May 17, 2013 06:44
I do this mistake too often...
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
VAR=$(git grep --cached debugger)