Skip to content

Instantly share code, notes, and snippets.

View jiripospisil's full-sized avatar
🦖

Jiri Pospisil jiripospisil

🦖
View GitHub Profile
@jiripospisil
jiripospisil / merge_sort.cc
Created October 26, 2013 20:44
So awesome!
// Author: Stephan T. Lavavej
// Code for "Stephan T. Lavavej - Core C++, 8 of n" from Channel 9 Videos
#include <iostream>
#include <array>
#include <climits>
using namespace std;
template<int... Vals>
#include <boost/format.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <iostream>
namespace
{
namespace b = boost;
typedef b::adjacency_list<b::vecS, b::vecS, b::undirectedS, b::no_property,
@jiripospisil
jiripospisil / kk.cc
Created November 11, 2013 13:53
Fibonacci numbers using gmp
#include <iostream>
#include <gmpxx.h>
int main(int argc, const char** argv)
{
mpz_class res;
mpz_fib_ui(res.get_mpz_t(), 20e6);
std::cout << res.get_str(10) << std::endl;
return 0;
}
#include <iostream>
template<typename T>
struct type_trait
{
template<typename U>
struct pointer_trait
{
enum { result = false };
};
package main
import (
"encoding/json"
"log"
"net/http"
"runtime"
)
type Article struct {
@jiripospisil
jiripospisil / app.js
Created June 7, 2013 08:57
Ember.js: Resolve templates using ajax
App = Ember.Application.create({
resolver: Ember.DefaultResolver.extend({
resolveTemplate: function (parsedName) {
var template = this._super(parsedName);
if (!template) {
var templateName = parsedName.fullNameWithoutType.replace(/\./g, "/"),
filePath = "/assets/templates/" + templateName + ".js";
$.ajax({
App.Auth = Ember.Auth.create({
// ...
modules: ["emberModel"]
});
fac :: Int -> Int
fac 0 = 1
fac n = n * fac(n - 1)
-- fac 100 => 0
func offset(tz string) int {
if seconds, ok := timeZone[tz]; ok {
return seconds
}
log.Println("unknown time zone:", tz)
return 0
}
package main
import "fmt"
type Opicak struct {
Name string
Age int
}
func (b Opicak) PrettyName() string {