Skip to content

Instantly share code, notes, and snippets.

View ksarna's full-sized avatar

Kamil Sarna ksarna

View GitHub Profile
@ksarna
ksarna / devert
Created April 2, 2017 21:30 — forked from cfr/devert
Fix vertical video
#!/usr/bin/env sh
# http://stackoverflow.com/a/30819570/187663
ffmpeg -i $1 -lavfi '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' $1.fixed.mov
@ksarna
ksarna / index.js
Created March 3, 2017 14:20 — forked from mrzmyr/index.js
React Native - Detect Double Tap
var Index = React.createClass({
getInitialState: function () {
return {
lastPress: 0
}
},
onPress: function () {
var delta = new Date().getTime() - this.state.lastPress;
@ksarna
ksarna / profiling_tool.rb
Created November 23, 2011 20:10
Profiling rails requests with ruby-prof
# You can use this class in your console. For example
# p = ProfilingTools.new
# p.profiled_request(:controller => :welcome, :action => :index)
# this will profile whole application stack and save file in your tmp/profiler folder
# You can also use +request+ method just to see the output for example:
#
# p.request(:controller => :offers, :action => :index)
#
# p.response.body
# p.response.cookies # and so on
@ksarna
ksarna / gist:955129
Created May 4, 2011 12:13
Handling ajax redirection in rails
def redirect_to(options = {}, response_status = {})
if request.xhr?
render(:update) {|page| page.redirect_to(options)}
else
super(options, response_status)
end
end
@ksarna
ksarna / nginx.conf
Created April 29, 2011 21:51
Snippet from nginx config file for serving different rails apps on single server.
#....
server {
listen 80;
root /home/deploy/$host/current/public; # <--- be sure to point to 'public'!
passenger_enabled on;
}
#....
@ksarna
ksarna / deploy.rb
Created April 29, 2011 21:48
Capistrano task for restarting standalone passenger process
# this is to adjust the capistrano deploy if you are using standalone passenger process,
namespace :deploy do
task :restart, :roles => :app, :except => {:no_release => true} do
run "start-stop-daemon –stop –name nginex"
run "cd #{deploy_to}/current && passenger start -a 127.0.0.1 -p 3000 -d -e #{environment}"
end
end