Skip to content

Instantly share code, notes, and snippets.

View alexandru-calinoiu's full-sized avatar
💭
Crafting

Calinoiu Alexandru Nicolae alexandru-calinoiu

💭
Crafting
View GitHub Profile
@alexandru-calinoiu
alexandru-calinoiu / gist:451bb7cdaa1e67111ae7
Last active January 29, 2022 05:04
Send a CURL get request with an array param
This took me longer that I will like to find out
curl "http://localhost:3000/v1/collections/42/items?fields[]=synopsis" -v -H "Content-Type: application/json" -H "X-Session-Token: xxx" --globoff
{
"name": "AgilePool",
"description": "Testing pool from Agile Freaks",
"ticker": "AFPL",
"homepage": "https://www.agilefreaks.com"
}
@alexandru-calinoiu
alexandru-calinoiu / knights_tour.rb
Created November 4, 2018 10:04
Solve knights tour both recursively and iteratevely
# A knight is placed on a square of the board, moving according to the rules of the chess he must visit each square exactly once
N = 8
sol = Array.new(N) { Array.new(N) { :not_visited } }
def print_solution(sol)
sol.each do |line|
line.each { |char| print "#{char} " }
puts
@alexandru-calinoiu
alexandru-calinoiu / boot_enqueue.rb
Created April 20, 2017 12:23
Async step adapter
class Enqueue
include Dry::Monads::Either::Mixin
include IngestService::Import['enqueue']
def call(step, input, *args)
enqueue.call(step.operation_name, input, args)
Right(input)
end
end
require 'thread'
q = Queue.new
eq = Enumerator.new(-> { q.size }) do |y|
loop do
y << q.pop
end
end
doubler = Thread.new do
/**
* e2e task
*
* You should have the server up and running before executing this task. e.g. run `au run`, otherwise the
* protractor calls will fail.
*/
import { build, CLIOptions } from 'aurelia-cli';
import * as del from 'del';
import * as eventStream from 'event-stream';
import * as gulp from 'gulp';
#inspired by http://blog.martinosis.com/blog/simple-functional-strong-params-in-ruby/
require 'pp'
filter_hash = -> keys, params {
keys.map { |key| [key, params[key]] }.to_h
}.curry
params = { name: 'Ion', age: 42, pwd: 'plain', contact: { address: 'Danil Ionescu' } }
class Client
class NotificationsResponse
attr_reader :content, :error
def self.build(&block)
error = false
content = begin
yield
rescue Errno::ECONNREFUSED => exception
error = exception
query {
movie(id: 1) {
title
shortname
release_year
extras(first: 25) {
images {
hero {
16_9
class VideoPresenter
def initialize(db_video, facebook_video)
@facebook_id = db_video[:id]
@age = facebook_video[:age]
end
end
db_videos = [{ id: 42, name: 'Ion' }, { id: 43, name: 'Gheo' }]
facebook_videos = [{ facebook_id: 43, age: 42 }, { facebook_id: 44, age: 43 }]