Skip to content

Instantly share code, notes, and snippets.

@marcinwol
marcinwol / python install.sh
Last active August 29, 2015 14:03
How to install virtual environment of Python 3.4.x from source in Ubuntu 14.04
# Below are commands used to install and set-up virtual environment of Python 3.4 in Ubuntu 14.04.
# First we need to install dependencies. Please not that this is much larger list than is required for setting up only Python.
# The reason is that usually I and my users install other python packages through pip (list of the popular ones is at the
# end) and these packages also require some packages to be installed first. Thus, I prefer to install everything at
# once.
sudo apt-get install build-essential libc6-dev libreadline-dev libncursesw5-dev libssl-dev libgdbm-dev libsqlite3-dev libbz2-dev liblzma-dev tk-dev bzip2 libbz2-dev sqlite3 tk8.5-dev zlib1g-dev liblzma-dev libblas3 liblapack3 gfortran libopenblas-dev liblapack-dev libmagickwand-dev libxml2-dev libxslt1-dev qtmobility-dev git cmake libqt4-dev libwebp-dev
# Download latest Python, unpack it, and enter into Python folder.
@marcinwol
marcinwol / dir_scan.cpp
Created February 25, 2015 05:17
Example showing how to get all paths in a given folder using dirent readdir method.
#include <errno.h>
#include <dirent.h>
#include <iostream>
#include <vector>
using namespace std;
int dir_scan(const string & in_path, vector<string> & found_paths)
@marcinwol
marcinwol / main.cpp
Created March 1, 2015 02:27
C++11: enum to string and integer
/* How to use enum class and to obtain its value as integer and string
* without too much of code repition.
*
* Based on http://stackoverflow.com/a/238157/248823
*/
#include <iostream>
using namespace std;
@marcinwol
marcinwol / chanker.cc
Created July 1, 2015 06:25
C++11: devide vector into k-sized chunks
/**
* Code taken from http://stackoverflow.com/a/11408470/248823
*/
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include <iostream>
#include <stdexcept>
@marcinwol
marcinwol / return_value.cpp
Created July 3, 2015 00:38
Example of returning values from threads
/**
* Example of returning a value from threads
*/
#include <iostream>
#include <vector>
#include <mutex>
#include <thread>
using namespace std;
@marcinwol
marcinwol / startirfan.py
Last active August 29, 2015 14:26
Start IrfanView in Linux with input file
#!/usr/bin/python3
#
# Put the file, for example in: /home/marcin/bin/startirfan.py
# and mark it as executable: chmod +x /home/marcin/bin/startirfan.py
#
# Make IrfanViewMine.desktop in /home/marcin/.local/share/applications that contains:
#
# [Desktop Entry]
# Encoding=UTF-8
# Name=MineIrfanView348
@marcinwol
marcinwol / startgimp.py
Last active August 29, 2015 14:26
Start gimp from IrfanView in Ubuntu
#!/usr/bin/python3
#
# add this, for example, /home/marcin/bin/startgimp.py
# to IfranViews Miscellaneus Properties/Settings
#
import os
import sys
gimp_cmd = '/usr/bin/gimp-2.8 '
@marcinwol
marcinwol / nslookup
Last active August 29, 2015 14:27
Check ip address of for a webpave
nslookup mine.moneropool.com
Server: 127.0.1.1
Address: 127.0.1.1#53
Non-authoritative answer:
Name: mine.moneropool.com
Address: 54.75.230.12
Name: mine.moneropool.com
Address: 54.75.230.15
Name: mine.moneropool.com
@marcinwol
marcinwol / example-upload.phpt
Created January 23, 2011 05:47
Example phpt file for testing file uploads
--TEST--
Example test emulating a file upload
--SKIPIF--
<?php if (php_sapi_name()=='cli') die('skip'); ?>
--POST_RAW--
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfywL8UCjFtqUBTQn
------WebKitFormBoundaryfywL8UCjFtqUBTQn
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain
@marcinwol
marcinwol / Zend_db_ex.php
Created January 30, 2011 08:00
Example of using Zend_Db independent from Zend Application
<?php
#index.php
// Assuming the Following directory structures
//
// |-- index.php
// `-- library
// `-- Zend
// |-- Db
// |-- Db.php