Skip to content

Instantly share code, notes, and snippets.

View reuf's full-sized avatar

Muhamed Halilovic reuf

View GitHub Profile
@reuf
reuf / HiddenInputSupportDemo.page
Created December 20, 2015 23:09 — forked from martyychang/HiddenInputSupportDemo.page
Demonstration of using an apex:actionSupport with a "hidden" input
<apex:page standardController="Account">
<h2>Form</h2>
<apex:form>
<apex:inputText id="accountNameInput" styleClass="with-hidden"/>
<apex:inputText id="accountNameInputHidden"
value="{!Account.Name}"
style="display:none">
<apex:actionSupport event="onchange" action="{!quicksave}"
reRender="accountNameOutput"
status="accountNameStatus"/>
@reuf
reuf / ActionSupportParamDemo.page
Created December 20, 2015 23:09 — forked from martyychang/ActionSupportParamDemo.page
Demonstration of how apex:actionSupport and apex:param are supposed to work together
<apex:page controller="ActionSupportParamDemoController">
<apex:form>
<apex:repeat value="{!accounts}" var="account">
<apex:inputCheckbox value="{!account.IsActive__c}">
<apex:actionSupport event="onchange"
action="{!handleAccountCheckboxChange}">
<apex:param id="account" name="accountId" value="{!account.Id}"
assignTo="{!targetAccountId}"/>
</apex:actionSupport>
</apex:inputCheckbox>
@reuf
reuf / read_write.pl
Created September 30, 2015 10:11 — forked from seouri/read_write.pl
read/write perl
sub read_file {
my $file_name = shift;
print STDERR "READ $file_name ... ";
my @file;
open(FH, "< $file_name") or die("Can't read $file_name: $!\n");
while (<FH>) {
chomp;
my @t = split /\t/;
@t = map { s/^\s+//g; s/\s+$//g; $_ } @t;
push @file, \@t;
@reuf
reuf / struktura_stranice.txt
Created September 30, 2015 10:10
StrutkuraStranice
Lekcija
- id
- naslov,
- redni broj,
- opis
Tekst
- id_vjezbe
- id_rijecnika
- id_
@reuf
reuf / RBTree
Created September 30, 2015 10:09 — forked from adderllyer/RBTree
red-black tree implementation
package com.ds.tree.rbtree;
import java.util.LinkedList;
import java.util.Queue;
import com.ds.tree.adt.BinarySearchTree;
import com.ds.tree.adt.TreeTraversal;
/**
@reuf
reuf / django-ajax.html
Created September 30, 2015 09:37 — forked from Djiit/django-ajax.html
django-ajax
<polymer-element name="django-ajax" extends="core-ajax">
<script>
Polymer({
getCSRFCookie: function() {
b = document.cookie.match('(^|;)\\s*csrftoken\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
},
ready: function() {
this.super();
this.headers = {
@reuf
reuf / django ajax csfr token
Created September 30, 2015 09:37 — forked from elin3t/django ajax csfr token
django ajax csft token
//query
$.ajax({
data: 'csrfmiddlewaretoken={{ csrf_token }}&...,
type: 'post',
});
//json
$.ajax({
data: {'csrfmiddlewaretoken': '{{ csrf_token }}', ...},
@reuf
reuf / Django + Ajax dynamic forms
Created September 30, 2015 09:37 — forked from goldhand/Django + Ajax dynamic forms .py
#Django form with Ajax A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin. There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdate…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
#views.py
@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')
@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():