Skip to content

Instantly share code, notes, and snippets.

View ag0os's full-sized avatar
🔧

Agustin Nicolas Calabrese ag0os

🔧
View GitHub Profile
@nicolai86
nicolai86 / calendar.coffee
Last active November 5, 2019 14:16
do it yourself calendar.
isSunday = (date) ->
return date.getDay() is 0
nextDay = (date, days = 1) ->
newDate = new Date(date.getTime())
newDate.setDate(date.getDate() + days)
return newDate
prevDay = (date, days = 1) ->
newDate = new Date(date.getTime())
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@stonehippo
stonehippo / install_ruby_with_rbenv.md
Last active June 14, 2024 00:32
Installing a new Ruby with rbenv on Mac OS

Install a new Ruby with rbenv on Mac OS (and make yourself a superhero)

If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account.

This sucks and should be avoided. Here's how to fix that.

Installing a new Ruby

To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*

A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.

@bzerangue
bzerangue / _verify-repair-permissions-disk.md
Last active July 19, 2024 07:35
Mac OS X Utilities via Terminal: (Verify and Repair: Disk Permissions AND Disk / Software Update / TimeMachine)

Verify and Repair Disk Permissions via Terminal (Mac OS X)

Verify Permissions

diskutil verifyPermissions /

Repair Permissions

diskutil repairPermissions /

#!/usr/bin/env bash
#
# Originally from https://gist.github.com/IanVaughan/2902499
#
# authors: Ian Vaughan
# Jacob Zimmerman
#
# usage: uninstall_gems [<version> ...]
#
# examples:
@mbajur
mbajur / .md
Created April 29, 2016 07:16
How to create small, unique tokens in Ruby

How to create small, unique tokens in Ruby

That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:

My choice: Dave Bass’s rand().to_s() trick

Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):

@nickangtc
nickangtc / simple_calendar_tutorial.md
Created October 15, 2016 02:07
How to use Simple Calendar Rails gem

Using Simple Calendar for Rails

Objectives

  • Use simple_calendar gem to easily generate calendars in a Rails project.
  • Understand how the calendar is generated and how to customise it.

What is simple calendar?

Simple calendar is a Rails gem that generates a calendar for use in your views.

You can use simple calendar to generate monthly and weekly calendars.

//here is document with NESTED Array
{
"_id": "xyz-800",
"site": "xyz",
"user": 800,
"timepoints": [
{"timepoint": 0, "a": 1500, "b": 700},
{"timepoint": 2, "a": 1000, "b": 200},
{"timepoint": 4, "a": 3500, "b": 1500}
]
require 'json'
COLORS = {
'#' => '#216e39',
'+' => '#30a14e',
':' => '#40c463',
'-' => '#9be9a8',
'.' => '#ebedf0',
' ' => nil,
}
@dhh
dhh / pagination_controller.js
Last active July 18, 2024 01:07
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>