Skip to content

Instantly share code, notes, and snippets.

🤡
-

Steve Wagner lanwin

🤡
-
View GitHub Profile
View gist:add3ab8a5de85e871afc
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)
{
View designer.html
<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 Feb 9, 2015
Parse tshark (Wireshark) data field capture file
View convert.js
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 Apr 9, 2015
XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
View gist:ad98f0b37222b4f08478
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<10;i++) {
View designer.html
<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 Apr 20, 2015
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
View example.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function func() {
@lanwin
lanwin / test.html
Created Apr 23, 2015
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set # 3
View test.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function onload(s) {
@lanwin
lanwin / gist:852890
Created Mar 3, 2011
Simply object extension with provides an maybe monad.
View gist:852890
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 Sep 29, 2015 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
View functional-utils.js
// 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 Feb 2, 2012
Script to Automatically add all GitLab users to all projects
View add_users_to_projects.sh
#!/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
You can’t perform that action at this time.