Skip to content

Instantly share code, notes, and snippets.

If you've downloaded Eclipse from their official website, follow these steps for the installation.
Extract the eclipse.XX.YY.tar.gz using
tar -zxvf eclipse.XX.YY.tar.gz
Become root.
sudo -i
Copy the extracted folder to /opt
@epson121
epson121 / download_imgur_album.rb
Last active August 29, 2015 13:56
Download imgur album from command line
require "rubygems"
require "json"
require "net/http"
require "uri"
require 'open-uri'
uri = URI.parse(ARGV[0] + ".json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
class MultiplicationTable {
public static void main(String[] args) {
//rows
int m = Integer.parseInt(args[0]);
//columns
int n = Integer.parseInt(args[1]);
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
System.out.print(String.format("%4d", i*j));
class ReverseString {
public static void main(String[] args) {
int last = args[0].length()-1;
char[] chars = args[0].toCharArray();
for (int i = 0; i < args[0].length()/2; i++) {
char temp = chars[i];
chars[i] = chars[last];
chars[last--] = temp;
@epson121
epson121 / bf.rb
Created September 30, 2013 19:28
Write a program which performs brute force letter combination until the word “password” is found. The program should print every letter combination (lowercase or uppercase, it doesn't matter) in alphabetic order. It must start with a and the last printed combination should be password.
# v1:
("a".."password").to_a.join(" ")
# v2:
?a.upto('password').to_a.join(" ")
@epson121
epson121 / gen.rb
Created August 31, 2013 22:24
Calculation for civil engineering task of vehicle performance. (in Croatian)
res = []
8.times do
res << [rand(7..10), rand(3..4), rand(3..6), rand(2..4)]
end
14.times do
res << [rand(11..20), rand(5..7), rand(3..4), rand(3..4)]
end
2.times do
@epson121
epson121 / Palantir.java
Last active December 14, 2015 21:59
Variable-Base Expression Evaluation http://www.palantir.com/challenge/
/*
You've woken up one day to find that everyone suddenly expresses numbers in different number bases. You're seeing prices in octal and phone numbers in hexadecimal. It's a numerical Tower of Babel! For your own sanity, you decide to program a simple mathematical expression evaluator that can handle numbers in different number bases. It should support addition, subtraction, and multiplication, should respect order of operations, and should handle number bases between 2 and 16.
While your language of choice may directly support expression evaluation, please create your own.
The input on stdin is a mathematical expression on a single line. Number constants are expressed like "123_4", which is "123" in base 4, which is 27 in base 10. Some digits in the higher bases will be represented with uppercase letters. Numbers within the expression will always be non-negative integers. The operators will be +, -, and *. Whitespace should be ignored.
Your program should emit to stdout a single base-10 number with no und
@epson121
epson121 / bs_tree_size.cpp
Created February 23, 2013 10:49
BS-tree size solved with and without additional memory.
/*
* BS-tree size solved with and without additional memory.
*
*/
#include <iostream>
#include <cstdlib>
using namespace std;
@epson121
epson121 / tree_traversal.cpp
Last active December 14, 2015 03:09
tree traversal algorithms
/*
* Simple tree traversal algorithms (preorder, inorder and postorder)
* on a small binary tree with 5 nodes.
*
*/
#include <iostream>
#include <cstdlib>
using namespace std;
@epson121
epson121 / rot_13.rb
Last active December 11, 2015 10:28
'''
Rot13 implementation in ruby
21.01.2013.
'''
def a(s)
s.tr("A-MN-Z","N-ZA-M")
end
p a("ASDDSAZZZ")