Skip to content

Instantly share code, notes, and snippets.

@Moddus
Moddus / root_service.go
Last active December 17, 2015 07:59
Example: Appengine and go-restful
package api
import (
"appengine"
"github.com/Moddus/go-restful"
)
type Basic struct {
Version string
Message string
@Moddus
Moddus / example.c
Created May 17, 2013 09:12
Example error handling in c.
/**
* error type
*/
typedef int state_t;
/**
* error states
*/
#define STATE_SUCCESS (0)
#define STATE_NULL_PTR (1)
@Moddus
Moddus / adb am gcm.md
Last active February 15, 2022 09:23
Android GCM braodcast intent on adb shell to test REGISTRATION

general:

am broadcast -a <Intent-Name> -n <Package>/<Receiver-Name-with-leading-dot> <Extras>

example:

am broadcast -a com.google.android.c2dm.intent.REGISTRATION -n de.example/.GCMBroadcastReceiver 
--es "registration_id" "1234"

tail recursive vs not tail recursive

not tail recursive

def fac( n: Int ): Int =
    if ( n == 0 ) 1
    else n * fac( n - 1 )
@Moddus
Moddus / adb am gcm.md
Last active January 1, 2016 00:19
Some stuff i need for Android development

general:

am broadcast -a <Intent-Name> -n <Package>/<Receiver-Name-with-leading-dot> <Extras>

example:

am broadcast -a com.google.android.c2dm.intent.REGISTRATION -n de.example/.GCMBroadcastReceiver 
--es "registration_id" "1234"
fd = socket(AF_INET, SOCK_DGRAM, 0);
server_addr.sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
server_addr.sin_len = sizeof(struct sockaddr_in);
#endif
server_addr.sin_addr.s_addr = "127.0.0.1";
server_addr.sin_port = htonl(7);
memset((void *) buf, ’A’, sizeof(buf));
# commands
alias lsa='ls -lah'
alias l='ls -lah'
alias ll='ls -lh'
alias la='ls -lAh'
alias sl=ls # often screw this up
alias ..='cd ..'
alias ...='cd ../..'
alias less='less -N'
/*
* Search a particular hash table for a conversation with the specified
* {addr1, port1, addr2, port2} and set up before frame_num.
*/
static conversation_t *
conversation_lookup_hashtable(GHashTable *hashtable, const guint32 frame_num, const address *addr1, const address *addr2,
const port_type ptype, const guint32 port1, const guint32 port2)
{
conversation_t* convo=NULL;
conversation_t* match=NULL;
#!/bin/bash
COMPILE=""
ssh bsd9 "mkdir -p $1 && rm -rf $1/*"
for filename in *; do
if [[ -f $filename ]]; then
EXT=${filename##*.}
if [ "$EXT" == c ] || [ "$EXT" == h ]; then
@Moddus
Moddus / _service.md
Last active August 29, 2015 14:12 — forked from naholyr/_service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)