Skip to content

Instantly share code, notes, and snippets.

View lanzafame's full-sized avatar

Adrian Lanzafame lanzafame

View GitHub Profile
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
$ curl -O ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
$ tar -xzvf ncurses-5.9.tar.gz
$ cd ./ncurses-5.9
$ ./configure --prefix=/usr/local \
--without-cxx --without-cxx-binding --without-ada --without-progs --without-curses-h \
--with-shared --without-debug \
--enable-widec --enable-const --enable-ext-colors --enable-sigwinch --enable-wgetch-events \
&& make
$ sudo make install
The guide to getting fired: horrendous abuses of GCC.
For fun only: most of what is listed here are undefined with respect to the C standard, hence for obvious reasons they are not portable (sigh of relief comming from audience).
Tested with GCC (and codepad), so use #ifdef __GNUC__ to enclose all of these examples.
1: Map - Reduce in C ... as Macros ...
#define MAP(fn, ret_type, fst, ...) ({ \
typeof(fst) from[] = {(fst), __VA_ARGS__ }; \
ret_type to[sizeof(from)/sizeof(typeof(fst))]; \
int i, n = sizeof(from)/sizeof(typeof(fst)); \
@lanzafame
lanzafame / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lanzafame
lanzafame / .lldbinit
Last active August 29, 2015 14:19 — forked from zrxq/.lldbinit
comma script import ~/lldb/subl.py
comma script add -f subl.subl subl
@lanzafame
lanzafame / concurrency-in-go.md
Last active September 4, 2015 03:11 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
@lanzafame
lanzafame / main.go
Created October 20, 2015 14:08 — forked from mattetti/main.go
Go's reflection example
package main
import(
"fmt"
"reflect"
)
func main(){
// iterate through the attributes of a Data Model instance
for name, mtype := range attributes(&Dish{}) {
@lanzafame
lanzafame / taskgit
Created October 29, 2015 04:47 — forked from unode/taskgit
#!/bin/sh
# copyright 2014 Renato Alves
# distributed under the GPL licence
if [ -z "$TASKDIR" ]; then
#TODO Look for data location in rc:location instead of assuming ~/.taskrc
TASKDIR="$(grep data.location $HOME/.taskrc | cut -d '=' -f 2)"
fi
if test -n $HOME
set -l NIX_LINK $HOME/.nix-profile
if test ! -L $NIX_LINK
echo "creating $NIX_LINK" >&2
set -l _NIX_DEF_LINK /nix/var/nix/profiles/default
/nix/store/cdybb3hbbxf6k84c165075y7vkv24vm2-coreutils-8.23/bin/ln -s $_NIX_DEF_LINK $NIX_LINK
end
set -x PATH $NIX_LINK/bin $NIX_LINK/sbin $PATH
@lanzafame
lanzafame / ssh_agent_start.fish
Last active April 23, 2016 05:04 — forked from rsff/ssh_agent_start.fish
ssh agent for fish
#this script can never fail
#i use it in the fish_config
#call it with start_agent
setenv SSH_ENV $HOME/.ssh/environment
function ssh_agent_start
if [ -n "$SSH_AGENT_PID" ]
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null