Skip to content

Instantly share code, notes, and snippets.

View erpe's full-sized avatar
🏠
Working from home

rene paulokat erpe

🏠
Working from home
  • AustauschKompass
  • Berlin
  • X @er_pe
View GitHub Profile
@erpe
erpe / unicorn_cap_task.rb
Created April 18, 2013 11:11
capistrano task to deal with unicorn restarts during deployment
namespace :unicorn do
desc "Zero-downtime restart of Unicorn"
task :restart, :except => { :no_release => true } do
# you can use this signal if preload_app == false
# run "kill -s HUP `cat #{shared_path}/pids/unicorn.pid`"
# use this signal if preload_app == true
run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
# give unicorn some seconds to create unicorn.pid.oldbin
@erpe
erpe / gist:6174427
Last active December 20, 2015 18:18
using chained scopes for facetted querying
class Program < ActiveRecord::Base
belongs_to :associated_school
scope :active, -> { where("active = ?", true) }
scope :inactive, -> { where("active = ?", false)}
scope :in_country, ->(country) {
joins(associated_school:
{school: :address}
).where(addresses:
@erpe
erpe / _piwik_js.html.erb
Last active December 31, 2015 13:49
my try to get turbolinks work with (piwik) javascript tracking somehow its not relayable - dunno why... it tracks sometimes - but not to the expected degree... figured out, that tracking works as today in firefox 26.0 on Linux as well as on Android Standard (safari-based?) Browser (4.3) - but on Chrome Version 31.0.1650.63 on Linux as well as an…
<!-- app/views/shared/_piwik_js.html.erb -->
<script type="text/javascript" data-turbolinks-eval=false>
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<%= PiwikSetup.host %>/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
@erpe
erpe / piwik_analytics.coffee
Last active July 20, 2016 01:02
another try to get piwik running with turbolinks
class @PiwikAnalytics
@load: ->
# Piwik Analytics depends on a global _paq array. window is the global scope.
window._paq = []
window._paq.push(['setTrackerUrl', PiwikAnalytics.trackerUrl() + '/piwik.php'])
window._paq.push(['setSiteId', PiwikAnalytics.siteId()])
window._paq.push(['enableLinkTracking'])
# Create a script element and insert it in the DOM
@erpe
erpe / google_analytics.coffee
Last active August 29, 2015 14:03
CoffeeScript GoogleAnalytics analytics.js
class @GoogleAnalytics
@load: ->
((i, s, o, g, r, a, m) ->
i["GoogleAnalyticsObject"] = r
i[r] = i[r] or ->
(i[r].q = i[r].q or []).push arguments
i[r].l = 1 * new Date()
@erpe
erpe / main.rs
Last active August 29, 2015 14:12
rust - String and str
fn main() {
let mut txt = "Hello, World!".to_string(); // txt: String
println!("first its: {}", txt);
txt = get_pling(txt);
println!("then its: {}",txt);
add_in_place_plong(&mut txt); // passes a mutable reference
println!("finally its: {}", txt);
@erpe
erpe / paperclip_renderer.rb
Last active September 15, 2015 20:44
Custom renderer for redcarpet to render paperclip - images by their id and additional css
# quick'm'dirty way to allow paperclip image-ids
# instead of urls be passed to Redcarpet
# so you can do:
# ![title](42 'thumb|pull-right') - whereas 'thumb' is your available paperclip-style and 'pull-right' a css-class
# and also the knwon way:
# ![title](http://i.ytimg.com/vi/Z6po6SS9Uz4/maxresdefault.jpg "my alt text")
# all this b'cause there is no 'super' in redcarpet...
#
class PaperclipRender < Redcarpet::Render::HTML
@erpe
erpe / video_markdown_renderer.rb
Created October 22, 2015 17:53
extend redcarpet with custom video tag
# create custom tags for redcarpet to insert youtube|vimeo iframes in
# your document.
# ::usage:: vid(youtube, 123456)
class VideoMarkdownRenderer < Redcarpet::Render::HTML
include ActionView::Helpers::AssetTagHelper
def preprocess(document)
# scans for: vid(provider, id)
# e.g. vid(youtube,12345)
@erpe
erpe / kemalcr_task.rake
Created August 13, 2018 14:50
Simple 'start-stop-daemon'-based script to start/stop/restart kemal after deployment with capistrano
namespace :deploy do
desc 'show kemal status'
task :kemal_status do
on roles(:app) do
within "#{release_path}" do
execute "start-stop-daemon",
"-v",
"--status",
"--pid",
apache2 nutzt auf ubuntu-bionic (18.04) PrivateTmp
d.h. nach jedem reboot von apache2 ändert sich dieses directory
um das zu umgehen entweder PrivateTmp=false in apache service file oder:
in jeweiliger vhosts conf:
PassengerInstanceRegistryDir /var/run/passenger-instance
in .bash_profile: