Skip to content

Instantly share code, notes, and snippets.

View madfriend's full-sized avatar

Alex Chuchunkov madfriend

  • Yandex, OpenCorpora
  • St. Petersburg, Russia
View GitHub Profile
(function() {
var id_counter = 1;
Object.defineProperty(Object.prototype, "__uniqueId", {
writable: true
});
Object.defineProperty(Object.prototype, "uniqueId", {
get: function() {
if (this.__uniqueId == undefined)
this.__uniqueId = id_counter++;
return this.__uniqueId;
@madfriend
madfriend / data.csv
Last active August 29, 2015 14:07 — forked from gencay/data.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 10 columns, instead of 6. in line 4.
Stage, Ref L max, Ref L avg, Ref D max, Ref D avg, MT L max, MT L avg, MT D max, MT D avg,
Role id, 0.959, 0.803, 0.778, 0.582, 0.956, 0.795, 0.667, 0.501,
Role class, 0.862, 0.715, 0.574, 0.466, 0.881, 0.721, 0.525, 0.434,
Actions, 0.979, 0.821, 0.917, 0.650, 0.971, 0.839, 0.700, 0.577,
Actions align, 0.908, 0.737, 0.429, 0.332,
Role align, 0.709, 0.523, 0.378, 0.266,
import glob
index = dict()
for (i, filename) in enumerate(glob.glob('collection/*.txt')):
print "%d %d" % (len(index.keys()), i)
with open(filename) as f:
for line in f:
words = line.strip().split(' ')
for word in words:
try:
index[word] += 1
start: program;
program: outer_block*;
outer_block: (outer_line NEWLINE)*
outer_line?;
@outer_line: initialization
| assignment
';';
assignment: name '='
@madfriend
madfriend / be.html
Last active August 29, 2015 14:18
be with m decoupled
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BE with M decoupled</title>
</head>
<body>
<div class="container">
<div class="new-label-form is-hidden">
<h2 class="new-label-form--title">
@madfriend
madfriend / snip.js
Created September 10, 2015 21:11
my jquery snippets
$.fn.mapGetter = function(prop) {
return $(this).map(function(i, e) {
return $(e).attr(prop);
}).get();
};
$.fn.filterByAttr = function(attr, val) {
return $(this).filter(function(i, e) {
return $(e).attr(attr) == val;
});
@madfriend
madfriend / lazystring.php
Created March 15, 2012 20:08
Lazy Strings class
<?php
// accepts default string and test function.
// test function is tweaked everytime object of class LazyStrings is casted to string,
// if test function returns FALSE/NULL default string is returned, otherwise the result of
// test.
class LazyString {
private $_default, $_tweak;
def isPalindrome(word):
if len(word)<2:
return boolean(word)
return (word[0] is word[-1]) ? IsPalindrome(word[1:-2]) : False
@madfriend
madfriend / gist:2704897
Created May 15, 2012 20:31
How to treat the most stupid thing in PHP
<?php
// Assume this function definition:
function foo($bar, $baz = 'qux') {
return $bar.$baz;
}
// Oh crap, something went wrong, and we call it without arguments:
$foo = foo();
CMS:
Database configurator: Propel (http://www.propelorm.org/), only migrations?
Model: Paris (https://github.com/j4mie/paris)
Controller: own, with given tools
Router: Klein (https://github.com/chriso/klein.php)
Packaging: Composer
View: Twig vs Smarty
User management: ??
Application: ??