Skip to content

Instantly share code, notes, and snippets.

func parseAddr(spec string) (p string, a string, e error) {
split := strings.Split(p, "://")
switch len(split) {
case 1:
p = "tcp"
a = split[0]
case 2:
p = strings.ToLower(split[0])
a = split[1]
function cla_block_view($delta = '')
{
$block = array();
switch ($delta) {
case 'cla':
$block['subject'] = t('Custom login actions');
$block['contents'] = array(
'#type' => 'markup',
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){