Skip to content

Instantly share code, notes, and snippets.

View Spoygg's full-sized avatar

Ivan Ivanić Spoygg

View GitHub Profile
$sql = "select qst.system_name as system_name, qst.question as question, ans.answer as answer from " . EVENTS_ANSWER_TABLE . " ans inner join " . EVENTS_QUESTION_TABLE . " qst on ans.question_id = qst.id where qst.system_name = 'country' and ans.attendee_id = " . $attendee_id;
$questions = $wpdb->get_results($sql, ARRAY_A);
if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->question != NULL) {
foreach ($questions as $q) {
$country = $q['answer'];
}
}
foreach($serviceTypes as $serviceType) {
$clean = str_replace(',', '', $serviceType->getName());
$options[$clean] = $this->getCourierName($serviceType->getCourierId()) . ' - ' . $serviceType->getName();
}
@Spoygg
Spoygg / slow-connection.bash
Created September 5, 2012 07:34
Simulaitng slow connection.
# Add delay of 1000 millis to every request
sudo tc qdisc add dev lo root handle 1:0 netem delay 1000msec
# Remove delay
sudo tc qdisc del dev lo root
function wmode() {
// For each iFrame
$('iframe').each(function () {
// Store some variables
var $this = $(this),
src = $this.attr('src'),
query;
@Spoygg
Spoygg / symfony1.4-show-all-form-errors.php
Created August 3, 2012 09:05
Symfony 1.4 get all form errors.
<ul class="error_list">
<?php foreach( $form->getGlobalErrors() as $name => $error ) : ?>
<li><?php echo $name ?> : <?php echo $error ?></li>
<?php endforeach ?>
<?php $errors = $form->getErrorSchema()->getErrors() ?>
<?php if ( count($errors) > 0 ) : ?>
<?php foreach( $errors as $name => $error ) : ?>
<li><?php echo $name ?> : <?php echo $error ?></li>
<?php endforeach ?>
<?php endif ?>
// Legacy code - do not remove
$isResidential = $values['residential'] != 'no';
$inquiry = RateInquiryPeer::create(
$values['CollectionAddress']['CountryCode'],
$values['CollectionAddress']['City'],
$values['CollectionAddress']['PostalCode'],
$values['DestinationAddress']['CountryCode'],
$values['DestinationAddress']['City'],
$values['DestinationAddress']['PostalCode'],
@Spoygg
Spoygg / initialize-os.sh
Created July 20, 2012 04:59
Script to run after installation of OS.
# Setup Vim
# For persist Vim undo history beyond closing file
mkdir ~/.vim-meta-files
# Link Vim config to sync with Dropbox
ln -s ~/Dropbox/vim ~/.vim
ln -s ~/.vim/vimconfig ~/.vimrc
echo "Vim setup."
#Customize OS
# Import custom keyboard layout
@Spoygg
Spoygg / gist:3137273
Created July 18, 2012 16:22
Notes for lecture: Law of Attraction
Zakon privlačnosti
Od primećivanja do manifestacije
iliti Kako pomoći sebi da imaš sve što poželiš
* Prvi korak je da nešto primetiš u svojem okruženju.
Primeri:
Ideš ulicom i vidiš nešto
Na netu si naletiš na nešto
* Drugi korak je želja
Primeri:
Video si nešto i želiš to za sebe
@Spoygg
Spoygg / gist:3122226
Created July 16, 2012 11:29
Keyboard switches for XKB setxkbmap
altwin:menu = +altwin(menu)
altwin:meta_alt = +altwin(meta_alt)
altwin:ctrl_win = +altwin(ctrl_win)
altwin:meta_win = +altwin(meta_win)
altwin:left_meta_win = +altwin(left_meta_win)
altwin:super_win = +altwin(super_win)
altwin:hyper_win = +altwin(hyper_win)
altwin:alt_super_win = +altwin(alt_super_win)
altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin)
grp:switch = +group(switch)
@Spoygg
Spoygg / publication-merge.php
Created July 14, 2012 15:26
Merge publication prevods to single page prevod
<?php
// First fetch all prevods
// Mysql call
$sql = "
SELECT ID, post_title, post_content, post_parent, post_name
FROM wp_rscom_posts
WHERE post_parent
IN (
SELECT ID
FROM wp_rscom_posts