Skip to content

Instantly share code, notes, and snippets.

View vladfaust's full-sized avatar
🕉️
एकक्षण

Vlad Faust vladfaust

🕉️
एकक्षण
View GitHub Profile
@vladfaust
vladfaust / gist:cc51b26c8ef545017bdb
Last active January 15, 2016 19:38 — forked from bibstha/gist:49540af53fa0ec5ab869
Deploy to dokku from codeship.com

After migrating from heroku to dokku, we had to also chance codeship so we deploy to dokku. I followed the following steps to successfully deploy to dokku.

  1. Save the public key of the codeship project. It is found in Project Settings > General Settings.
  2. Copy the public key to a file /tmp/codeship_projectname.pub.
  3. Make sure when pasting, all the contents are in a single line and not multiple lines.
  4. Add the public key to dokku using the following command in console. Reference.
cat /tmp/codeship_projectname.pub | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"
@vladfaust
vladfaust / sort_playing_cards_task.rb
Created January 25, 2016 11:18
Was given a playing cards sample array. The task was to sort it and make all the members unique.
@canonical_hash = Hash.new
def init
i = 0
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Aces' ].map do |value|
@canonical_hash[value] = (i += 1)
end
end
def card_sort (array)
@vladfaust
vladfaust / ali_parse.rb
Last active May 8, 2016 17:25
Small code snippets to grab from Aliexpress
require 'open-uri'
require 'nokogiri'
require 'active_support'
require 'fileutils'
module Proxy
@@proxy = nil
def self.get_proxy
@@proxy
@vladfaust
vladfaust / freegeoip_dokku.md
Last active September 2, 2016 16:33
Running a FreeGeoIP instance and linking it to a Dokku app
  1. docker run -d fiorix/freegeoip -http :80
  2. dokku docker-options:add myapp run "--link container_name:alias"
  3. dokku docker-options:add myapp deploy "--link container_name:alias"
  4. Inside dokku app: curl alias/json/1.2.3.4
  5. 👍
@vladfaust
vladfaust / gist:470f69f28ed4f6b4e55247fdb5e4f99e
Created January 20, 2017 20:59
Backup Dokku apps with Dropbox
# 0. Install Ruby on your server: https://gorails.com/setup/ubuntu/16.04
# 1. Install Whenever gem on the server: https://github.com/javan/whenever
# 2. Cd to `/root/backup/`, install Dropbox Uploader (https://github.com/andreafabrizi/Dropbox-Uploader) into it
# 3. Go to https://www.dropbox.com/developers/apps, create a new app
# 4. Generate a new Access Token for that app
# 5. Run `./dropbox_uploader.sh` and import the Access Token
# 6. Create a `config` directory
# 7. Run `wheneverize .`
# 8. Edit `config/schedule.rb` file like this (it's just an example):
module API
module Queries
module User
Fragment = Client.new.parse <<- 'GRAPHQL' # There is no space in the code, just for Gist
fragment on User {
id
status
}
GRAPHQL
end
@vladfaust
vladfaust / test.cr
Created August 1, 2017 22:19
Overloading bug (Crystal issue #4775)
# Using crystal 0.23.1
# See https://github.com/crystal-lang/crystal/issues/4775
# Run `crystal spec test.cr` to test
# PART 0: Definitions
module Abstract
abstract class Dog
def initialize(@color : String)
end
@vladfaust
vladfaust / list.md
Last active November 15, 2017 00:31
Crystal improvements
  1. HTTP::Params should be initializeable w/o arguments
  2. Currently :nodoc: doesn't exclude classes from generated documentation
require "logger"
require "colorize"
# A custom log formatter.
#
# ```
# require "./custom_log_formatter"
# logger = Logger.new(STDOUT, Logger::DEBUG, custom_log_formatter)
# logger.debug("Hello world!")
# DEBUG [12:45:52.520] Hello world!
@vladfaust
vladfaust / .travis.yml
Created October 8, 2018 10:14
Docker-based Crystal nightly builds on Travis CI
dist: xenial
language: generic
sudo: required
services:
- docker
before_install:
- docker pull crystallang/crystal:nightly
script:
- docker run -v ${PWD}:/x -w /x crystallang/crystal:nightly bash -c "/usr/bin/shards install"
- docker run -v ${PWD}:/x -w /x crystallang/crystal:nightly bash -c "/usr/bin/crystal spec"