Skip to content

Instantly share code, notes, and snippets.

View alkuzad's full-sized avatar

Dawid Gosławski alkuzad

View GitHub Profile
@alkuzad
alkuzad / check_rubocop
Created April 28, 2015 09:17
Rubocop check only files that are changed
# Needs showlinennum in ~/bin folder of user, change it to some more general
# solution if you have showlinenum in path
if [ "$1" == "" ];then
rev="HEAD"
else
rev="$1"
fi
if [ -e ~/bin/showlinenum.awk ]; then
@alkuzad
alkuzad / Hack DelayedJob attr_accessible
Created September 29, 2015 15:16
Hack DelayedJob attr_accessible
module Delayed
module Backend
module ActiveRecord
class Job
def mass_assignment_authorizer_with_logging
mass_assignment_authorizer_without_logging + [:logging_args]
end
alias_method_chain :mass_assignment_authorizer, :logging
end
@alkuzad
alkuzad / send_controller.rb
Created March 4, 2016 14:17
Ruby/Rails4 stream file to client
class SendController < ActionController::Base
def send
# Important - browser can react differently for different types
self.response.headers["Content-Type"] ||= 'application/zip'
# Dispose that file has to be saved not displayed, also specify filename
self.response.headers["Content-Disposition"] = "attachment; filename=@filename"
self.response.headers['Cache-Control'] = 'no-cache' # do not try to cache file
http = Net::HTTP.new('server.dot.net', 80)
@alkuzad
alkuzad / capybara_show_console.rb
Created October 25, 2016 14:02
Capybara Webkit show console in STDOUT
def show_console
page.driver.console_messages.each do |line|
if [:source, :line_number].all?{|x| line.keys.include?(x)}
puts "#{line[:source]}:#{line[:line_number]} - #{line[:message]}"
else
puts "#{line[:message]}"
end
end
nil
end
--- old
+++ fixed
@@ -54,13 +54,13 @@
#A bug was introduced in Sublime Text 3, sometime before 3053, in that it
#changes the active group to 0 when the layout is changed. Annoying.
active_group = window.active_group()
- window.set_layout(layout)
+ window.run_command('set_layout', layout)
num_groups = len(layout['cells'])
window.focus_group(min(active_group, num_groups-1))
@alkuzad
alkuzad / close_minimap_on_multi_view.py
Created January 4, 2018 14:34
Test of cols instead of cells
import sublime
import sublime_plugin
def plugin_loaded():
for window in sublime.windows():
if window.num_groups() > 1:
window.set_minimap_visible(False)
class CloseMinimapOnMultiView(sublime_plugin.EventListener):
@alkuzad
alkuzad / install_jenkins_plugin.sh
Created March 29, 2018 08:25 — forked from hoesler/install_jenkins_plugin.sh
Script to install one or more jenkins plugins including dependencies while jenkins is offline
#!/usr/bin/env bash
set -e
set -o pipefail
plugin_repo_url="http://updates.jenkins-ci.org/download/plugins"
plugin_dir="/var/lib/jenkins/plugins"
include_optionals=false
showUsage() {
@alkuzad
alkuzad / pywin32 read file that exceeds 260chars .py
Created June 15, 2019 20:26
pywin32 read file that exceeds 260chars
import win32file
def read260(path):
handle = None
try:
# http://docs.activestate.com/activepython/2.6/pywin32/win32file__CreateFileW_meth.html
# http://timgolden.me.uk/pywin32-docs/win32file__CreateFileW_meth.html
handle = win32file.CreateFileW(
path,
win32file.GENERIC_READ,
@alkuzad
alkuzad / pywin32 write file that exceeds 260 chars .py
Created June 15, 2019 20:26
pywin32 write file that exceeds 260 chars
import win32file
def write260(path, content):
handle = None
try:
# http://docs.activestate.com/activepython/2.6/pywin32/win32file__CreateFileW_meth.html
# http://timgolden.me.uk/pywin32-docs/win32file__CreateFileW_meth.html
handle = win32file.CreateFileW(
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import org.apache.commons.io.IOUtils
def jenkinsCredentials = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class,
Jenkins.instance,
null,
null