Skip to content

Instantly share code, notes, and snippets.

View camarin24's full-sized avatar

Cristian Marín camarin24

  • Iluma
  • Medellín, Colombia
  • 03:03 (UTC -05:00)
View GitHub Profile
@camarin24
camarin24 / Server.js
Created October 10, 2016 15:15
Insert whit Mysql DataBase and Node.js
app.post("/registro", function (req, res) {
var datos = {
nombre: req.body.nombre,
apellido: req.body.apellido,
fecha_nacimiento: req.body.fechaNacimiento,
correo_electronico: req.body.email,
contrasenia: req.body.password
};
db.query("SELECT * FROM personas WHERE correo_electronico = ?", [req.body.email], function (err, user) {
if (err) throw err;
@camarin24
camarin24 / InterfacesImplementations.ts
Created November 22, 2016 19:09
TypeScript Interfaces implementations
interface IRepository<T>{
Delete(Entity:T):T;
Update(Entity:T):T;
Create(Entity:T):T;
}
class IComprasRepository implements IRepository<ComprasModel>{
private _url:string;
constructor(url:string){
this._url = url;
}
@camarin24
camarin24 / LinqExtension.cs
Created December 17, 2016 17:43
Linq extension method (converto to int array)
public static class LinqExtension
{
public static int[] ConvertToArrayInt<T>(this List<T> data, Func<T,int> lamba)
{
return data.Select(lamba).ToArray();
}
}
@camarin24
camarin24 / Paginate.cs
Created December 19, 2016 15:36
Linq extension method (Paginate)
public static class LinqExtension
{
public static List<T> Paginate<T>(this List<T> data, Func<T, object> orderBy, int pageSize, int PageNumber)
{
var model = data.OrderBy(orderBy).Skip((PageNumber - 1) * pageSize).Take(pageSize).ToList();
return model;
}
}
@camarin24
camarin24 / BaseRepository.cs
Created December 20, 2016 18:38
BaseDbContextManager
public interface IRepository<T> where T : class
{
IQueryable<T> All { get; }
T Delete(T entity);
T FindById(object Id);
T Insert(T entity);
T Update(T entity, T oldEntity, out bool modified);
}
public abstract class BaseEFRepository<TEntity> : IRepository<TEntity> where TEntity : class, new()
@camarin24
camarin24 / reflection.cs
Created December 27, 2016 21:52
Reflection Extension Method
private T DeserializeYahooRequest<T>(string response) where T : class, new()
{
T model = new T();
string[] parameters = response.Split('&');
foreach (var item in parameters)
{
var elem = item.Split('=');
PropertyInfo propertyInfo = model.GetType().GetProperty(elem[0]);
propertyInfo.SetValue(model, Convert.ChangeType(elem[1], propertyInfo.PropertyType), null);
}
@camarin24
camarin24 / AsyncHelpers.cfm
Last active June 2, 2017 20:15
synchronously
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Web.Helpers
{
public static class AsyncHelpers
{
@camarin24
camarin24 / soap.xml
Created June 30, 2017 17:43
Soap configuration section
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="1024000" name="ZWS_PRECIO_VENTA" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/>
@camarin24
camarin24 / deleteduplicates.sql
Created June 30, 2017 21:36
Delete duplicates rows in a table
DELETE dupes
FROM MyTable dupes, MyTable fullTable
WHERE dupes.dupField = fullTable.dupField
AND dupes.secondDupField = fullTable.secondDupField
AND dupes.uniqueField > fullTable.uniqueField
@camarin24
camarin24 / GitLabDocker.txt
Created October 11, 2017 00:17
GitLab Docker command line
docker run --detach --name gitlab --hostname 127.0.0.1 --publish 30080:30080 --publish 30022:22 --env GITLAB_OMNIBUS_CONFIG="external_url 'http://127.0.0.1:30080'; gitlab_rails['gitlab_shell_ssh_port']=30022;" gitlab/gitlab-ce