Skip to content

Instantly share code, notes, and snippets.

View ypetya's full-sized avatar
💭
🚀

Peter Kiss ypetya

💭
🚀
  • Budapest, Hungary
View GitHub Profile
@ypetya
ypetya / gist:169100
Created August 17, 2009 12:27 — forked from anonymous/gist:169097
How not to make a very own pizza if you work at a pizza restaurant
# FIXME: You shouldn't do thatway!
def how_to_make_pizza( components, pizza_size )
components.each do |component|
angle = rand( 2 * Math::PI * 1000 ).to_f / 1000
dist = rand(pizza_size.to_i)
Fan << component.move_to( Position.new( dist * Math.cos( angle ), dist * Math.sin ( angle )).release
end
end
#!/usr/bin/env ruby
require 'rubygems'
gem 'soundcloud-ruby-api-wrapper'
require 'soundcloud'
sc_client = Soundcloud.register
puts 'Enter search, like : fine-cut-bodies or just hit enter! :)'
search = gets.strip
# .irbrc
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
# config.yaml : (Load this into an OpenStruct at the initializers, as usual...)
#
# test_legnths:
# default: 20
# title: 150
# description_in_list: 450
module ApplicationHelper
@ypetya
ypetya / update-alternatives
Created August 10, 2010 09:30
update alternatives ruby versions
# 1.8.7 enterprise ruby
sudo update-alternatives --install /usr/local/bin/ruby ruby /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby 500 --slave /usr/local/bin/erb erb /opt/ruby-enterprise-1.8.7-2010.01/bin/erb --slave /usr/local/bin/gem gem /opt/ruby-enterprise-1.8.7-2010.01/bin/gem --slave /usr/local/bin/irb irb /opt/ruby-enterprise-1.8.7-2010.01/bin/irb --slave /usr/local/bin/rake rake /opt/ruby-enterprise-1.8.7-2010.01/bin/rake --slave /usr/local/bin/rdoc rdoc /opt/ruby-enterprise-1.8.7-2010.01/bin/rdoc --slave /usr/local/bin/ri ri /opt/ruby-enterprise-1.8.7-2010.01/bin/ri --slave /usr/local/bin/testrb testrb /opt/ruby-enterprise-1.8.7-2010.01/bin/testrb
# 1.9.1 ruby
sudo update-alternatives --install /usr/local/bin/ruby ruby /opt/ruby-1.9.1-p378/bin/ruby 400 --slave /usr/local/bin/erb erb /opt/ruby-1.9.1-p378/bin/erb --slave /usr/local/bin/gem gem /opt/ruby-1.9.1-p378/bin/gem --slave /usr/local/bin/irb irb /opt/ruby-1.9.1-p378/bin/irb --slave /usr/local/bin/rake rake /opt/ruby-1.9.1-p378/bin/rake --slave /
@ypetya
ypetya / pomodoro.py
Created November 5, 2011 13:50 — forked from szaboat/pomodoro.py
Pomodoro Timer
import Tkinter
import datetime
import commands
class PomodoroTimer():
"""
Simple pomodoro timer app
"""
def __init__(self):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
private int myVar;
@ypetya
ypetya / gist:1924673
Created February 27, 2012 15:30
samba config
[share]
comment = Share
path = /home/kisp/smb
browseable = true
guest ok = yes
create mask = 0775
directory mask = 0775
follow symlinks = yes
wide links = yes
unix extensions = no
@ypetya
ypetya / .bashrc
Last active December 19, 2015 08:29
ssh Host completion by .ssh/config and known_hosts files in case their exists.
# ssh completion
if [ -f ~/.ssh/config ] ; then
SSH_COMPLETE=( $(grep "^Host " ~/.ssh/config | cut -f2 -d ' ' | sort -u ) )
SSH_COMPLETE=( ${SSH_COMPLETE[*]} $(grep "\w*User " ~/.ssh/config | cut -f2 -d ' ' | sort -u ) )
fi
if [ -f ~/.ssh/known_hosts ] ; then
SSH_COMPLETE=( ${SSH_COMPLETE[*]} $(cut -f1 -d' ' ~/.ssh/known_hosts | cut -f1 -d',' | sort -u ))
fi
complete -o default -W "${SSH_COMPLETE[*]}" ssh
complete -o default -W "${SSH_COMPLETE[*]}" scp
@ypetya
ypetya / .bashrc
Created September 29, 2013 13:11
Created this 'ln' function into my .bashrc, it emulates a 'cp' call instead of the real 'ln -s' which is not supported on windows MinGw.
function ln() {
echo "WARNING! 'ln' is an unsupported command on this platform."
echo " * The following command was called:"
echo "ln $@"
if [ $1 = "-s" ] ; then
echo " * Trying to translate it to a simple copy command : "
COMMAND="cp -R $2 $3"
echo "$COMMAND"