Skip to content

Instantly share code, notes, and snippets.

View jsam's full-sized avatar
🦁

sam jsam

🦁
View GitHub Profile
@jsam
jsam / quicksort.cpp
Last active February 2, 2018 10:34
quicksort
void quickSort(zaposlenici arr*, int left, int right)
{
int i = left, j = right;
zaposlenici tmp;
zaposlenici *pivot = arr[(left + right) / 2];
/* partition */
while (i <= j) {
while (arr[i]->oib < pivot->oib)
i++;
@jsam
jsam / gist:6948019
Created October 12, 2013 09:43
Rename file and buffer macro
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
@jsam
jsam / gist:6943381
Created October 11, 2013 23:05
stub
/*
* mcwm, a small window manager for the X Window System using the X
* protocol C Binding libraries.
*
* For 'user' configurable stuff, see config.h.
*
* MC, mc at the domain hack.org
* http://hack.org/mc/
*
* Copyright (c) 2010, 2011, 2012 Michael Cardell Widerkrantz, mc at
@jsam
jsam / gist:6626531
Created September 19, 2013 17:05
saving async task
/**
* Async class for communication with I/O for saving taken photo
* @param jpeg byte representation of given photo for saving to filesystem
*/
class SavePhotoTask extends AsyncTask<byte[], String, String> {
@Override
protected String doInBackground(byte[]... jpeg) {
UUID image_name = UUID.randomUUID();
@jsam
jsam / gist:6225931
Last active December 21, 2015 01:09
pyobjs proposal
cdef class CArray:
"""Class for representing c-array. Due to lack of void ptr arithmetic support there is no void casting magic, therefore per type casting is needed."""
cdef public list PyList
cdef public unsigned int PyListSize
def __init__(self, arr=None):
dprint("Initialize CArray in __init__")
if arr is not None:
self.PyList = self.fix_args(arr)
.. code-block:: bash
git checkout gh-pages
git merge -s ours master
git checkout master
git merge gh-pages
find . -mtime 0 -print | awk '{print "scp "$0" user@hostname:/a/b"}'
@jsam
jsam / gist:5268677
Created March 29, 2013 03:58
Match passwords
JS
function validatePass(p1, p2)
{
if (p1.value != p2.value || p1.value == '' || p2.value == '')
{
p2.setCustomValidity('Password incorrect');
} else {
p2.setCustomValidity('');
}
}
@jsam
jsam / gist:5006978
Last active December 14, 2015 01:29
lisp ref.
http://www.paulgraham.com/avg.html
http://programmers.stackexchange.com/questions/55284/is-lisp-still-useful-in-todays-world-which-version-is-most-used
http://norvig.com/paip.html
http://stackoverflow.com/questions/108201/common-lisp-or-scheme
@jsam
jsam / gist:4651691
Created January 28, 2013 00:30
zamjeni si sve at(i) sa [i] da te ne zbunjuje jer je ista funkcija.....push_back() ti je funkcija s kojom dodajes u listu...i to je to..pretrazivanje radis linearno to ti je najlakse..znaci puknes u petlju i onda pretrazujes element po element..pokazem ti jos sortiranje i to ti je ta ista sablona koja dolazi
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
class cstudent
{
public:
long long mat_broj;
string ime_prezime;