Skip to content

Instantly share code, notes, and snippets.

View achopijocoder's full-sized avatar

JuanLu achopijocoder

View GitHub Profile
class LineChart {
// LineChart by https://kevinkub.de/
constructor(width, height, values) {
this.ctx = new DrawContext();
this.ctx.size = new Size(width, height);
this.values = values;
}
_calculatePath() {
@achopijocoder
achopijocoder / BaseApiController.cs
Created November 30, 2016 08:36
Enable CORS on WEBAPI 1
public class BaseApiController : ApiController
{
public HttpResponseMessage Options()
{
return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
}
}
@achopijocoder
achopijocoder / gist:a0575fb9d45a3856980e60efb255c9fe
Last active May 17, 2017 06:42
Overcoming 2100 limit LINQ when using Contains
//this will work
// WITH Lambda syntax
var toUpdate = ctxt.Medida.AsEnumerable().Join(diferencia.Ids, c => c.ID, ci => ci, (c, ci) => c).ToList();
// WITH SQL syntax
var toUpdate = (from m in ctxt.Medida.AsEnumerable()
join d in diferencia.Ids
on m.ID equals d
select m).ToList();
@achopijocoder
achopijocoder / .NET BulkInsert from stored procedure using string and xml formats
Last active October 17, 2016 09:45
.NET BulkInsert from stored procedure using string and xml formats
static public void SynchronizeEntities(List<MyEntity> entities)
{
MyDataContext ctxt = MyDataContext.GetFachadaDAL();
// bulkinsert de las medidas
var sBuilder = new StringBuilder();
var sWriter = new StringWriter(sBuilder);
var serializer = new XmlSerializer(typeof(MyEntity[]));
serializer.Serialize(sWriter, entities.ToArray());
ctxt.BulkInsertEntity(sBuilder.ToString());
@achopijocoder
achopijocoder / gist:316c251ed727113b428fc9a6389ba122
Last active September 13, 2016 08:56
Script SQL for searching a String in all tables rows and columns of a database
/******
Extracted from stackoverflow:
http://stackoverflow.com/questions/591853/search-for-a-string-in-all-tables-rows-and-columns-of-a-db
This code should do it in SQL 2005, but a few caveats:
It assumes that all objects are owned by dbo. If that's not the case you'll need to adjust it.
It is RIDICULOUSLY slow. I tested it on a small database that I have with only a handful of tables and it took many minutes to complete. If your database is so big that you can't understand it then this will probably be unusable anyway.
@achopijocoder
achopijocoder / gist:39346de53719d25b02d77988981f5b7e
Created July 19, 2016 09:22
Regex expression for Latitude/Longitude coordinates
var regex_coords = /\-?[0-9]+[\.]{0,1}[0-9]*/;
@achopijocoder
achopijocoder / gist:647a486f14516096a97a
Created March 22, 2016 14:57
Bootstrap table collapse rows
<table class="table table-striped" style="border-collapse:collapse;">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Description</th>
<th>Credit</th>
<th>Debit</th>
<th>Balance</th>
</tr>
@achopijocoder
achopijocoder / validate_spanish_id.js
Created February 18, 2016 15:58 — forked from afgomez/validate_spanish_id.js
Spanish DNI, CIF, NIE validator
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );