Skip to content

Instantly share code, notes, and snippets.

@bonyiii
bonyiii / restore accidentall deleted.md files
Created June 7, 2012 12:59
Git restore accidentally deleted files
# Az alap koncepció innen származik: http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo
# Csak a törölt fájlokat akarom visszaállítani a módosítottakat nem (ezt a grep 'D' és cut kombináció biztosítja)
# Elméleti:
git co $(git rev-list -n 1 HEAD -- <file_path>)~1 -- $(git diff --name-status $(git rev-list -n 1 HEAD -- <file_path>)~1 head | grep '^D' | cut -f 2)
# Egysorban az egész db könyvtáron mint példa:
git co $(git rev-list -n 1 HEAD -- db)~1 -- $(git diff --name-status $(git rev-list -n 1 HEAD -- db)~1 head | grep '^D' | cut -f 2)
@bonyiii
bonyiii / gist:2290489
Created April 3, 2012 08:42
list git untracked files and delete them
# http://stackoverflow.com/questions/3801321/git-list-only-untracked-files-also-custom-commands
git ls-files --other --exclude-standard app/views/ | xargs rm
git ls-files -z -o --exclude-standard | xargs -0 git add
git clean -df
@bonyiii
bonyiii / gist:2158289
Created March 22, 2012 13:14
Rails ajax link_to remote with put, post
http://www.kolodvor.net/2010/01/02/rails-csrf-and-ajax-requests/
http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000514
http://stackoverflow.com/questions/5241213/rails-session-is-blank-when-using-http-put
Key thing is to add form_authenticity_token to path param as a query_string
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
<%= link_to 'Reset', null_counter_model_path(model, :authenticity_token => form_authenticity_token), :confirm => 'Are you sure?', :method => :put, :remote => true %>
http://stackoverflow.com/questions/68569/text-watermark-on-website-how-to-do-it
<style type="text/css">
#watermark {
color: #d0d0d0;
font-size: 200pt;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
@bonyiii
bonyiii / gist:2021399
Created March 12, 2012 11:59
whkhtmltopdf under opensuse

Linux (OpenSUSE)

# Provides Xvfb
zypper in xorg-x11-server-sdk

wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar -xjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2

cp wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf

@bonyiii
bonyiii / gist:1985562
Created March 6, 2012 10:21
How to make an activerecord model use a tempory table or view dynamically per query
# Creating view or temp table
ActiveRecord::Base.connection.execute("CREATE TEMPORARY TABLE users#{args.offset} SELECT * FROM users LIMIT #{limit} OFFSET #{(args.offset - 1) * limit}")
# or
ActiveRecord::Base.connection.execute("CREATE VIEW users#{args.offset} AS SELECT * FROM users LIMIT #{limit} OFFSET #{(args.offset - 1) * limit}")
### Giving relation back, suitable for find_in_batches
#User.arel_table.name ='users2'
# This changes table name in FROM part of the query
@bonyiii
bonyiii / gist:1901621
Created February 24, 2012 15:24
mysqlreport explanation
Other great tool:
https://launchpad.net/mysql-tuning-primer
Hack MySQL ‹ mysqlreport ‹ Download ‹ Guide › Documentation
Blog Contact Sitemap
This web site is no longer maintained. Read why.
@bonyiii
bonyiii / gist:1891503
Created February 23, 2012 08:20
gentoo KVM
http://en.gentoo-wiki.com/wiki/KVM
http://alanlam.blogspot.com/2011/12/gentoo-guest-using-virtio.html
@bonyiii
bonyiii / gist:1688318
Created January 27, 2012 11:10
diff two string or md5sum from command line input
#http://stackoverflow.com/questions/454427/bash-string-difference
diff <( echo "b27947f3045220faf16e4d9158cbfe13") <( md5sum php-5.2.17.tar.bz2 | cut -d' ' -f 1)
@bonyiii
bonyiii / gist:1652235
Created January 21, 2012 09:58
Painlessly Remove All Ruby Gems
http://geekystuff.net/2009/01/14/remove-all-ruby-gems/