Skip to content

Instantly share code, notes, and snippets.

@martinmev
martinmev / martinmev.py
Created Aug 8, 2013
Output for the new submission parser. This submission for 0.95045 uses PCA and svm.SVC classifier. Kaggle competition: Data Science London + Scikit-learn.
View martinmev.py
#!/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 Oct 8, 2017
Fix ugly file names (a simple shell function)
View gist:7741936
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 Dec 26, 2013
Convert image to an abstract picture
View imgfft.m
%% 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 Jan 1, 2016
Drupal 6: this tiny module disables 'Request new password' functionality
View disable_request_new_password.info
; $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 Mar 27, 2016
Configuration: Postfix SMTP authentication and Dovecot SASL
View gist:8248935

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 Jan 29, 2016
Drupal HTML article: Delete the teaser image and display the first image (from Drupal Galleria module) in Lightbox (on click).
View gist:2b219d7684b73692c96f
<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 Jun 1, 2014
Dump Nokia Suite SQLite database
View gist:fdc3462e62b039a910c4
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 Jun 1, 2014
Export contacts from Nokia Suite
View gist:444619fbdec82864a025
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 Aug 29, 2015
Detection (Javascript): Click (Desktop) or Touch (Touch device)?
View touchtest.html
<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 Aug 29, 2015
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.
View characterSetMappingTables.jl
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
You can’t perform that action at this time.