Skip to content

Instantly share code, notes, and snippets.

View nisevi's full-sized avatar
🧑‍🚀
Working from anywhere

Nicolas Sebastian Vidal nisevi

🧑‍🚀
Working from anywhere
View GitHub Profile
@nisevi
nisevi / github_static_pages_job.rb
Last active April 15, 2018 09:41
Module that holds the logic for pulling and saving to database the '.md' files that live in the root path of a GitHub repository.
require 'octokit'
require 'base64'
module GithubStaticPagesJob
extend self
FILE_NAME_REGEX = /\w+[^\.md]/
def client
credentials = {
@nisevi
nisevi / markdown_converter.rb
Created April 13, 2018 21:18
This service acts as a wrapper that encapsulates the 'kramdown' functionality.
class MarkdownConverter
attr_reader :markdown
private :markdown
def initialize(markdown)
@markdown = markdown
end
def as_html
converted_markdown.html_safe
@nisevi
nisevi / config.yml
Last active January 24, 2024 04:27
CircleCI 2.0 deploy to S3 static website - configuration file.
version: 2
jobs:
build:
working_directory: /tmp/vasko
docker:
- image: circleci/python:3.6.2-stretch-browsers
steps:
- checkout
- run:
name: Deploying Vasko.
@nisevi
nisevi / s3_public_read
Last active October 6, 2017 23:18
Granting Read-Only Permission to an Anonymous User - http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
@nisevi
nisevi / ApiTestTrait.php
Last active March 13, 2017 22:52
How to check the keys of a JSON in PHP?
<?php
namespace Tests\Traits;
trait ApiTestTrait
{
public function assertApiResponse(Array $actualData)
{
$this->assertApiSuccess();
@nisevi
nisevi / citrusbyte.rb
Last active January 2, 2017 16:32
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
# a = [[1,2,[3]],4]
# aux = []
def flatten(a, aux)
a.each do |n|
if n.instance_of?(Fixnum)
aux<<n
elsif n.instance_of?(Array)
flatten(n, aux)
end
end