Skip to content

Instantly share code, notes, and snippets.

@martinmev
martinmev / martinmev.py
Created August 8, 2013 16:00
Output for the new submission parser. This submission for 0.95045 uses PCA and svm.SVC classifier. Kaggle competition: Data Science London + Scikit-learn.
#!/usr/bin/env python
import numpy as np
from sklearn import grid_search
from sklearn import cross_validation as cv
from sklearn.svm import SVC
from sklearn.cross_validation import StratifiedKFold
from sklearn.decomposition import PCA
loadData = lambda f: np.genfromtxt(open(f,'r'), delimiter=',')
@martinmev
martinmev / gist:7741936
Last active October 8, 2017 19:51
Fix ugly file names (a simple shell function)
fix () {
for x in *
do
mv -- "$x" `echo "$x" | iconv -f utf8 -t ascii//TRANSLIT | tr '[:upper:]' '[:lower:]' | sed 's/[^-.a-zA-Z0-9]\+/-/g' | sed 's/[-]\+/-/g'` 2> /dev/null
done
}
fixDirs () {
fix
for x in *
@martinmev
martinmev / imgfft.m
Created December 26, 2013 16:00
Convert image to an abstract picture
%% run in Octave:
%% source 'imgfft.m'
filename = 'image.jpg';
img = imread(filename);
img2=double(img);
img3= (img2(:,:,1)+img2(:,:,2)+img2(:,:,3))/3;
@martinmev
martinmev / disable_request_new_password.info
Last active January 1, 2016 18:59
Drupal 6: this tiny module disables 'Request new password' functionality
; $Id$
name = Disable Request new password
description = Disable 'Request new password' functionality
core = 6.x
package = "Other"
version = "6.x-0.1"
@martinmev
martinmev / gist:8248935
Last active March 27, 2016 15:44
Configuration: Postfix SMTP authentication and Dovecot SASL

Postfix SMTP authentication and Dovecot SASL

  • /etc/postfix/master.cf
  smtp      inet  n       -       -       -       -       smtpd
  submission inet n       -       -       -       -       smtpd
    -o smtpd_tls_security_level=encrypt
    -o smtpd_sasl_auth_enable=yes
@martinmev
martinmev / gist:2b219d7684b73692c96f
Last active January 29, 2016 20:33
Drupal HTML article: Delete the teaser image and display the first image (from Drupal Galleria module) in Lightbox (on click).
<script type="text/javascript">
<!--
try { $('.Image')[0].outerHTML=''; } catch(err) {};
-->
</script></p>
<p><a href="#" onclick="Lightbox.start(
$('#galleria-content ul.galleria li a:eq(0)')[0]);
return false;"><img src="/sites/default/files/posli_to_dal2.jpg" style="float: left;"/></a></p>
@martinmev
martinmev / gist:fdc3462e62b039a910c4
Created June 1, 2014 11:09
Dump Nokia Suite SQLite database
import sqlite3
conn = sqlite3.connect('c:\\Users\\Martin\\AppData\\Local\\Nokia\\Nokia Data Store\\DataBase\\MDataStore.db3')
for i in conn.iterdump():
print(i)
@martinmev
martinmev / gist:444619fbdec82864a025
Created June 1, 2014 11:18
Export contacts from Nokia Suite
import sqlite3
import json
conn = sqlite3.connect('c:\\Users\\Martin\\AppData\\Local\\Nokia\\Nokia Data Store\\DataBase\\MDataStore.db3')
data = {}
cursor = conn.execute("select * from contact")
rows = cursor.fetchall()
getRowData = lambda r : ' '.join([x if x else '' for x in r]).strip()
@martinmev
martinmev / touchtest.html
Last active August 29, 2015 14:16
Detection (Javascript): Click (Desktop) or Touch (Touch device)?
<html>
<body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script language="javascript">
mouseOverTime = 0;
@martinmev
martinmev / characterSetMappingTables.jl
Last active August 29, 2015 14:20
This Julia Gist generates the character set mapping dictionaries from the mappings files (8 bit characters to Unicode; ftp.unicode.org/Public/MAPPINGS/) and it decodes the text from a given code page.
using HDF5, JLD
# https://www.dropbox.com/s/o4ys5z3p7ogircd/characterSetMappingTables.jld?dl=0
@load "c:\\Users\\Martin\\Downloads\\MAPPINGS\\characterSetMappingTables.jld"
function printEncodings()
for mappingTable in sort(collect(keys(characterSetMappingTables)))
println(mappingTable)
end
end