Skip to content

Instantly share code, notes, and snippets.

@nagisa
nagisa / output
Last active August 29, 2015 14:11
Rust being slower when optimised?
$ rustc slower.rs --test -C no-stack-check -O
$ ./slower --bench
running 1 test
test bench_stdrng_u64 ... bench: 187 ns/iter (+/- 14) = 42 MB/s
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
$ rustc slower.rs --test -C no-stack-check
$ ./slower --bench
-- tagsoup 0.13.1 package, ghc 7.8.2
*Main> :m +Text.HTML.TagSoup
*Main Text.HTML.TagSoup> :t renderOptions { optEscape = id, optMinimize = const True, optRawTag = const True }
<interactive>:1:1:
No instance for (Text.StringLike.StringLike t0)
arising from a use of ‘renderOptions’
The type variable ‘t0’ is ambiguous
Note: there are several potential instances:
instance Text.StringLike.StringLike
# Getting the git version of pacaur
amebox :: ~/d/test
𝛌pacaur -S pacaur-git
:: Package(s) pacaur-git not found in repositories, trying AUR...
:: resolving dependencies...
:: looking for inter-conflicts...
:: pacaur-git and pacaur are in conflict. Remove pacaur? [y/N] y
AUR Packages (1): pacaur-git-latest
(22:22:13) bz: simukis_: max-content can't depend on content height
(22:22:25) bz: simukis_: so can't depend on whether there is a vertical scrollbar
(22:22:57) bz: simukis_: there is no way to win there: either you get a gap or a horizontal scrollbar. :(
(22:23:30) bz: simukis_: I _think_ for overflow-y:scroll we include the vertical scrollbar width and for overflow-y:auto we do not or something like that
(22:24:15) simukis_: bz: but then scrollbar would be visible on short content as well which is undesirable in many cases.
(22:25:00) simukis_: I suspect a lot of people will complain about that in the future.
(22:25:30) bz: simukis_: there's just no sane way to make this work
(22:26:29) bz: simukis_: "people" have contradictory requirements
(22:26:37) bz: simukis_: So life is bad for someone sometime.
@nagisa
nagisa / gist:5019206
Last active December 14, 2015 03:09
For people who want to sort items in hakyll by time in metadata
sortOnM :: (Monad m, Ord k) => (a -> m k) -> [a] -> m [a]
sortOnM f xs = liftM (map fst . sortBy (comparing snd)) $
mapM (\x -> liftM (x,) (f x)) xs
chronologicalMeta :: [Item a] -> Compiler [Item a]
chronologicalMeta = sortOnM $ getItemUTC defaultTimeLocale . itemIdentifier
recentFirstMeta :: [Item a] -> Compiler [Item a]
recentFirstMeta i = return . reverse =<< chronologicalMeta i
Mažesnis feature barjeras.
Pavyzdžiui į aštuonioliktą versiją įkišo naują JS engine ir netoli matosi Australis tema.
Jei būtų versijuojama ankstesniu principu, Mozilla release team'as būtų ko gero liepȩs
laukti kol abu fyčersai bus paruošti kad būtų galima viską išleisti vienu major releasu.
O dabar fyčersai ateina kada jie būna paruošti ± 2 mėn.
@nagisa
nagisa / gist:4972837
Last active December 13, 2015 20:48
Hyphenation of words in hakyll
import Text.Hyphenation (hyphenate, english_GB)
import Text.Pandoc (bottomUp, Pandoc)
import Text.Pandoc.Definition
------------------------------------------------------------
hyphenatePandoc :: Pandoc -> Pandoc
hyphenatePandoc = bottomUp (hyphInline :: Inline -> Inline)
where hyphW = intercalate "\x00AD" . hyphenate english_GB
hyphWs = unwords . map hyphW . words
hyphInline (Str str) = Str $ hyphWs str
hyphInline a = a
entryListing :: Context a -> [Item a] -> Compiler String
entryListing ctx entry = do
entryItemTpl <- loadBody "templates/entry-item.html"
applyTemplateList entryItemTpl ctx entry
makePostList ctx = makeItem ""
>>= loadAndApplyTemplate "templates/entries.html" ctx
>>= loadAndApplyTemplate "templates/base.html" ctx
>>= relativizeUrls
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <time.h>
#define USER_ACTIVE 1
#define USER_SUSPENDED 0
typedef struct book {

Ponas Jonas šiaurės Amerikoje augina tigrus. Tigrai yra tvarkingi gyvūnai ir reprodukciją atlieka privačiai. Jonas žino kokia tvarka nori suporuoti gyvūnus (jis net būsimų tigriukų vardus žino!), tačiau jo sąrašas buvo rastas visiškai išdarkytas. Jonui atgauti duomenis iš sąrašo pavyko, tačiau pamesta eilės tvarka. Jonas pasisamdė šaunųjį programuotoją Vytautą, kad tas jam padėtų vėl viską surikiuoti.

Pradiniai duomenys

Faile yra keletas <eilė> <patelės vardas> <patino vardas> <būsimas tigriuko vardas> eilučių. Paprastumo dėlei sakykime, kad vietoje vardo – tik inicialai (t.y. pirma vardo raidė).

========== Rezultatai