Skip to content

Instantly share code, notes, and snippets.

View Alir3z4's full-sized avatar
💭
Rock'nRolla

Alireza Savand Alir3z4

💭
Rock'nRolla
View GitHub Profile
@Alir3z4
Alir3z4 / main.cpp
Created April 6, 2011 06:59
hello world with Qt/C++
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv)
{
QApplication App(argc, argv);
QLabel Lbl("Hello KhoshGel!");
Lbl.show();
App.exec();
}
@Alir3z4
Alir3z4 / plupload_init.js
Created April 16, 2011 02:42
using plupload and with django to limit files uploading with some effect!
var maxfiles = {{ maxfiles }}; // {{ maxfiles }} returns from views.py
$(function() {
$("#uploader").pluploadQueue({
runtimes : 'gears', // Initialize gears runtime
url : '{{ obj.get_image_upload_url }}', // Url to current object image uploading url
max_file_size : '4mb',
chunk_size: '4mb',
multiple_queues : true,
multi_selection: false, // It's necessary for file uploading limit
rename: true,
const std::vector<std::string> toStdVector(const QVector<QString> &q_vect)
{
std::vector<string> std_vect;
for (int i = 0; i < q_vect.size(); ++i) {
std_vect.push_back(q_vect[i].toStdString());
}
return std_vect;
}
const std::map<std::string, std::string> fromQMap(const QMap<QString, QString> &q_map)
{
std::map<std::string, std::string> std_map;
QMap<QString, QString>::const_iterator i = q_map.constBegin();
while (i != q_map.constEnd()) {
std_map.insert(std::pair<std::string, std::string>(i.key().toStdString(), i.value().toStdString()));
}
return std_map;
}
const std::vector<std::string> fromQVector(const QVector<QString> &qVect)
{
std::vector<std::string> stdVect;
for (int i = 0; i < qVect.size(); ++i) {
stdVect.push_back(qVect[i].toStdString());
}
return stdVect;
}
const std::map<std::string, std::string> Aria2c::fromQMap(const QMap<QString, QString> &qMap)
@Alir3z4
Alir3z4 / slugify_countries.py
Created March 30, 2012 15:17
Slugify all the country.printable_name and put them in slug field
def forwards(self, orm):
"""
Slugify all the country.printable_name and put them in slug field
"""
from django.template.defaultfilters import slugify
for country in orm.Country.objects.all():
country.slug = slugify(country.printable_name)
countey.save()
def queryset(self, request):
if request.user.is_superuser:
return self.model.objects.all()
return self.model.objects.filter(user=request.user)
#
# Definitions of ISO 4217 Currencies
# Source: http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm
#
CURRENCY['BZD'] = Currency(code='BZD', numeric='084', name='Belize Dollar', countries=['BELIZE'])
CURRENCY['YER'] = Currency(code='YER', numeric='886', name='Yemeni Rial', countries=['YEMEN'])
CURRENCY['XBA'] = Currency(code='XBA', numeric='955', name='Bond Markets Units European Composite Unit (EURCO)', countries=[])
CURRENCY['SLL'] = Currency(code='SLL', numeric='694', name='Leone', countries=['SIERRA LEONE'])
CURRENCY['ERN'] = Currency(code='ERN', numeric='232', name='Nakfa', countries=['ERITREA'])
#!/usr/bin/env python
import sys
base_path = sys.argv.pop()
sys.path.insert(0, base_path)
from fix_getpass import fixGetpass
import os
from django.core.management import execute_manager
# Fucking hack to set local env for django debug
# yeah
" -[ General behaviour ]-
" general
set nocompatible
set nowrap
syntax on
filetype plugin indent on
" search
set nohls
set incsearch