Skip to content

Instantly share code, notes, and snippets.

View iboB's full-sized avatar
:shipit:
shipit

Borislav Stanimirov iboB

:shipit:
shipit
View GitHub Profile
public class PalindromeChecker {
public static void main(String[] args) {
String[] sWordsToCheck = new String[] {
"gatemannametag", //p
"abcdefghijklmnopqrtuvwxyz", // not p
"aaaaa1aaaaa", //p
"aaaaa12aaaaa", // not p
};
for(int i=0; i<sWordsToCheck.length; ++i) {
@iboB
iboB / gist:1363574
Created November 14, 2011 09:09
simple ruby timer (for simple programs)
class Timer
def initialize
ObjectSpace.define_finalizer(self,
self.method(:finalize).to_proc)
@start = Time.new
end
def finalize(id)
p "Time: #{Time.now.to_f - @start.to_f} seconds"
@iboB
iboB / main.cpp
Created December 10, 2011 16:32
n-dimensional, generic, compile-time matrix and vector, reusing the same code
#include <iostream>
#include <cassert>
#include <cstring>
#include "nmath.h"
using namespace std;
typedef matrix_nxnt<2, float> matrix2x2;
typedef vector_nt<3, float> vector3;
typedef vector_nt<4, float> vector4;
@iboB
iboB / sandbox.md
Created April 8, 2012 11:14
My md sandbox

Is this code correct? Please explain.

class Test
{
public:
    int *i; <!--- Bobi: I think the star should be with the int -->
    Test()
    {
        i= new int;

}

@iboB
iboB / gist:2459893
Created April 22, 2012 06:03
A way of checking if a class is derived from a template
template <typename A, typename B>
class myclass
{};
template <typename T>
struct is_myclass
{
struct yes { char c; };
struct no { char c[2]; };
@iboB
iboB / gist:5388658
Created April 15, 2013 14:49
product sum solve
class Timer
def initialize
ObjectSpace.define_finalizer(self,
self.method(:finalize).to_proc)
@start = Time.new
end
def finalize(id)
p "Time: #{Time.now.to_f - @start.to_f} seconds"
# c2md - v1.0 - public domain
# authored in 2016 by Borislav Stanimirov
# Used to generate dox files from cpp files
if ARGV.length == 0 || ARGV[0] == '--help' || ARGV[0] == '-?'
puts 'c2md'
puts 'Generate markdown doc from a C-like language'
puts
puts 'Usage:'
// shared_vector.hpp - v1.0.0 - public domain
// authored in 2016 by Borislav Stanimirov / Chobolabs
//
// This is a simple wrapper of std::vector providing a shared vector interface
// The class is basically the same as shared_ptr<std::vector<T>>. It only provides
// methods and operators with the same signature as std::vector so a transition
// could be seemless.
//
//
// VERSION_HISTORY
template <typename T>
struct fast_static
{
// call globally to ensure the constructor is called
static T& slow_get()
{
static T t;
return t;
}

Правила на седмичния конкурс за кодене

  1. В понеделник, който е на ред поства задачка. Такава, която може да се реши за по-малко от половин час.
  2. Който иска да участва, дава решение като отговор на задачата. Един човек може да даде много решения, ако иска. (Принципно може пейст на кода, като коментар, ама по-добре ползвайте ideone или gist или нещо подобно)
  3. Задалият задачката няма право да участва в този кръг.
  4. В неделя, решението с най-много лайкове печели (забележете, че това не е задължително най-бързото, или най-елегантното, или най-краткото решение а най-много провокиралото публиката).
  5. Печелившият от кръга се къпе в гъзария и щастие и за награда измисля и поства задачката за следващата седмица (и си почива).

Мрън-мрън