This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| $ time ./NR.exe | |
| 21081852648,717 | |
| real 0m2.887s | |
| user 0m0.015s | |
| sys 0m0.000s | |
| */ | |
| using System; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Author: Raynor Vliegendhart | |
| # LICENSE: MIT | |
| def multirater_kfree(n_ij, n, k): | |
| ''' | |
| Computes Randolph's free marginal multirater kappa for assessing the | |
| reliability of agreement between annotators. | |
| Args: | |
| n_ij: An N x k array of ratings, where n_ij[i][j] annotators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class ClosureExample { | |
| public static void main(String[] args) { | |
| List<Runnable> actions = new ArrayList<>(); | |
| for (int i = 0; i < 10; i++) { | |
| final int j = i; | |
| actions.add(new Runnable() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| from time import time | |
| class Benchmark(): | |
| def __init__(self, message, stdout=sys.stdout, prefix='', silent=False, parallel=False): | |
| self.message = message | |
| self.stdout = stdout | |
| self.prefix = prefix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compute_perm_mapping(from_list, to_list): | |
| index = {} | |
| if len(from_list) == len(to_list): | |
| for i, x in enumerate(to_list): | |
| index.setdefault(x, []).append(i) | |
| try: | |
| mapping = [index[x].pop(0) for x in from_list] | |
| except (KeyError, IndexError) as _: | |
| raise ValueError('from_list is not a permutation of to_list') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PowerShell V4 | |
| param( | |
| [String]$VideoId | |
| ) | |
| [String]$gdata_uri = "http://gdata.youtube.com/feeds/api/videos/$VideoId" | |
| $metadata = irm $gdata_uri | |
| $duration = $metadata.entry['media:group']['yt:duration'].seconds | |
| echo $duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- convoluted FizzBuzz | |
| import Data.Monoid | |
| import Data.Function (on) | |
| every :: Int -> a -> [Maybe a] | |
| every n x = cycle (replicate (n-1) Nothing ++ [Just x]) | |
| fizzbuzz :: [String] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DOC=your_main_tex_file # without extension! | |
| BIB=${DOC} | |
| # default render options (also see .tex example): | |
| RENDER=rendertwocol | |
| OUTPUT_SUFFIX=_2col | |
| LATEX_CODE=\\def\\${RENDER}{1} \\input{${DOC}} | |
| TMP_DIR=tmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Simple example to log into Paypal (far from feature complete) | |
| # Requires: Firefox installed on machine | |
| import getpass | |
| from selenium import webdriver | |
| from selenium.webdriver.common.keys import Keys | |
| LOGIN_URL = 'https://www.paypal.com/signin/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; AutoHotkey script for adding shortcuts for volume and next/prev controls | |
| ; using the Win (#), shift (+) and PgUp/PgDn keys: | |
| #PgUp::Send {Volume_Up 3} | |
| #PgDn::Send {Volume_Down 3} | |
| #+PgDn::Send {Media_Next} | |
| #+PgUp::Send {Media_Prev} |