Skip to content

Instantly share code, notes, and snippets.

View aliostad's full-sized avatar
I may be slow to respond.

Ali Kheyrollahi aliostad

I may be slow to respond.
View GitHub Profile
aliostad / stockfish-interface.txt
Created August 17, 2019 10:41
stockfish - Description of the universal chess interface (UCI)
Description of the universal chess interface (UCI) April 2006
* The specification is independent of the operating system. For Windows,
the engine is a normal exe file, either a console or "real" windows application.
* all communication is done via standard input and output with text commands,
aliostad /
Last active October 20, 2023 09:28
BASH script for increasing file descriptors on linux
CURRENT_MAXFILE=$(ulimit -n)
function update_sysctl(){
UPDT="fs.file-max = $MAXFILE"
if ! grep "$UPDT" /etc/sysctl.conf; then
echo "$UPDT" >> /etc/sysctl.conf
aliostad / azure-data-centres-location-codes
Created June 18, 2017 15:53
Azure Data Centres - Location Codes
"value": [
"id": "/subscriptions/c3dfd792-49a4-4b06-80fc-6fc6d06c4742/locations/eastasia",
"name": "eastasia",
"displayName": "East Asia",
"longitude": "114.188",
"latitude": "22.267"
aliostad / BinaryMediaTypeFormatter
Created April 28, 2012 15:17
An ASP.NET Web API media type formatter for application/octet-stream
public class BinaryMediaTypeFormatter : MediaTypeFormatter
private static Type _supportedType = typeof (byte[]);
private bool _isAsync = false;
public BinaryMediaTypeFormatter() : this(false)
aliostad / rotten_tomatoes.json
Created June 15, 2012 12:57
Result from Rotten Tomatoes search API
{"total":26,"movies":[{"id":"12897","title":"The Matrix","year":1999,"mpaa_rating":"R","runtime":136,"critics_consensus":"An ingenious combination of Hong Kong action, ground-breaking Hollywood FX, and an imaginative vision.","release_dates":{"theater":"1999-03-31","dvd":"1999-09-21"},"ratings":{"critics_rating":"Certified Fresh","critics_score":87,"audience_rating":"Upright","audience_score":81},"synopsis":"","posters":{"thumbnail":"","profile":"","detailed":"","original":""},"abridged_cast":[{"name":"Keanu Reeves","id":"162654049","characters":["Neo"]},{"name":"Laurence Fishburne","id":"162669090","characters":["Morpheus"]},{"name":"Carrie-Anne Moss","id":"162669130","characters":["Trinity"]},{"name":"Hugo Weaving","id":"162709905","characters":["Agent Smith"]},{"name":"Glori
aliostad / gist:3202814
Created July 30, 2012 00:18
Serialisation and deserialisation of HTTP request and response messages in ASP.NET Web API
public interface IHttpMessageSerializer
void Serialize(HttpResponseMessage response, Stream stream);
void Serialize(HttpRequestMessage request, Stream stream);
HttpResponseMessage DeserializeToResponse(Stream stream);
HttpRequestMessage DeserializeToRequest(Stream stream);
public class MessageContentHttpMessageSerializer : IHttpMessageSerializer
var url = "";
var client = new HttpClient();
var result = client.GetAsync(url).Result;
aliostad /
Created December 2, 2018 19:32
Solving simple linear function using tensorflow
import keras
import tensorflow as tf
import keras.backend as K
import numpy as np
from tensorflow.contrib.layers import *
# What we want to do: aX + b = Y
''' This one is using without using feed
X = np.random.uniform(-100., 100., 1000)
aliostad / word2vec_rock_artist_clustering
Created July 12, 2015 15:32
Clustering [k-means] of Rock artists based on their word2vec vectors - Wikipedia corpus
Peccatum, Destructhor, Silenoz, Blood of Kingu, Abruptum, Hate Forest, Demoniac, Tsjuder, Kaiaphas, Ihsahn, Myrkskog, Maurizio Iacono, John McEntee, Manes, Uli Kusch, Narqath, Incantation, Armored Saint, Charred Walls of the Damned, Ved Buens Ende, Beyond Fear, Ildjarn, Holy Moses, Old Funeral, The Kovenant, Carpe Tenebrum, Chroma Key, Michael Amott, Jim Matheos, Nagelfar, Borknagar, Necrophobic, Blackmoon, Koshi Inaba, Casey Chaos, Arcturus, Schmier, Thou Shalt Suffer, Tormentor
De Staat, The Paupers, Arbovirus, 12012, Juliette Greco, Los Mockers, The Head and the Heart, The Wu Tang Clan, Bass Drum of Death, Tiny Dancers, Telephone Jim Jesus, Ghost Brigade, Pegazus, Angband, Unfact, Cirith Gorgor, Incongruous, Heathers, The Shamrock, December Wolves, Mimi Farina, Obliveon, Headplate, Young Ejecta, Kalijuge, Matt Brain, The Lovely Sparrows, Asa Martin, Lost in Thought, Mad Heads, Rosenstolz, Morgan Harper Nichols, Kaliber, Jacob Golden, Serious Drinking, Randy and the Rainbows, Rose Cousins, Daggermouth,
aliostad / MemoryCacheNoFinalizer.cs
Created October 4, 2013 14:26
Not disposing MemoryCache results in memory leak
class Program
static void Main(string[] args)
for (int i = 0; i < 1000000000; i++)
var memoryCache = new MemoryCache("sdf"); // leads to memory leak!!!
// var memoryStream = new MemoryStream(new byte[100000]);