Skip to content

Instantly share code, notes, and snippets.

View jpolvora's full-sized avatar

Jone jpolvora

View GitHub Profile
public static class Coroutine {
public static void BeginExecute(IEnumerable<Promise> enumerable) {
MoveNext(enumerable.GetEnumerator());
}
static void MoveNext(IEnumerator<Promise> enumerator) {
if (enumerator.MoveNext()) {
var promise = enumerator.Current;
promise.Current = promise.Task();
promise.Current._CallBack = () => MoveNext(enumerator);
@jpolvora
jpolvora / cleaniissites.bat
Last active June 2, 2017 00:37
Removes all registered IIS Express sites in applicationhost.config.
@echo off
pushd "%PROGRAMFILES%\IIS Express"
for /F %%i in ('appcmd list sites /text:NAME') do (
echo %%i
appcmd delete site %%i
)
popd
@jpolvora
jpolvora / boot.js
Created September 28, 2016 22:20
SystemJS Knockout JS Module Loader
var systemJsLoader = {
loadComponent: function (name, templateConfig, callback) {
if (templateConfig.systemjs) {
SystemJS.import(templateConfig.systemjs)
.then(function (viewModelCtor) {
callback({
createViewModel: function (params, componentInfo) {
return viewModelCtor.viewModel(params, componentInfo);
},
template: ko.utils.parseHtmlFragment(viewModelCtor.template)
@jpolvora
jpolvora / main.cs
Last active January 24, 2017 20:10
esqueminha pseudo java/C#
class ApiClient {
private string connectionString;
ctor(String connectionString) {
this.connectionString = connectionString;
}
public string FazAlgumaCoisa(string parametros) {
using (var conexao = new ConexaoComDb(connectionString)) {
return conexao.PegaDados(parametros);
@jpolvora
jpolvora / iis.bat
Last active October 4, 2016 17:50
Batch file which will start IISExpress in current directory with optional port argument
@echo off
@set path=%PATH%;"%PROGRAMFILES\IIS EXPRESS";
:: echo current directory is: %~dp0
:: echo argument 1 is: %1
set "HTTPPORT=9901"
set "PUBLIC=%~dp0%wwwroot"
set "HOME=%~dp0%iishome"
if not [%1]==[] (
set httpport=%1
)
/*
* read-only date display with momentjs
* use like this: data-bind="moment: dateVar, format: 'YYYY-MM-DD'"
* The "format" is optional and will default to "MM/DD/YYYY"
*/
ko.bindingHandlers.moment = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var val = valueAccessor();
var date = moment(ko.utils.unwrapObservable(val));
(function () {
String.prototype.format = function () {
var args = arguments;
return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (m, n) {
if (m == "{{") { return "{"; }
if (m == "}}") { return "}"; }
return args[n];
});
};
@jpolvora
jpolvora / controller.js
Last active December 28, 2015 18:09
Ext Ext.js ActionColumn MVC Estive procurando uma solução para esse problema e de todas as formas que testei, a mais simples no MVC foi a de disparar um evento na view, com o controller capturando este evento. Testado no Ext.js 4.2.0
Ext.define('App.controller.Clientes', {
extend: 'Ext.app.Controller',
init: function () {
this.control({
"grid": {
meuevento: function (record) { //captura o evento que será disparado pelo grid, quando o ícone for clicado
console.log(record);
},
@jpolvora
jpolvora / LocalReportExtensions.cs
Last active December 22, 2015 09:49
Modo de Uso: var report = viewer.RptViewer.LocalReport; JonePolvora.LocalReportExtensions.ImprimeDireto(report);
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using Microsoft.Reporting.WinForms;
// ReSharper disable once CheckNamespace
namespace JonePolvora {
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;