Skip to content

Instantly share code, notes, and snippets.

View maggocnx's full-sized avatar

Marco Grieb maggocnx

  • Gronic Systems
  • Birstein, Germany
View GitHub Profile
@maggocnx
maggocnx / timertest.c
Created July 8, 2013 07:37
Timer example
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/hrtimer.h>
#include <linux/ktime.h>
unsigned long timer_interval_ns = 1e6;
static struct hrtimer hr_timer;
enum hrtimer_restart timer_callback( struct hrtimer *timer_for_restart )
{
@maggocnx
maggocnx / controller.js
Created July 22, 2013 07:34
Angular Demo
function SettingsCtrl($scope, $http){
$http.get("settings.json")
.success(function(data,status){
$scope.settings = data;
});
$scope.submit = function(){
console.log($scope.settings);
$http.post("settings/", $scope.settings).
success(function(data,status){})
var app = angular.module('gronicom', []);
app.factory('socket', function ($rootScope) {
var socket = io.connect();
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
var express = require("express");
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var fs = require('fs');
var printer = require("./printer.js");
app.listen(3000);
var clientSocket;
@maggocnx
maggocnx / express body
Created September 7, 2013 06:52
Show post Data in express
app.use (function(req, res, next) {
var data='';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
@maggocnx
maggocnx / app.js
Last active March 4, 2023 11:26
mongoskin rest api
var express = require('express')
, mongoskin = require('mongoskin')
var app = express()
app.use(express.bodyParser())
var db = mongoskin.db('localhost:27017/skintest', {safe:true});
app.param('collectionName', function(req, res, next, collectionName){
req.collection = db.collection(collectionName)
@maggocnx
maggocnx / undefined.js
Last active December 28, 2015 04:48
Find console.log which outputs undefined
origLog = console.log;
console.log = function(arg){
if(typeof arg == "undefined")
console.trace(undefined);
}
@maggocnx
maggocnx / app.js
Created November 13, 2013 13:26
Simulating latency in express
app.use(function(req,res,next){setTimeout(next,1000)}); // Simulating latenceny
@maggocnx
maggocnx / wait.sh
Created November 28, 2013 15:47
Waiting for server going online
#! /bin/bash
wait=true
while $wait
do
sleep 1
ready=$(curl -sL -w "%{http_code}\\n" $1 -o /dev/null)
if [ $ready -eq 200 ]
then
wait=false
fi
@maggocnx
maggocnx / app.js
Created December 17, 2013 10:16
Dyndns Replacement
var express = require('express');
var app = express();
var dynAddress = null;
var dynPort = "";
app.get("/reg", function(req,res){
if(req.query.port)
dynPort = req.query.port;