Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

require "JSON"
def get_json(url)
print "Fetching `#{url}`... "
result = `curl -s "#{url}"`
puts "DONE"
JSON.parse(result, :symbolize_names => true)
end
def get_tags(image)
Reflections reflections = new Reflections("pl.edu.polsl.labjava");
commandMap = new TreeMap<String, Class<? extends Command>>();
Set<Class<? extends Command>> commandClasses = reflections.getSubTypesOf(Command.class);
commandClasses.stream()
.map((Function<Class<? extends Command>, KeyValue<String, Class<? extends Command>>>) (commandClass -> {
String commandName;
try {
╭─jaen@yuuki /mnt/media/steam-library/SteamApps/common/Natural Selection 2 ‹2.0.0-p247›
╰─$ LOCALE=en_US.UTF-8 ~/.steam/bin32/steam-runtime/run.sh primusrun ./ns2_linux32
GetInstanceCount currently unimplemented
Build 261
Linux
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 78: saw unknown, expected number
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
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)
@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


@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@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 / 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
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 / 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 {}))