Skip to content

Instantly share code, notes, and snippets.

@guy4261
guy4261 / viewTable.php
Created July 4, 2012 22:20
Download mysql table as TSV
<?php
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="default-filename.txt"');
$newline = "\r\n";
$delimiter = "\t";
$db_host = 'localhost';
$db_user = "web";
$db_pwd = '';
@guy4261
guy4261 / README.md
Last active December 21, 2015 03:08 — forked from mbostock/.block

On mouseover, mark the node you're hovering over, and color its neighbours according to the type of the relationship. This style is only an example and anything goes - from adding icons, respecting asymmetric links (i.e. different markup of employee or manager in an unmutual hierarchy link) and the list goes on.

Not relying on markers etc gives a lot of visual relief.

Based on Mike Bostock's molecule example from: http://bl.ocks.org/mbostock/3037015

@guy4261
guy4261 / normalize_torch_mnist_data.lua
Last active August 29, 2015 14:21
Normalize the mnist train data in the Torch tutorial
require('torch')
-- Find the average per image
train = torch.load('mnist.t7/train_32x32.t7', 'ascii')
train.data = train.data:type(torch.getdefaulttensortype())
BOUND = 60000 -- Perform on the full data
-- BOUND = 1 -- You can test on a single image as a beginning
for index = 1, BOUND do
cells = train.data[index][1]
avg = 0
@guy4261
guy4261 / pixel_iterator_on_torch_mnist.lua
Created May 18, 2015 14:54
Implementing an iterator that goes through the pixels in the torch mnist dataset
train = torch.load('mnist.t7/train_32x32.t7', 'ascii')
train.data = train.data:type(torch.getdefaulttensortype())
function pixels(dataset)
local dimensions = (#dataset.data):totable()
local data = dataset.data
local d1 = 1
local d2 = 1
local d3 = 1
local d4 = 1
@guy4261
guy4261 / python2.7.9_centos_installation.sh
Last active October 8, 2022 09:30
Installing Python 2.7.9 on CentOS
###########################
# Installing Python 2.7.9 #
###########################
# https://github.com/h2oai/h2o-2/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only
yum -y groupinstall "Development tools"
yum -y install zlib-devel
yum -y install bzip2-devel
yum -y install openssl-devel
@guy4261
guy4261 / glc_via_conda.sh
Last active August 29, 2015 14:27
Installing GraphLab using Miniconda on CentOS
# Download an install miniconda
wget -nv https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
chmod u+x Miniconda-latest-Linux-x86_64.sh
./Miniconda-latest-Linux-x86_64.sh -b -f
# -b means batch install using the defaults: that means .bashrc does not change so we do it outselves.
cp .bashrc .bashrc-miniconda.bak
echo "
# added by Miniconda 3.10.1 installer
@guy4261
guy4261 / niqqud.py
Last active April 12, 2023 20:38
Hebrew niqqud unicode point values for Python programmers
# To create a hebrew letter with niqqud:
# hebrew letter [+ optional shin_dot if letter is shin] [+ optional dagesh] [+ optional niqqud]
# example: print("ש" + chr(shin_dot_right_shin) + chr(dagesh) + chr(kmz_katan)) => שָּׁ
# letter should be first, order of the rest does not matter
# print("ש" + chr(kmz_katan) + chr(shin_dot_left_sinn) + chr(dagesh)) => שָּׂ
# This is how you get things like the reverse of noël being l̈eon instead of lëon,
# as discussed in Edaqa Mortoray's two seminal blog posts:
# https://mortoray.com/we-dont-need-a-string-type/
@guy4261
guy4261 / linkedin_data_export_messages_to_csv.py
Created July 5, 2023 14:32
Turn you LinkedIn messages from a data export to csv (and help RIF'd friends)
#!/usr/bin/env python
# coding: utf-8
import os
import webbrowser
import zipfile
from datetime import datetime
from glob import glob
from io import BytesIO
import pandas as pd