Skip to content

Instantly share code, notes, and snippets.

View jsam's full-sized avatar
🦁

sam jsam

🦁
View GitHub Profile
.. code-block:: bash
git checkout gh-pages
git merge -s ours master
git checkout master
git merge gh-pages
@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)
@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: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: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 / 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:8423438
Created January 14, 2014 18:43
flora2
/*
Neka je zadana baza znanja:
zaposlenik::osoba.
kupac::osoba.
menadzer::zaposlenik.
direktor::menadzer.
stefica:kupac.
ivek:zaposlenik.
import random, subprocess
def start_game():
operations = ['+', '-', '*', '/']
for i in range(10):
n1 = random.randint(0, 100)
n2 = random.randint(0, 100)
operation = operations[random.randint(0, 3)]
sol = raw_input("{} {} {} = ".format(n1, operation, n2))
@jsam
jsam / gist:8441392
Created January 15, 2014 18:16
cjeo
import argparse, time, os, uuid
from pwd import getpwnam
from multiprocessing import Process, Queue
def sender(q, message):
_id = uuid.uuid4()
print("[S] sending {}".format(message))
for i, part in enumerate(message):
q.put({ 'data': part, 'sequence_number': i, 'sender_id': str(_id) })
@jsam
jsam / gist:8469632
Created January 17, 2014 07:24
speed test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2013 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0