Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lextoumbourou
lextoumbourou / GamepadCursorScrollUtil.lua
Last active July 9, 2021 02:04
A Roblox module that allows Gamepad scrolling using the DPad
local ContextActionService = game:GetService('ContextActionService')
local module = {hold=false}
local ActionNames={
['ScrollDown']='ScrollDown',
['ScrollUp']='ScrollUp',
['ScrollRight']='ScrollRight',
['ScrollLeft']='ScrollLeft'
}
@lextoumbourou
lextoumbourou / roblox-create-voxel-of-terrain.lua
Last active May 11, 2021 11:39
Create a single Voxel of Terrain in Roblox
local Terrain = game:GetService("Workspace").Terrain
-- The resolution required for Terrain system.
local terrainResolution = 4
-- The smallest possible voxel size.
local region = Region3.new(Vector3.new(0,0,0), Vector3.new(4,4,4))
-- The material as a 1x1x1 3d-grid. What material should go in the voxel?
local material = {
@lextoumbourou
lextoumbourou / predictions.py
Last active August 27, 2018 00:27
Making predictions with a SequentialRNN model (Fast.ai)
# Note: ensure you have the latest version of Torchtext by running: pip install torchtext --upgrade
rnn_model = text_data.get_model(opt_fn, 1500, bptt, emb_sz=em_sz, n_hid=nh, n_layers=nl,
dropout=0.1, dropouti=0.65, wdrop=0.5, dropoute=0.1, dropouth=0.3)
# ...
rnn_model.data.test_dl.src.sort = False
rnn_model.data.test_dl.src.sort_within_batch = False
rnn_model.data.test_dl.src.shuffle = False
@lextoumbourou
lextoumbourou / dataframe_dataset.py
Created August 20, 2018 09:18
Torchtext dataset from DataFrame
from torchtext import data
class DataFrameDataset(data.Dataset):
def __init__(self, df, text_field, label_field, is_test=False, **kwargs):
fields = [('text', text_field), ('label', label_field)]
examples = []
for i, row in df.iterrows():
label = row.sentiment if not is_test else None
text = row.text
@lextoumbourou
lextoumbourou / compile.sh
Created December 6, 2017 05:00
Compile Tensorflow for Lambda
BASE_PATH=./
yum install -y wget
wget https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo -O /etc/yum.repos.d/vbatts-bazel-epel-7.repo
# Appear to have to run this twice to get it to run reliably.
yum install -y bazel; yum install -y bazel
if [ ! -d "$BASE_PATH/env" ]; then
@lextoumbourou
lextoumbourou / hbase_heap.py
Last active May 10, 2019 10:20
Hbase Heap Size Calculator
def get_regionserver_heap_size(
storage_capacity_in_gb,
region_max_filesize=10737418240,
memstore_flush_size=134217728,
replication_factor=3,
memstore_heap_fraction=0.4
):
"""
Calculates heap size required based on storage requirements.
@lextoumbourou
lextoumbourou / gist:ac085cd8002141d036c9
Created January 16, 2015 03:10
Install a Pip package via Git (or any VCS) with setuptools extras
> pip install git+ssh://git@github.com/lextoumbourou/MyProject.git#egg=MyModule[extra]
@lextoumbourou
lextoumbourou / nginx.conf
Created January 14, 2015 10:08
Conditional Nginx error pages based on Accept (or other) headers
http {
map $http_accept $extension {
default html;
application/json json;
}
server {
listen 80;
error_page 500 /500;
@lextoumbourou
lextoumbourou / auto_nested_dict.py
Created December 7, 2014 02:31
Super simple auto nested dict in Python
from collections import defaultdict
def auto_nested_dict():
return defaultdict(auto_nested_dict)
if __name __ == '__main__':
d = auto_nested_dict()
d['wats']['up']['world'] = 'Here I am!'