Skip to content

Instantly share code, notes, and snippets.

View jandudulski's full-sized avatar

Jan Dudulski jandudulski

View GitHub Profile
#!/usr/bin/env ruby1.9.1
# coding: utf-8
if ARGV.empty?
STDERR.puts "Usage: fajrant hours"
exit(-1)
end
begin
hours = Integer(ARGV[0])
@jandudulski
jandudulski / charazay
Created October 28, 2010 13:03
na początek. mechanize rox!
#!/usr/bin/env ruby1.9.1
# encoding: utf-8
require 'rubygems'
require 'nokogiri'
require 'mechanize'
def get_password
puts "Password please:"
system "stty -echo"
git config --global alias.suck pull
git remote add my url
git branch dick
`git suck my dick` command (almost) ready to use!
@jandudulski
jandudulski / form.html
Created June 14, 2011 09:48
RangeDatepicker
<form id="search" data-range="1" data-offset="5">
<div class="wrapper">
<label>
First date:
<input type="text" value="" class="calendar first" readonly="readonly" />
</label>
<input type="hidden" value="" name="day" data-type="day" />
<input type="hidden" value="" name="month_1" data-type="month" />
</div>
<div class="wrapper">
@jandudulski
jandudulski / o.rb
Created July 21, 2011 15:29
Open tweet in a browser (Earthquake.gem plugin)
Earthquake.init do
command :o do |m|
begin
tweet = twitter.status(m[1])
browse "https://twitter.com/#{tweet['user']['screen_name']}/status/#{m[1]}"
rescue
puts 'invalid input'
end
end
end
@jandudulski
jandudulski / strem_notifier.rb
Created October 19, 2011 13:45
Stream notifier for earthquake
# coding: utf-8
Earthquake.init do
output do |item|
if item["_stream"] && item["text"]
notify item["text"], title: "#{item["user"]["name"]} (#{item["user"]["screen_name"]})"
end
end
end
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@jandudulski
jandudulski / post-update
Created November 2, 2011 13:11
post-update hook which deploy on server when pushed changes to live branch
#!/bin/sh
branch=$(git rev-parse --symbolic --abbrev-ref $1)
if [ $branch == "live" ]
then
echo
echo "**** Pulling changes into live server ****"
echo
@jandudulski
jandudulski / ajax_rails.haml
Created June 29, 2012 17:01
Reinvet the wheel
# Instead of:
= link_to 'Fajne', fajny_path, id: 'fajny-url'
:javascript
$('#fajny-url').on('click', function() {
$.ajax('jakis/path', {
...
}).done(function(data) {
$('gdzieś').html(data);
class PhotosController < ApplicationController
before_filter :authenticate_user!
def create
current_user.photo = params[:file] || params[:qqfile]
data = if current_user.save
{
:success => true,
:photo => {