Skip to content

Instantly share code, notes, and snippets.

View reuf's full-sized avatar

Muhamed Halilovic reuf

View GitHub Profile
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@reuf
reuf / .vimrc
Last active September 8, 2015 10:28 — forked from nardev/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@reuf
reuf / Algos.py
Created September 27, 2015 18:44
Basic algos and math solvers
__author__ = 'user'
def fibonocci_sequence():
a, b = 0, 1
while b<100:
print(b)
a, b = b, a+b
fibonocci_sequence()
@reuf
reuf / 01_data_structures_algos.py
Created September 28, 2015 08:53
Data structures and algos examples
import os
from collections import deque, defaultdict, OrderedDict, Counter, namedtuple, ChainMap
# import json
import heapq
import math
from operator import itemgetter, attrgetter
from itertools import groupby, compress
__author__ = 'muhamed.halilovic'
@reuf
reuf / 02_strings_text.py
Created September 29, 2015 11:36
String manipulation python
__author__ = 'muhamed.halilovic'
import re
import os
from urllib.request import urlopen
from fnmatch import fnmatch, fnmatchcase
from calendar import month_abbr
import unicodedata
# ------------------------------
# 2.1. Splitting Strings on Any of Multiple Delimiters
# Loading the pyPdf Library
from pyPdf import PdfFileWriter, PdfFileReader
import os
# Creating a routine that appends files to the output file
def append_pdf(input,output):
[output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]
# Creating an object where pdf pages are appended to
output = PdfFileWriter()
@reuf
reuf / combinePDFSInOne.py
Created September 30, 2015 09:08
Combine PDF Files in current working dir into one
# Loading the pyPdf Library
from pyPdf import PdfFileWriter, PdfFileReader
import os
from os import listdir
# Creating a routine that appends files to the output file
def append_pdf(input,output):
[output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]
# Creating an object where pdf pages are appended to
@reuf
reuf / Pageload.py
Created September 30, 2015 09:32 — forked from ralphking/Pageload.py
Django search
class SearchView(FormMixin, ListView):
template_name = 'search.html'
context_object_name = 'spaces'
form_class = SearchForm
def get_initial(self):
'''get initial values from request params'''
if self.request.GET:
initial = self.request.GET.dict()
return initial
@reuf
reuf / gist:9984a5758d517bcb15a6
Created September 30, 2015 09:35 — forked from kuozo/gist:3046326
django
'''
actions.get(action)(selected)代码写的不错,干净。
源文件:https://github.com/marconi/django-quickstart/blob/master/src/todo/views.py
'''
def home(request):
todos=Todo.objects.order_by('-created')
if request.method == 'POST':
action = request.POST['action'].lower()
todo_list_form = TodoListForm(data=request.POST, todos=todos)
if todo_list_form.is_valid():
@reuf
reuf / Snipplr-25237.py
Created September 30, 2015 09:36 — forked from lambdamusic/Snipplr-25237.py
Django: Django and JSON
def json_response(something):
from django.utils import simplejson
return HttpResponse(simplejson.dumps(something),
content_type='application/json; charset=UTF-8')