$ gem install kontena-cli
$ kontena login {ip}
$ kontena grid use staging
$ kontena vpn config > kontena.ovpn
$ sudo openvpn --config kontena.ovpn --script-security 2 --daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pg' | |
=begin | |
when creating a postgres db replica in RDS, or restoring from a snapshot, the | |
underlying EBS volume of the new instance must be initialized by reading every | |
block, otherwise the blocks will be lazy-initialized by production queries | |
which will be extremely latent. (i've seen normally 50ms queries take 30s in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/activestorage.rb | |
Rails.application.config.to_prepare do | |
# Provides the class-level DSL for declaring that an Active Record model has attached blobs. | |
ActiveStorage::Attached::Macros.module_eval do | |
def has_one_attached(name, dependent: :purge_later, acl: :private) | |
class_eval <<-CODE, __FILE__, __LINE__ + 1 | |
def #{name} | |
@active_storage_attached_#{name} ||= ActiveStorage::Attached::One.new("#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"}, acl: "#{acl}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT json_build_object( | |
'type', 'FeatureCollection', | |
'crs', json_build_object( | |
'type', 'name', | |
'properties', json_build_object( | |
'name', 'EPSG:4326' | |
) | |
), | |
'features', json_agg( | |
json_build_object( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Published on Docker Hub with above user alexellisio. | |
# If you want to rebuild your own copy, follow below instructions | |
# Build this on each type of machine so you have the correct CPU extensions. | |
FROM alexellisio/boostbase | |
RUN git clone -b Linux https://github.com/nicehash/nheqminer.git | |
RUN cd nheqminer/cpu_xenoncat/Linux/asm/ && sh assemble.sh && cd ../../../Linux_cmake/nheqminer_cpu && cmake . && make | |
ENTRYPOINT ["./nheqminer/Linux_cmake/nheqminer_cpu/nheqminer_cpu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# Put this code snippet between the <head></head>-tags in your application layout and %> | |
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %> | |
<%# ... %> | |
<head> | |
<%# ... %> | |
<% if Rails.env.production? %> | |
<script type="text/javascript"> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.TileLayer.GeoJSON.Multi = L.TileLayer.GeoJSON.extend({ | |
addTileData: function(json, tilePoint) { | |
for (var featureName in json) { | |
var geojson = json[featureName]; | |
L.TileLayer.GeoJSON.prototype.addTileData.apply(geojson, tilePoint); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var browserSync = require('browser-sync').create(); | |
var setupWatchers = function() { | |
gulp.watch(['./app/views/**/*.erb', | |
'./app/assets/javascripts/**/*.js'], ['reload']); | |
gulp.watch(['./app/assets/stylesheets/**/*.scss'], ['reloadCSS']) | |
}; | |
gulp.task('reload', function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
///////////////////// | |
// slack2html | |
// by @levelsio | |
///////////////////// | |
// | |
///////////////////// | |
// WHAT DOES THIS DO? | |
///////////////////// | |
// |
NewerOlder