Skip to content

Instantly share code, notes, and snippets.

View lanwin's full-sized avatar
🤡
-

Steve Wagner lanwin

🤡
-
View GitHub Profile
public static class FunctionalBindingExtensions
{
public static Action<T2> Bind<T1, T2>(this Action<T1, T2> action, Func<T1> getValueFunc)
{
return action.Bind(getValueFunc());
}
public static Action<T1> Bind<T1, T2>(this Action<T1, T2> action, Func<T2> getValueFunc)
{
@lanwin
lanwin / designer.html
Created November 26, 2014 08:51
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@lanwin
lanwin / convert.js
Created February 9, 2015 16:09
Parse tshark (Wireshark) data field capture file
var fs = require("fs");
var content = fs.readFileSync("outfile.raw",{encoding:'ascii'}).toString().trim().split(/\r?\n/g);
var text = Buffer.concat(content.map(function(line){return new Buffer(line.trim(),'hex');})).toString('ascii').trim();
text.split(/\r\n\r\n/g).forEach(function(line){
var obj = JSON.parse(line);
console.log( ' ' );
console.log( JSON.stringify(obj,null,line.length>200?2:0) );
@lanwin
lanwin / gist:ad98f0b37222b4f08478
Created April 9, 2015 09:45
XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<10;i++) {
@lanwin
lanwin / designer.html
Last active August 29, 2015 14:18
designer
<link href="../core-icon-button/core-icon-button.html" rel="import">
<link href="../core-toolbar/core-toolbar.html" rel="import">
<link href="../core-header-panel/core-header-panel.html" rel="import">
<link href="../core-drawer-panel/core-drawer-panel.html" rel="import">
<link href="../core-menu/core-submenu.html" rel="import">
<link href="../core-item/core-item.html" rel="import">
<polymer-element name="my-element">
<template>
@lanwin
lanwin / example.html
Created April 20, 2015 11:51
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function func() {
@lanwin
lanwin / test.html
Created April 23, 2015 10:28
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set # 3
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function onload(s) {
@lanwin
lanwin / gist:852890
Created March 3, 2011 15:06
Simply object extension with provides an maybe monad.
public static class ObjectExtensions
{
public static IEnumerable<T> ToMaybe<T>(this T obj)
{
return Equals(obj,null) ? Enumerable.Empty<T>() : new[] {obj};
}
}
@lanwin
lanwin / functional-utils.js
Created September 29, 2015 14:30 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@lanwin
lanwin / add_users_to_projects.sh
Created February 2, 2012 08:41
Script to Automatically add all GitLab users to all projects
#!/bin/sh
baseurl=http://mygitlaburl
usermail=adminuser@mymailserver
userpass=adminpassword
repo_access=2 #0=denied 1=read 2=read&write
project_access=2 #0=deined 1=read 2=report 3=admin
# login
curl -s -I -c cookies.txt -d "utf8=✓&user[email]=$usermail&user[password]=$userpass&commit=Sign+in" $baseurl/users/sign_in