Skip to content

Instantly share code, notes, and snippets.

#ifndef LINKEDTABLE_H_INCLUDED
#define LINKEDTABLE_H_INCLUDED
//--- includes
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#ifdef HAS_OGL
#include <GL\glew.h>
@jaen
jaen / gist:3863583
Created October 10, 2012 06:56
UJS problem
# _share.html.haml button
= form_tag(public_memo_path(@memo), :remote => true, :style => 'margin-bottom: 5px;') do
= submit_tag "Make #{@memo.public? ? 'private' : 'public'}", :id => "make_public_button", :class=>"simple #{@memo.public? ? 'redish' : 'blue'} floatright", :disable_with => "Changing status..."
# memo_controller.rb, public action
def public
@memo = Memo.find(params[:id])
authorize! :share, @memo
@jaen
jaen / gist:3926212
Created October 21, 2012 07:10
Stylus support for Middleman
require "stylus"
module Middleman
module Renderers
# Sass renderer
module Stylus
# Setup extension
class << self
# Once registered
def registered(app)
@jaen
jaen / crude-bot.clj
Created December 16, 2012 22:16
Crude Clojure LISP bot using Aleph.
(ns jaen-bot.core
(:use [lamina.core]
[aleph.tcp]
[gloss.core]
[clojure.java.io])
(:require [net.cgrand.regex :as r]
[clojure.string :as s]
[cheshire.core :as json]))
(def config (atom {}))
@jaen
jaen / gist:5024965
Created February 24, 2013 18:36
Awfully dumb ruby 4chan downloader. Does the job though.
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
BASE_PAGE_URL = ARGV[0]
LAST_PART_REGEXP = /\/([^\/]+)$/
BASE_DIR = LAST_PART_REGEXP.match(BASE_PAGE_URL)[1]
`mkdir #{BASE_DIR}`
@jaen
jaen / struts.rb
Created March 29, 2013 18:46
My xmonad config
# conky bar bottom
gap_y -1000
#background yes
double_buffer yes
out_to_console yes
own_window yes
own_window_type override
[jaen@yuuki rust_tmp]$ for i in 1 2 3 4 5; do ./hello & done
[1] 23437
[2] 23438
[3] 23439
[4] 23440
[5] 23441
hello?
hello?hello?
hello?
@jaen
jaen / gist:5331133
Created April 7, 2013 16:14
rustc weirdness
fn sum(a: int, b: int) -> int { a + b }
fn main() {
let a = |x:int| { |y:int| -> int { x + y } };
let b = a(2);
io::println(int::to_str(sum(2, 3)));
io::println(int::to_str(a(2)(3)));
io::println(int::to_str(b(3)));
}
@jaen
jaen / my_if.rb
Last active December 21, 2015 15:29
Rant. About metaprogramming. In polish.

Troszkę wykręcasz moje słowa - powiedziałem quote, większość języków, unquote.

Dla przykładu w TIOBE top 20 takie rzeczy potrafią LISP, Ruby no i może Python (nie jestem guru Pythonowym co prawda, ale zawsze ichniejsze meta wydawało mi się słabsze niż Rabiowe).
Z mniej mainstreamowych, ale nadal rozsądnie popularnych języków ostatnio dodali to do Scali, jest Template Haskell, jest Clojure (ale to akurat LISP).
I to chyba tyle, bo tych całkiem niszowych wymieniać teraz nie będę (ale pewnie z 10 na rozsądnym poziomie ewolucji by się znalazło).

Tak czy siak - każ coś takiego zrobić Javie albo C++ to się posra, which is precisely my point. Wróć, przy C++ to programista się posra próbując wykombinować coś szablonami ; D


defmodule Test do
def sum(list), do: _sum(list, 0)
defp _sum([], acc), do: acc
defp _sum([x|xs], acc), do: _sum(xs, acc+x)
def max(list), do: _max(list, Enum.first(list))
defp _max([], max), do: max
defp _max([x|xs], max)