Skip to content

Instantly share code, notes, and snippets.

View AlexJoz's full-sized avatar

Alex Joz AlexJoz

View GitHub Profile
@AlexJoz
AlexJoz / Direction.java
Created October 22, 2015 16:02
Enum Direction
enum Direction {
VERTICAL {
public Direction opposite() {
return HORIZONTAL;
}
},
HORIZONTAL {
public Direction opposite() {
return VERTICAL;
}
@AlexJoz
AlexJoz / gist:23c3cd19e94de9d61f7c
Created November 21, 2015 22:54
Refresh Dependencies in Gradle & Eclipse
It depends on how you integrate with Eclipse.
If you use Gradle's 'apply plugin: eclipse', run 'gradle cleanEclipse eclipse'.
If you use the STS Gradle plugin, right-click the project and choose 'Gradle - Refresh Dependencies'.
@AlexJoz
AlexJoz / gist:46b489e2303cddb3c85f
Created November 26, 2015 23:48
Function handle in Matlab
joz = @(k) k+1;
>> joz(1)
ans =
2
@AlexJoz
AlexJoz / xyto1D.java
Last active November 29, 2015 13:21
Transform 2D to 1D array coordinates, where x - col and y - row
// transform (x,y) to 1D
// where x - colomn, y - row (for CV applications or picture filtering)
//this.x = picture.width();
private int p(int x, int y) {
return y * this.x + x + 1;
}
###
# !!! THIS IS NOT A BASH SCRIPT !!!
###
# named .sh just so Github does correct syntax highlighting
# Inspired by https://gist.github.com/erikbern/78ba519b97b440e10640
#
# This setup is available as a public AMI in US-East(N. Virginia): ami-9d0f3ff7
# Add repos for cmake and gcc
@AlexJoz
AlexJoz / tensorflow 0.9 with gpu support for py3 on aws ec2
Created July 11, 2016 14:56
tensorflow 0.9 with gpu support for py3 on aws ec2
###
# !!! THIS IS NOT A BASH SCRIPT !!!
###
# named .sh just so Github does correct syntax highlighting
# Inspired by https://gist.github.com/AlexJoz/1670baf0b32573ca7923
#
# This setup is available as a public AMI in US-East(N. Virginia): ami-60da5a77
#
# Tensorflow 0.9 with gpu support (installing cuda drivers and cudnn lib) for python3 with numpy, matplotlib and sklearn installed
@AlexJoz
AlexJoz / gist:e6e45e3c84fb7143cb1da0f8c9f46e76
Last active August 5, 2016 16:22
Syncronize files with running ec2 instance (download data from aws)
sudo rsync -azv -e "ssh -i /home/ubuntu/key-to-ec2.pem" [email protected]:/home/ubuntu/source/ /home/ubuntu/target
@AlexJoz
AlexJoz / rfc2822_to_day_of_year.py
Created November 17, 2016 20:07
Get day of year from rfc2822 email time in Python
#python2
from email.utils import parsedate_tz
import datetime
z = parsedate_tz('Fri, 1 Jan 2016 17:58:28 +0700')
print z
print datetime.datetime.strptime('{}-{}-{}'.format(z[0],z[1],z[2]), '%Y-%m-%d').timetuple().tm_yday
output:
'''
(2016, 1, 1, 17, 58, 28, 0, 1, -1, 25200)
@AlexJoz
AlexJoz / download_to_file.py
Created November 18, 2016 14:22
Download file from http link with python2
import urllib2
#put your link here =)
url = "http://ichart.finance.yahoo.com/table.csv?s=^GSPC&c=2016"
file_name = "table.csv" #can parse fname from url, ofcoz.
u = urllib2.urlopen(url)
gspc = u.read()
with open(file_name, 'wb') as f:
@AlexJoz
AlexJoz / gist:a83f245de9bc77e87feccd181ebc848e
Last active January 10, 2017 13:44
Some nice ubuntu commands ^^
sudo sgdisk -Z /dev/sdc Wipe guid partition table
sudo apt-get purge `dpkg -l | awk '{print $2}' | grep -E 'gnome|unity'` Wipe unity
sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic for NVidia Optimus cards