Skip to content

Instantly share code, notes, and snippets.

ActiveAdmin.register User do
controller do
def update_resource(object, attributes)
update_method = attributes.first[:password].present? ? :update_attributes : :update_without_password
object.send(update_method, *attributes)
end
def scoped_collection
User.
joins('LEFT OUTER JOIN states ON states.user_id = users.id').
#!/usr/bin/env python3
import urwid
import urwid.curses_display
import os
import re
import signal
from operator import itemgetter
from urwid.canvas import CompositeCanvas
<?php
function streaming_data_node_info()
{
return array(
'frontend' => array(
'name' => t('Streaming server'),
'base' => 'streaming_data_frontend',
'description' => t('A server that will broadcast video stream to users.'),
'help' => t('Stream-proxy instance that will request configuration.'),
'has_title' => true,
package main
import (
"net/http"
"net/url"
"encoding/json"
"fmt"
"os"
"log"
)
#ifndef __BIT_OPS__
#define __BIT_OPS__
#ifndef _BV
#define _BV(x) (1 << (x))
#endif
/* #!ruby
*
* # generator for bitN macroes
$form['actions']['reset'] = array(
'#type' => 'markup',
'#markup' => format_string('<input type="reset" value="@value" class="form-submit" id="edit-reset" />', array(
'@value' => t('Reset')
))
);
$form['actions']['submit'] = array(
'#type' => 'button',
#include <avr/io.h>
int main(void){
TCCR1A |= (1 << COM1A1) | (1 << WGM11) | (1 << WGM10);
TCCR1B |= (1 << CS12);
DDRB |= (1 << PB1);
while(1){}
return 0;
}
var app = angular.module('samlib', ['ui.modal']);
app.config(['$httpProvider', function($httpProvider){
$httpProvider.responseInterceptors.push('httpRestarter');
}]);
app.factory('httpRestarter', ['$q', '$injector', '$timeout', 'notifier', function($q, $injector, $timeout, notifier){
var $http;
return function(r){
/**
* Parses JSON request bodies, populates $_POST
* for queries like PUT, PATCH, etc...
*/
public static function preprocessInput()
{
if ($_SERVER['HTTP_CONTENT_LENGTH'] == 0) // empty request
return;
$is_json = preg_match(self::$content_type_json, $_SERVER['HTTP_CONTENT_TYPE']);
/**
* Package implements a queue structure with task state tracking.
* Task can have 4 states:
* * Confirmed. When task was processed successfully it is confirmed.
* Confirm() function removes task from queue.
*
* * Discarded. Removed from queue, discarded flag set.
* Pretty much the same as Confirmed,
* just with differrent name to indicate cancellation
* of processing