This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"net/url" | |
"encoding/json" | |
"fmt" | |
"os" | |
"log" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __BIT_OPS__ | |
#define __BIT_OPS__ | |
#ifndef _BV | |
#define _BV(x) (1 << (x)) | |
#endif | |
/* #!ruby | |
* | |
* # generator for bitN macroes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
int main(void){ | |
TCCR1A |= (1 << COM1A1) | (1 << WGM11) | (1 << WGM10); | |
TCCR1B |= (1 << CS12); | |
DDRB |= (1 << PB1); | |
while(1){} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |