Skip to content

Instantly share code, notes, and snippets.

View loderunner's full-sized avatar
👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎

Charles Francoise loderunner

👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎
View GitHub Profile
@loderunner
loderunner / getbroadaddr.c
Last active April 2, 2017 03:13
get broadcast address for an interface
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <netdb.h>
-------- START OF LOG --------
17:02:16 LOG: Core version: $Version: Talos_PC_distro; Talos_Executables-OSX-Final; 300763 2017-04-13 14:14:40 @builderm04.croteam.local; OSX-x86-Static-Final-Default$
17:02:16 LOG: Command: $
17:02:16 LOG: Initializing timer.
17:02:16 LOG: Timestamp: 2017/04/16 17:02:16
17:02:16 LOG: Binary name: Talos
17:02:16 LOG: Binary soft path: Bin/

GOTO challenge

Problem

Suppose a function that does the following, assuming all operations can fail and none can block:

  • Allocate XXX bytes of memory (on the heap)
  • Open file for reading
  • Read file into allocated buffer
  • Acquire lock

Recettes pour l'apéro

Guacamole

  • 2-3 avocats bien murs
  • jus d'1 citron vert
  • 1 petite échalote (ou 1/2 grosse)
  • 1-2 gousses d'ail
  • coriandre fraiche (généreusement)
  • une pincée de poivre de cayenne (alternativement, piments frais en fines lanières)
@loderunner
loderunner / activate_goenv.sh
Last active May 18, 2017 20:01
Set environment variables for Go development to a given workspace.
# Set environment for Go development. Inspired by Python virtualenv
# This file must be used with "source activate_goenv.sh" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_GOENV_GOPATH+_}" ] ; then
GOPATH="$_OLD_GOENV_GOPATH"
@loderunner
loderunner / pid2name.c
Created July 24, 2014 09:48
Retrieve process name from pid using sysctl (Darwin)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int main(int argc, char** argv) {
int mib[3], argmax;
size_t syssize;
char *procargs, *cp, *thiscmd;
/*
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
*/
/*
//
// fs_capabilities.m
//
// Created by Charles Francoise on 13/05/14.
// Copyright (c) 2014 Charles Francoise. All rights reserved.
//
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
@loderunner
loderunner / git-completion.sh
Created January 17, 2019 13:22
Install bash completions on macOS
ln -s /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash /usr/local/etc/bash_completion.d/git
@loderunner
loderunner / git-completion.sh
Created January 17, 2019 13:22
Install bash completions on macOS
ln -s /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash /usr/local/etc/bash_completion.d/git