Skip to content

Instantly share code, notes, and snippets.

def change_multiple(list, item_field, expected_changes = ->(x) { x })
change_matcher = lambda { |item|
expected_changes.call(
change { item.reload[item_field] }
)
}
first_item = list.first
rest = list[1..-1]
first_matcher = change_matcher.call(first_item)
rest.inject(first_matcher) do |matcher, item|

How starting a new django project with Cookiecutter

Create enviroment

$ pyenv virtualenv cookiecutter-starter

Activate enviroment

$ pyenv activate cookiecutter-starter

Install Cookiecutter

$ pip install cookiecutter

@afmicc
afmicc / trello-summary.js
Created February 6, 2020 13:58
Trello - Show card count and sum story point and spends hours
// template: Create User - Facebook login - [1sp] [5hs]
const listTitlesSelector = '.list-header-num-cards.js-num-cards';
const cardTitlesSelector = '.list-card-title.js-card-name';
const storyPointRegex = /\d+(?=[sp SP])/;
const spentHourRegex = /\d+(?=[hs HS hr HR])/;
const listHeaderSummaryClass = 'list-header-summary';
const listHeaderSummarySelector = `.${listHeaderSummaryClass}`;
const showCardCount = () => document.querySelectorAll(listTitlesSelector).forEach(title => title.classList.remove('hide'));
@afmicc
afmicc / ruby-on-rails-intallation.md
Last active October 20, 2019 02:41
Installing ruby on rails on windows from Ubuntu bash

Ruby on Rails installation

Installing ruby on rails on windows from Ubuntu bash

  1. (Optional) Install PogreSQL

  2. Install ruby + rails

  3. If you install rails 6+, you need to install yarn.

@afmicc
afmicc / heroku_copy_database.sh
Created September 27, 2019 13:48
Heroku - Copy database to another app
# get git remote url names
git remote -v
# create back up at old app
heroku pg:backups:capture --remote origin-remote-name-url
heroku pg:backups:download --remote origin-remote-name-url # optional
# get backup url
heroku pg:backups:url --remote origin-remote-name-url # return s3-amazon-url
@afmicc
afmicc / !README.md
Last active October 20, 2019 02:36
VS Code debug Ruby on Rails

VS Code debug Ruby on Rails

Steps

  1. In a terminal: run rails debug
  2. In VS Code: Debug > select Listen for rdebug-ide > Play
@afmicc
afmicc / IdentificationValidator.cs
Last active December 17, 2018 14:21
Verificador de cedula de identidad (CI) uruguaya. Angular validator.
namespace Helpers
{
#region --- Usings ---
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion
@afmicc
afmicc / area-list.component.ts
Last active September 27, 2018 20:59
Convert json response to object in typescript
import { CopyHelper } from '../../helpers/copy.helper';
import { Area } from '../../models/area';
export class AreaListComponent
{
...
getAreas(): void
{
this.service.getAll()
.subscribe(response =>
@afmicc
afmicc / !README.md
Last active January 21, 2020 20:19
DataTable.net - Implementation of serverside processing in .net Core MVC with ef core dynamic query to paging, sorting and searching

DataTable.net - serverside processing

DataTable.net - Implementation of serverside processing in .net Core MVC with ef core dynamic query to paging, sorting and searching

@afmicc
afmicc / sort-array.js
Created September 21, 2018 01:54
Sort array by properties
/*
* property: sort by property (name) - type: string
* property2: then sort by property2 (name) - type: string - optional
* areNumbers: Are property and property2 numbers? - type: boolean - optional
*/
Array.prototype.sortBy = function(property, property2, areNumbers)
{
return this.sort(function(a,b)
{
var valueA = areNumbers ? 0 : "";