Skip to content

Instantly share code, notes, and snippets.

@adamtal3
adamtal3 / FileAsync.cs
Created April 8, 2015 20:51
FileAsync - AsyncFile - Asynchronous System.IO.File alternative
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// An async alternative to System.IO.File common usages
/// </summary>
public static class FileAsync
@adamtal3
adamtal3 / Login.js
Created July 26, 2016 08:32
Material-UI + redux-form chrome's auto-fill / auto complete patch
class Login extends Component {
// This was tested under chrome only. It's ugly, but it works. Code was modified a bit for simplicity so it might not work out of the box.
componentDidMount() {
// Fix chrome auto-fill
setTimeout(() => {
const { change, dispatch }= this.props;
if (this.refs.usernameAutoFill.value && ! this.refs.username.value) {
dispatch(change('username', this.refs.usernameAutoFill.value));
}
@adamtal3
adamtal3 / readme.md
Last active August 29, 2016 11:34 — forked from benpriebe/readme.md
Transferring Server data to JavaScript with initial Page Request

Transferring Server data to JavaScript with initial Page Request

Often you want to return data with your call to retrieve a web page/control from ASP.NET MVC so that it can be accessed via JavaScript as a ViewModel (using KnockoutJS or equivalent).

Typically, you make a server call to retrieve the web page using the standard ASP.NET controller action and then make a AJAX call to go retrieve the model to populate your JavaScript ViewModel.

Wouldn't it be nice if you could send back the model with the page request and avoid a separate AJAX call?

How

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
//Allow using this built library as an AMD module
//in another project. That other project will only
//see this AMD call, not the internal modules in
//the closure below.
define(factory);
} else {
//Browser globals case. Just assign the
//result to a property on the global.
@adamtal3
adamtal3 / upload-complete-wrong-size
Created October 18, 2016 20:21
ssh2 logs for issue #485
This file has been truncated, but you can view the full file.
2016-10-18T19:37:28.843Z - debug: DEBUG: Local ident: 'SSH-2.0-ssh2js0.1.11'
2016-10-18T19:37:28.845Z - debug: DEBUG: Client: Trying ftp .... .com on port 2222 ...
2016-10-18T19:37:29.299Z - debug: DEBUG: Client: Connected
2016-10-18T19:37:29.900Z - debug: DEBUG: Parser: IN_INIT
2016-10-18T19:37:29.901Z - debug: DEBUG: Parser: IN_GREETING
2016-10-18T19:37:29.901Z - debug: DEBUG: Parser: IN_HEADER
2016-10-18T19:37:29.901Z - debug: DEBUG: Remote ident: 'SSH-2.0-CrushFTPSSHD'
2016-10-18T19:37:30.468Z - debug: DEBUG: Outgoing: Writing KEXINIT
2016-10-18T19:37:30.469Z - debug: DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
2016-10-18T19:37:30.469Z - debug: DEBUG: Parser: IN_PACKET