Skip to content

Instantly share code, notes, and snippets.

View acamino's full-sized avatar
💭
千本桜景厳

Agustin Camino acamino

💭
千本桜景厳
  • Genome, LLC
  • Quito, Ecuador
View GitHub Profile
@acamino
acamino / section.rb
Created December 24, 2019 18:48
Section an array by the given lengths
# section :: [a] -> [Int] -> [[a]]
section = lambda { |arr:, lengths:|
starts = [*0..lengths.size - 1].reduce([]) do |acc, idx|
acc << lengths.take(idx).sum; acc
end
starts.zip(lengths).map { |start, lenght| arr.slice(start, lenght) }
}
arr = [*1..100]
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4VsqRXhpZgAATU0AKgAAAAgAFgEPAAIAAAAGAAABFgEQAAIAAAAMAAABHAESAAMAAAABAAEAAAEaAAUAAAABAAABKAEbAAUAAAABAAABMAEoAAMAAAABAAIAAAEyAAIAAAAUAAABOAE7AAIAAAABAAAAAAITAAMAAAABAAIAAIKYAAIAAAABAAAAAIdpAAQAAAABAAABTIglAAQAAAABAAA5uIgwAAMAAAABAAIAAIgyAAQAAAABAAAGQJAQAAIAAAAHAAA5zJARAAIAAAAHAAA51JASAAIAAAAHAAA53KQwAAIAAAABAAAAAKQxAAIAAAANAAA55KQyAAUAAAAEAAA58qQ0AAIAAAAcAAA6EqQ1AAIAAAALAAA6LgAAOjpDYW5vbgBDYW5vbiBFT1MgUgAAAABIAAAAAQAAAEgAAAABMjAxODowNDoyMiAwNzo1NzoxMAAAIIKaAAUAAAABAAAC0oKdAAUAAAABAAAC2ogiAAMAAAABAAIAAIgnAAMAAAABBkAAAJAAAAcAAAAEMDIzMZADAAIAAAAUAAAC4pAEAAIAAAAUAAAC9pEBAAcAAAAEAQIDAJIBAAoAAAABAAADCpICAAUAAAABAAADEpIEAAoAAAABAAADGpIHAAMAAAABAAUAAJIJAAMAAAABAAAAAJIKAAUAAAABAAADIpJ8AAcAADVWAAADKpKGAAcAAAEIAAA4gJKQAAIAAAADNzMAAJKRAAIAAAADNzMAAJKSAAIAAAADNzMAAKAAAAcAAAAEMDEwMKABAAMAAAABAAEAAKACAAMAAAABDSAAAKADAAMAAAABCMAAAKAFAAQAAAABAAA5iKIOAAUAAAABAAA5qKIPAAUAAAABAAA5sKIQAAMAAAABAAIAAKQBAAMAAAABAAAAAKQCAAMAAAABAAAAAKQDAAMAAAABAAAAAKQGAAMAAAABAAAAAOodAAkAAAABAAAAAAAAA
@acamino
acamino / factorial.rb
Created November 7, 2018 18:27
Factorial defined in terms of lambda calculus.
# Factorial
# Keep in mind we want to remove assignment.
ZERO = ->(_) { ->(x) { x } }
# ONE = ->(f) { ->(x) { f[x] } }
TWO = ->(f) { ->(x) { f[f[x]] } }
THREE = ->(f) { ->(x) { f[f[f[x]]] } }
ADD0 = ->(n) { ->(f) { ->(x) { n[f][x] } } }
SUCC = ->(n) { ->(f) { ->(x) { f[n[f][x]] } } }
@acamino
acamino / IncomingController.cs
Created October 10, 2017 21:51
Secure your C# / ASP.NET Core by validating incoming Twilio Requests
using Microsoft.AspNetCore.Mvc;
using Twilio.TwiML;
using ValidateRequestExample.Filters;
namespace ValidateRequestExample.Controllers
{
public class IncomingController : Controller
{
[ValidateTwilioRequest]
[Produces("text/xml")]
@acamino
acamino / IncomingController.cs
Last active October 5, 2017 15:10
Secure your C# / ASP.NET WEB API by validating incoming Twilio Requests
using System.Net.Http;
using System.Text;
using System.Web.Http;
using Twilio.TwiML;
using ValidateRequestExample.Filters;
namespace ValidateRequestExample.Controllers
{
public class TwilioMessagingRequest
{
@acamino
acamino / Todo.hs
Last active January 20, 2017 12:33
TODO manager in Haskell
import System.Directory
import System.Environment
import System.IO
import Control.Monad
import Data.List
dispatch :: [(String, [String] -> IO ())]
dispatch = [ ("add", add)
, ("view", view)
, ("remove", remove)
@acamino
acamino / .vimrc
Last active October 24, 2016 11:20
Vim Custom Configuration
" Quickly toggle between relative and no relative line numbers
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
nnoremap <C-L> :call NumberToggle()<CR>
@acamino
acamino / colors.sh
Created October 20, 2016 11:18
Bash Colors
#!/bin/bash
echo -e "\033[0mCOLOR_NC (NO COLOR)"
echo -e "\033[1;37mCOLOR_WHITE\t\033[0;30mCOLOR_BLACK"
echo -e "\033[0;34mCOLOR_BLUE\t\033[1;34mCOLOR_LIGHT_BLUE"
echo -e "\033[0;32mCOLOR_GREEN\t\033[1;32mCOLOR_LIGHT_GREEN"
echo -e "\033[0;36mCOLOR_CYAN\t\033[1;36mCOLOR_LIGHT_CYAN"
echo -e "\033[0;31mCOLOR_RED\t\033[1;31mCOLOR_LIGHT_RED"
echo -e "\033[0;35mCOLOR_PURPLE\t\033[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\033[0;33mCOLOR_YELLOW\t\033[1;33mCOLOR_LIGHT_YELLOW"
@acamino
acamino / README.md
Last active April 21, 2024 20:58
Shortcuts to Improve Your Bash & Zsh Productivity

Shortcut — Action

  • CTRL + A — Move to the beginning of the line
  • CTRL + E — Move to the end of the line
  • CTRL + [left arrow] — Move one word backward (on some systems this is ALT + B)
  • CTRL + [right arrow] — Move one word forward (on some systems this is ALT + F)
  • CTRL + U — (bash) Clear the characters on the line before the current cursor position
  • CTRL + U —(zsh) If you're using the zsh, this will clear the entire line
  • CTRL + K — Clear the characters on the line after the current cursor position
  • ESC + [backspace] — Delete the word in front of the cursor
@acamino
acamino / HttpClientApproach.cs
Last active November 6, 2023 11:46
4 Ways to Parse a JSON API with C#
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
namespace HttpClientApproach
{
internal class Contributor
{
public string Login { get; set; }