Skip to content

Instantly share code, notes, and snippets.

@mingan
mingan / bem.js
Created May 15, 2015 06:28
react-bem-helper wrapper to not use any prefix by default
import BEM from 'react-bem-helper';
import _o from 'lodash/object';
export default function (blockName, opts = {}) {
const def = {
name: blockName,
prefix: null
};
return new BEM(_o.merge(def, opts));
}
@mingan
mingan / extract.js
Created September 20, 2014 17:04
Simple jQuery code to extract basic information from ArchDaily (http://www.archdaily.com/tag/vienna) to CSV
data = []
$('#st1>div').each(function (i, div) {
project = {};
$link = $(div).find('h3 a');
project['url'] = $link.attr('href');
project['name'] = $link.text();
$specs = $(div).find('.specs')
if ($specs.length) {
specs = $specs.text();
# Per-category pagination. Useful for multilingual blogs =)
# It will react, regarding your configuration in `config.yml`:
#
# paginate_per_category: true|false - activate this pagination or keep the
# default one
# default_category: "en" - determine the default category if you
# wish the root pagination to be this one
module Jekyll
module Paginate
class Pagination < Generator
<Aggregate type="min" required="true">
<Compare metric="inequality" required="false">
<Input path="?a" />
<Input path="?b" />
</Compare>
<Aggregate type="average">
<Compare metric="equality" required="true">
<TransformInput function="lowerCase">
<TransformInput function="removeSpecialChars">
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:adms="http://www.w3.org/ns/adms#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:gr="http://purl.org/goodrelations/v1#"
xmlns:irw="http://www.ontologydesignpatterns.org/ont/web/irw.owl#"
xmlns:org="http://www.w3.org/ns/org#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:s="http://schema.org/"
@mingan
mingan / foaf+schema.org.html
Created October 22, 2012 14:13
Satisfy Google Rich Snippets "Person" standard using FOAF?
<div id="me" vocab="http://xmlns.com/foaf/0.1/" prefix="v: http://rdf.data-vocabulary.org/#" typeof="Person v:Person" resource="http://carlboettiger.info#me">
<p>
<img property="depiction" src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger" style="float: right; margin: 10px 10px"/> I am
<a property="homepage v:url" href="http://carlboettiger.info">
<span property="name v:name">
<span property="firstName v:givenName">Carl
</span>
<span property="lastName v:familyName">Boettiger
</span>
</span></a>,
def countChange (money: Int, coins: List[Int]): Int = {
def count(money: Int, coins: List[Int]): Int = {
if (coins.tail.isEmpty) {
if (money % coins.head == 0) 1
else 0
}
else if (money == 0) 1
else if (money < coins.head) count(money, coins.tail)
else count(money - coins.head, coins) + count(money, coins.tail)
@mingan
mingan / stats.sql
Created June 6, 2012 15:21
Players' stats
SELECT
`Division_i18n`.`content` AS `Division__name`,
`TeamInfo`.`id`,
`TeamInfo`.`name`,
`Player`.`id`,
`PlayerInfo`.`name`,
`PointsSummary`.`matches`,
`PointsSummary`.`points`,
`PunishmentsSummary`.`punishment_type_id`,
`PunishmentsSummary`.`count`
@mingan
mingan / saveToXml.php
Created April 25, 2012 19:39
Uložení $_POST do XML
<?php
// jsou odeslaná data POSTem
if (!empty($_POST)) {
$filename = dirname(__FILE__) . 'mujxmlsoubor.xml';
// načte soubor, musí existovat!
$xml = simplexml_load_file($filename);
// kořenovému elementu přidá nový element record
$record = $xml->addChild('record');
@mingan
mingan / gist:1276469
Created October 10, 2011 20:43 — forked from goldfish01/gist:1276446
Martiny úkol
public class Vysledek
{
//== Datové atributy (statické i instancí)======================================
private Tym domaci;
private Tym hoste;
private int kolo;
private String datum;
private int domaciGolu;
private int hosteGolu;
private boolean prodlouzeni;