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 / Jenkinsfile
Last active December 13, 2022 05:44
Jenkinsfile for a multibranch-pipeline project that builds and deploys a rails application - using capistrano and rvm on jenkins-server
// jenkinsfile - as declarative pipeline
pipeline {
agent any
environment {
// credentials 'jenkins-db-credential' is globally accessible on jenkins
//
DB_CREDENTIAL = credentials('jenkins-db-credential')
DB_USER = "${env.DB_CREDENTIAL_USR}"
@erpe
erpe / filter.d wordpress.conf
Created June 10, 2020 16:50
fail2ban filter for wordpress / apache log combined
[INCLUDES]
before = common.conf
[Definition]
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S
failregex = <HOST>.*POST.*(wp-login\.php|xmlrpc\.php).* 200
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:
@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",
@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 / 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 / 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 / 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 / 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 / _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"]);