Skip to content

Instantly share code, notes, and snippets.

int
blocked_shot(int e)
{
int t, a, x, y;
double adx, ady, edx, edy, div;
/* AIship_track(e) returns direction of enemy movement */
t = AIship_track(e);
/* AIship_aimdir(e) is an autoaim function that returns the
angle required to hit the enemy ship */
a = AIship_aimdir(e);
@droyo
droyo / Examples
Created October 28, 2010 04:01
Binary regexp parser for cifsd by cinap_lenrek
Some usage of the parser:
EXAMPLES
smb.c:803: if(!unpack(h, p, e, "#0b{*2}#1w{}")){
smb.c:827: if(!unpack(h, p, e, "#0b{*2}#1w{_f}", r->o->nameunpack, &name)){
smb.c:861: if(!unpack(h, p, e, "#0b{*2wl__________}#1w{_f}", &attr, &mtime, r->o->nameunpack, &name)){
smb.c:907: if(!unpack(h, p, e, "#0b{*2}#1w{_f}", r->o->nameunpack, &name)){
smb.c:945: if(!unpack(h, p, e, "#0b{*2w}#1w{}", &fid)){
@droyo
droyo / gist:5333884
Last active December 15, 2015 22:29
signalfd SFD_NONBLOCK test
#include <stdio.h>
#include <sys/signalfd.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>
int sigfd_read(int fd) {
ssize_t n;
struct signalfd_siginfo buf;
# Directory where the Elasticsearch binary distribution resides
ES_HOME=/usr/share/elasticsearch
# Heap Size (defaults to 256m min, 1g max)
ES_HEAP_SIZE=256m
ES_MIN_MEM=$ES_HEAP_SIZE
ES_MAX_MEM=$ES_HEAP_SIZE
# Heap new generation
#ES_HEAP_NEWSIZE=
[DEFAULT]
# Show debugging output in log (sets DEBUG log level output)
# debug = true
# The DHCP agent will resync its state with Quantum to recover from any
# transient notification or rpc errors. The interval is number of
# seconds between attempts.
# resync_interval = 5
# The domain name sent to all instances
dhcp_domain = example.net
[DEFAULT]
# Show debugging output in log (sets DEBUG log level output)
# debug = True
# The Quantum user information for accessing the Quantum API.
auth_url = http://example.net:35357/v2.0/
# auth_region = RegionOne
admin_tenant_name = *****
admin_user = ******
admin_password = ******
@droyo
droyo / grpc-generate-access-token.go
Created December 26, 2019 23:19
GCP iamcredentials.googleapis.com GenerateAccessToken GRPC example
package main
import (
"log"
"flag"
"path"
"time"
"context"
"github.com/kr/pretty"
@droyo
droyo / service-account.go
Created March 20, 2020 21:38
Fetch iam service account
import (
"context"
"flag"
"log"
"path"
"github.com/kr/pretty"
"google.golang.org/api/iam/v1"
)
# let inc p = let v = !p in incr p; v;;
val inc : int ref -> int = <fun>
# let x = ref 0;;
val x : int ref = {contents = 0}
# type t_read = {tag: int; fid: int; offset: int; count: int};;
type t_read = { tag : int; fid : int; offset : int; count : int }
# let r = {tag=(inc x); fid=(inc x); offset=(inc x); count=(inc x)};;
val r : t_read = {tag = 3; fid = 2; offset = 1; count = 0}
# let x = ref 0;;
val x : int ref = {contents = 0}
// Adds, then removes an alias IP from a VM
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"time"