Skip to content

Instantly share code, notes, and snippets.

View pewniak747's full-sized avatar

Tomasz Pewiński pewniak747

View GitHub Profile
#!/usr/bin/ruby
# tweet is a script that allows you to update
# your twitter status using shell
# written by Tomasz 'pewniak747' Pewiński
# pewniak747@gmail.com
def exp_value input
input[input.index("=")+1, input.size].strip
end
/* classic boyer_moore find algorithm
* by pewniak747@gmail.com */
#include<iostream>
int boyer_moore(std::string input, std::string pattern) {
int index = 0;
int input_length = input.size()-1;
int pattern_length = pattern.size()-1;
int last[255];
#include<iostream>
int main() {
int data[100][2];
int p[100];
int howmany, mass;
std::cin >> howmany >> mass;
for(int i=0; i<=mass; i++) p[i] = 0;
#include <iostream>
#include <vector>
int main() {
int szala1, szala2 = 0;
long mnoznik = 1;
std::vector<int> s1, s2;
std::cin >> szala1;
while(szala1 != szala2) {
if((szala1%3+1)%3+1 == (szala2%3+1)%3) {
@pewniak747
pewniak747 / post-receive-pivotal
Created April 10, 2012 15:57
git post-receive pivotal hook
#!/usr/bin/env ruby
# encoding: UTF-8
require 'net/http'
require 'nokogiri'
class GitLogs
attr_accessor :raw_log, :logs
def initialize old_ref, new_ref
self.raw_log = `git log --no-color --format=short #{old_ref}..#{new_ref}`.force_encoding('utf-8')
@pewniak747
pewniak747 / gist:2780469
Created May 24, 2012 09:36
capybara subdomains helper
Capybara.javascript_driver = :webkit
Capybara.server_port = 7171
def with_subdomain subdomain
old_subdomain = Capybara.app_host
Capybara.app_host = "http://#{subdomain}.localhost.dev:7171"
yield
ensure
Capybara.app_host = old_subdomain
end
@pewniak747
pewniak747 / proxy.pac
Created July 4, 2012 07:31
proxy autoconfiguration
if (shExpMatch(host, "*.dev")) {
return "PROXY localhost:3000";
}
if (shExpMatch(host, "*.dev2")) {
return "PROXY localhost:3001";
}
if (shExpMatch(host, "*.dev3")) {
return "PROXY localhost:3002";
}
function Lagrange (n : Integer;
var x,f : vector;
xx : Extended;
var st : Integer) : Extended;
{---------------------------------------------------------------------------}
{ }
{ The function Lagrange calculates the value of a polynomial given by }
{ Lagrange's interpolation formula. }
{ Data: }
{ n - number of interpolation nodes minus 1 (the degree of polynomial }
function Neville (n : Integer;
x : vector;
xx : Extended;
var f : vector;
var st : Integer) : Extended;
{---------------------------------------------------------------------------}
{ }
{ The function Neville calculates the value of interpolating polynomial by }
{ Neville's algorithm. }
{ Data: }
config.around(:each) do |example|
Timecop.freeze if freeze_time?
example.run
Timecop.return if freeze_time?
end
def freeze_time?
example.metadata[:freeze_time]
end