Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / modal-ajax.coffee
Last active August 29, 2015 13:56
Bootstrap-modal with ajax links. Just put class js-modal on links. All links inside that modal and the form are submitted remotly
$ ->
$(document).on 'click', '.js-modal, #js-modal .modal-body a', (e)->
return true if $(this).data('toggle')
e.preventDefault()
modal = """
<div class='modal fade container' id='js-modal' role="dialog" >
<div class='no-modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@zealot128
zealot128 / db.rb
Last active August 29, 2015 13:57
ActiveRecord Sqlite auto connection + migration without Rails in one file (AR 4)
require 'active_record'
require 'fileutils'
ActiveRecord::Base.logger = Logger.new(STDERR)
db = "db/#{ENV['RACK_ENV']}.sqlite3"
if not File.exists? db
`sqlite3 #{db} '' `
end

Keybase proof

I hereby claim:

  • I am zealot128 on github.
  • I am stefanwienert (https://keybase.io/stefanwienert) on keybase.
  • I have a public key whose fingerprint is DB9A C627 56EF 892A 35D9 727E 2630 9489 C29F E67F

To claim this, I am signing this object:

@zealot128
zealot128 / README.md
Created October 18, 2011 08:08
pludoni Capistrano Deploy script

USAGE

cap deploy:setup
# will create shared dir's and symlinks for assets
#  db, log and "public/system"
cap deploy
# Let's go
@zealot128
zealot128 / README.md
Created December 16, 2011 21:21
Ruby - HTML Tagcloud with easy changeable formular

Tagcloud Calculation

Usage

Calculate weight of given array. e.g. %w[ruby ruby ruby rails]

Tagcloud.tagcloudize [ "rails", "ruby", "rails" ...] do |count,max|
@zealot128
zealot128 / README.md
Created December 16, 2011 21:55
Easy XML Sitemap with rails (little work involved anyway)

Sitemap XML with Rails

Rails is too custom, to provide a generic sitemap as a gem for any situation. But it ist not too hard anyway! Here is a frame how to make one:

rails g controller sitemap
@zealot128
zealot128 / drush.sh
Created March 12, 2012 23:47
Drupal 7 Installation with compass configuration
# Download latest Drupal
version="7.12"
wget http://ftp.drupal.org/files/projects/drupal-$version.tar.gz
tar xf drupal-$version.tar.gz
mv drupal-$version/.* . -f
mv drupal-$version/* .
rm drupal-$version.tar.gz -rf drupal-$version
rm *txt -f
wget http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.11.de.po -O profiles/standard/translations/drupal-7.11.de.po
chown www-data\: sites/default/ -R
@zealot128
zealot128 / download_file.rb
Created July 22, 2012 16:21
Download an URL with open-uri to paperclip
# encoding: utf-8
def download_url(url)
url.gsub!(" ","%20")
# TODO better escaping of stuff like umlauts
# url.gsub!("ö","%C3%B6")
logo_path = url.split("/").last
io = open(url)
io.define_singleton_method(:original_filename) do
logo_path
@zealot128
zealot128 / config.rb
Created November 28, 2012 21:11
Earthquake - Show replies to a tweet
# paste into ~/.earthquake/config
Earthquake.init do
command :replies do |m|
thread = [twitter.status(m[1])]
r = twitter.get "/related_results/show/#{273873995647045633}.json"
results = r.first["results"].map{|i|i["value"]}
results.reverse_each.with_index do |t,i|
t["_mark"] = config[:thread_indent] * i
@zealot128
zealot128 / README.md
Last active November 11, 2015 10:50
Favicon generation + Example integration in rails view

Needs imagemagick + pngquant

  • put a high res (at least 310x310) favicon_logo_big.png in the same folder as source.sh,
  • run it bash source.sh
  • move the bunch into your assets folder, e.g. app/assets/images/favicons
  • See the attached application.slim for example on how to link it.