Skip to content

Instantly share code, notes, and snippets.

@namoshizun
namoshizun / regret_matching.py
Created July 14, 2017 01:03
Use regret matching to play rock-paper-scissors
from __future__ import division
from random import random
import numpy as np
import pandas as pd
'''
Use regret-matching algorithm to play Scissors-Rock-Paper.
'''
class RPS:
@MarkTiedemann
MarkTiedemann / power-query-pagination.m
Last active March 1, 2025 00:46
Power Query Pagination Example
let
BaseUrl = "https://fake-odata-api.com/v1/Entities?",
Token = "F4K3-T0K3N-D0NT-U5E-L0L",
EntitiesPerPage = 1000,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
@KodrAus
KodrAus / Profile Rust on Linux.md
Last active August 12, 2024 12:37
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
"""
Azure Table Storage - Python Batching Example
(C) 2016 MediaRealm.com.au
Needs v0.30.0 of the Azure Storage Python SDK
https://github.com/Azure/azure-storage-python/releases/tag/v0.30.0
"""
from azure.storage.table import TableService, Entity, TableBatch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cvan
cvan / HOWTO.md
Last active May 16, 2025 06:07
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@gskema
gskema / convert.php
Created February 4, 2016 12:53
Integer number in Lithuanian words
<?php
/**
* Converts an integer number to a word in Lithuanian language.
*
* @param int $number Integer number to be converted into words
* @param array|bool $units Units array like array(0 => šimtas, 1 => šimtai, 2 => šimtų);
* @param bool $one If false, word "vienas" is omitted
* @return string
*/
@honnibal
honnibal / theano_mlp_small.py
Last active March 1, 2023 15:10
Stripped-down example of Multi-layer Perceptron MLP in Theano
"""A stripped-down MLP example, using Theano.
Based on the tutorial here: http://deeplearning.net/tutorial/mlp.html
This example trims away some complexities, and makes it easier to see how Theano works.
Design changes:
* Model compiled in a distinct function, so that symbolic variables are not in run-time scope.
* No classes. Network shown by chained function calls.
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import rx.*;
import rx.Observable.OnSubscribe;
import rx.Observable;
import rx.exceptions.*;
import rx.internal.operators.*;
import rx.internal.util.RxRingBuffer;
import rx.internal.util.unsafe.MpscLinkedQueue;