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
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.
@zealot128
zealot128 / README.md
Last active December 27, 2015 21:49
watermark imagemagick - add transparent png to all images in a folder as percentage width of the original

Image magick Watermark example

Create a watermark image, should be transparent background. watermark.png

Run script in the folder where all jpgs are located:

cd someproductimages
bash ../watermark.sh
...
@zealot128
zealot128 / README.md
Created January 10, 2016 11:41
OSM local download

Downloads Tiles with a radius of 10 tiles around the given lat//lon/zoom.

Useful for small landing pages where you only want to display the company's location in a Leaflet without querying OSM, which might be slow or not support SSL.

@zealot128
zealot128 / hotfix.yml
Created January 16, 2016 21:57
Ansible: quickly disable ssh roaming + upgrade ssh-server + openssl for all your servers
---
# Disable roaming for all servers, upgrade ssh-server + openssl
# you can test with: ssh whoami.filippo.io
# run with: ansible-playbook -i YOURINVENTORY hotfix.yml
- hosts: all
tasks:
- lineinfile:
insertafter: 'Host *'
line: ' UseRoaming no'
dest: '/etc/ssh/ssh_config'
@zealot128
zealot128 / convert.rb
Created May 12, 2016 07:19
recode all videos in current folder with ffmpeg (decreasing filesize by up to 80%)
# can also be *.flv or *.wmv etc.
files = Dir['*.mp4']
# min size
mb = 10
def size_mb(file)
(File.size(file).to_f / 1024 / 1024).round
@zealot128
zealot128 / ffmpeg_scripts.sh
Last active March 29, 2019 17:23
ffmpeg scripts
# Screencast on OSX
ffmpeg -r 30 -f avfoundation -capture_cursor 1 -capture_mouse_clicks 1 -i "1:0" out2.mp4
# Framerate 30
# Cursors + Clicks
# "1:0" -> first screen and microphone
# list all devices for above
ffmpeg -f avfoundation -list_devices true -i ""