Skip to content

Instantly share code, notes, and snippets.

@akcoder
akcoder / udpserver.c
Created December 4, 2019 19:20
A modified version of the UDP echo server from CMU. Modified to echo back the number of bytes sent, not just the strlen of the data sent. Fixes issue with the SmartRG CPES where they send 24 NULL bytes.
/*
* https://www.cs.cmu.edu/afs/cs/academic/class/15213-f99/www/class26/udpserver.c
* udpserver.c - A simple UDP echo server
* usage: udpserver <port>
*/
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
@akcoder
akcoder / modal-draggable.js
Last active November 29, 2016 19:58
modal-draggable directive for Angular1. Allows UIB modal dialogs to be dragged around the screen. Does bounds checking to prevent the window from being dragged off screen.
(function (angular) {
"use strict";
modalDraggable.$inject = ['$window', '$document', '$interval', '$log'];
angular.module('apt.widgets')
.directive('modalDraggable', modalDraggable);
function modalDraggable($window, $document, $interval, $log) {
return function (scope, element) {
var startX = 0;
@akcoder
akcoder / Symfony Toolbar Ajax Update
Last active December 22, 2015 09:49 — forked from mbence/Symfony Toolbar Ajax Update
Update the Symfony2 Web Debug Toolbar at the bottom of the page (if in debug mode). Updated from another gist which appended the contents of the wdt page. This one only updates the toolbar for the request.
$(document).ajaxComplete(function (event, xhr, ajaxOption) {
if (xhr.getResponseHeader('x-debug-token')) {
$.get(window.location.protocol + '//' + window.location.hostname + '/app_dev.php/_profiler/' + xhr.getResponseHeader('x-debug-token'), function (data, status, innerXhr) {
var toolbar = $(data).filter('.sf-toolbarreset');
$('.sf-toolbarreset').remove();
$('.sf-toolbar').append(toolbar);
});
}
});