Skip to content

Instantly share code, notes, and snippets.

def _set_files(files):
if current.request.ajax:
current.response.js = (current.response.js or '') + """;(function ($) {
var srcs = $('script').map(function(){return $(this).attr('src');}),
hrefs = $('link').map(function(){return $(this).attr('href');});
$.each(%s, function() {
if ((this.slice(-3) == '.js') && ($.inArray(this.toString(), srcs) == -1)) {
var el = document.createElement('script'); el.type = 'text/javascript'; el.src = this;
document.body.appendChild(el);
} else if ((this.slice(-4) == '.css') && ($.inArray(this.toString(), hrefs) == -1)) {
script = SCRIPT("""
jQuery(function() { var t = 10; (function run() {if ((function() {
var el = jQuery("#%(id)s");
if (el.AnyTime_picker == undefined) { return true; }
el.AnyTime_noPicker().AnyTime_picker(
jQuery.extend({format: "%%Y-%%m-%%d", labelTitle: "%(title)s"},
%(date_option)s));
})()) {setTimeout(run, t); t = 2*t;}})();});
""" % dict(id=_id, title=current.T('Choose date'),
date_option=_get_date_option()))
@kenji4569
kenji4569 / gist:1326961
Created October 31, 2011 05:28
descendants_from_node
def descendants_from_node(self, node, include_self=False):
db, table_node = self.db, self.settings.table_node
node = self._load_node(node)
left, right = node.left, node.right
if include_self:
left -= 1
right += 1
return db(table_node.left > left)(table_node.right < right)(
--- a/modules/plugin_lazy_options_widget.py
+++ b/modules/plugin_lazy_options_widget.py
@@ -37,6 +37,9 @@ class lazy_options_widget(SQLFORM.widgets.options):
self.keyword = self.keyword % dict(fieldname=field.name)
requires = field.requires
+
+ if isinstance(requires, IS_EMPTY_OR):
+ requires = requires.other
if not isinstance(requires, (list, tuple)):
@kenji4569
kenji4569 / gist:4123139
Created November 21, 2012 05:09
simple block-based task queue
NSMutableArray *tasks = [[NSMutableArray alloc] init];
[tasks addObject: ^() {
NSLog(@"task1");
}];
[tasks addObject: ^() {
NSLog(@"task2");
}];
for (void (^task)() in tasks) {
task();
}
@kenji4569
kenji4569 / gist:4123150
Created November 21, 2012 05:11
simple block-based task queue with cascade
NSMutableArray *tasks = [[NSMutableArray alloc] init];
void (^nextTask)() = ^() {
[tasks removeObjectAtIndex: 0];
if ([tasks count] > 0) {
void (^task)() = [tasks objectAtIndex: 0];
task();
}
};
[tasks addObject: ^() {
NSLog(@"task1");
@kenji4569
kenji4569 / gist:4123263
Created November 21, 2012 05:36
simple block-based task queue with cascade and async trail processing
dispatch_queue_t trail_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t trail_group = dispatch_group_create();
NSMutableArray *tasks = [[NSMutableArray alloc] init];
void (^nextTask)() = ^() {
[tasks removeObjectAtIndex: 0];
if ([tasks count] > 0) {
void (^task)() = [tasks objectAtIndex: 0];
task();
} else {
@kenji4569
kenji4569 / gist:4256217
Created December 11, 2012 05:57
Breadcrumbs; My first winrt custom control.
//////////////////////////////////////////////////////
// In SamplePage.xaml
//////////////////////////////////////////////////////
<local:Breadcrumbs Height="25" MaxWidth="475"
ItemsSource="{Binding Source={StaticResource sampleBreadcrumbsViewSource}}"
>
<local:Breadcrumbs.ItemTemplate>
<DataTemplate>
<Button VerticalAlignment="Top" Margin="0,0,5,0"

Resize Vagrant Disk

Step 1: Create VDI disk from VMDK disk type

# Turn off your Vagrant machine
$ vagrant halt

# Comment out this line in Vagrantfile
# config.disksize.size = '30GB'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.