Skip to content

Instantly share code, notes, and snippets.

View vasia123's full-sized avatar

Vasily Krakovetsky vasia123

View GitHub Profile
@grachov
grachov / QuickOrder.php
Created June 4, 2014 13:10
Покупка товара в один клик для miniShop2
<?php
$context = $modx->context->get('key');
if ($context == 'mgr' || empty($_POST['quick_order']) || empty($_POST['id']) || empty($_POST['customer'])) {
return;
}
/**
* @var miniShop2 $miniShop2
*/
$miniShop2 = $modx->getService('minishop2');
$miniShop2->initialize($context, array(
@cuibonobo
cuibonobo / bluetooth_kivy.py
Last active October 10, 2023 12:19 — forked from tito/bluetooth.py
Bluetooth example with Kivy. A more fleshed-out example here: https://github.com/tito/android-demo. A more modern way of doing it: https://github.com/kivy/plyer. And this guy used Kivy to connect to an Arduino: https://github.com/brean/arduino-kivy-bluetooth. Native Kivy code (?): https://groups.google.com/d/msg/kivy-users/n_cMbFzf_1A/5edKgQgycx0J
# Same as before, with a kivy-based UI
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
@Mark-H
Mark-H / benchmark.php
Created December 7, 2012 17:41
MODX Performance Benchmark Snippet
<?php
// Use this line to prevent people from hammering your server.
if (!isset($_GET['super_secret']) || ($_GET['super_secret'] != 'secretpassword')) return 'Not authorized';
// Call this snippet uncached in a resource with template "empty":
// content: "[[!benchmark]]"
// Make sure to tag the resource as uncachable
// The intro
echo '<body style="font-family: sans-serif;">';
@christianhanvey
christianhanvey / modx-snippets.php
Last active June 14, 2023 13:02
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@christianhanvey
christianhanvey / gist:2768300
Created May 22, 2012 10:51
Update resource fields on save (MODX Revo 2.2)
<?php
/*
Update resource fields when they are saved
trigger on the following system events:
OnBeforeDocFormSave
OnDocFormSave
note: changing / inserting tv values is better done onDocFormSave as the process for saving tvs onBeforeDocFormSave is much more complicated (apparently)
@casschin
casschin / gist:1990245
Created March 7, 2012 01:16
Python webdriver api quick sheet
### Locating UI elements ###
# By ID
<div id="coolestWidgetEvah">...</div>
element = driver.find_element_by_id("coolestWidgetEvah")
or
from selenium.webdriver.common.by import By
element = driver.find_element(by=By.ID, value="coolestWidgetEvah")
# By class name:
@davidmz
davidmz / inline-worker.js
Created June 14, 2011 09:02
Создание Web Worker-а без использования внешнего JS-файла. Работает ТОЛЬКО в Google Chrome (остальные браузеры не поддерживают BlobBuilder).
/**
* Создание Web Worker-а без использования внешнего JS-файла.
* Работает ТОЛЬКО в Google Chrome (остальные браузеры не поддерживают BlobBuilder)
*/
function InlineWorker(code) {
var URL = (self.URL || self.webkitURL), BlobBuilder = (self.BlobBuilder || self.WebKitBlobBuilder);
var bb = new BlobBuilder();
bb.append("(" + code.toString() + ")();");
var url = URL.createObjectURL(bb.getBlob("application/javascript"));
var worker = new Worker(url);
@didip
didip / tornado_cookie_secret_generator.py
Created February 12, 2011 17:20
Generates secure cookie secret for Tornado Web Framework