Skip to content

Instantly share code, notes, and snippets.

View FernandoBasso's full-sized avatar

Fernando Basso FernandoBasso

View GitHub Profile
#include <stdio.h>
void say_msg(char msg[]);
int main(void) {
char str[] = "C is a butt-kicking programming language.\n";
say_msg(str);
printf("%ld\n", sizeof(str)); // 43. WTF?!
printf("%ld\n", sizeof(&str)); // 8 or 4. Why? Isn't str already a pointer variable.
:function! SwapArgs()
. subst :(\zs\([^,]\+\), \([^)]\+\):\2, \1
endfunction
" :call SwapArgs()
" nnoremap <Leader>sa :call SwapArgs()<CR>
@FernandoBasso
FernandoBasso / bashrc
Last active August 29, 2015 13:57
List all categories, and all the posts in each category.
unset HISTFILESIZE
HISTSIZE=2000
PROMPT_COMMAND="${PROMPT_COMMAND:-:}; history -a"
export HISTSIZE PROMPT_COMMAND
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
var http = require('http');
var pg = require('pg');
var constr = 'postgres://devel:1234@127.0.0.1/tcc';
var server = http.createServer(function(req, res) {
pg.connect(constr, function(err, client, done) {
var handleError = function(err) {
orig=tmp.c
dest=./bin/tmp.bin
SDL_FLAGS := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs);
build:
gcc $(orig) -o $(dest) -std=c99 -Wall -pedantic $(SDL_FLAGS) $(SDL_LDFLAGS)
#include <iostream>
class Vector
{
public:
float x, y;
};
class Point
{
#!/usr/bin/env ruby -wU
#
# Source:
#
# http://asciidoctor.org/docs/editing-asciidoc-with-live-preview/#using-bundler
#
Bundler.require(:default)
@FernandoBasso
FernandoBasso / app.js
Last active August 29, 2015 14:18
ionic open view upon clicking button
var l = function l() {
console.log.apply(console, arguments);
};
var itemsDb = null;
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
<%= form_for @user_category do |f| %>
<p>
<%= f.label :description %>
<%= f.text_field :description %>
</p>
<p>
<%= f.radio_button :status, true, :id => 'status_true' %>
<%= f.label 'Ativo', :for => 'status_true' %>
@FernandoBasso
FernandoBasso / three-table-join.sql
Created August 14, 2015 13:54
Three-table sql join
-- I have the tables `category`, `subscription` and `document`. Document
-- references subscription, and subscription references category. I am trying to
-- get the category name based on a documents PK. I am doing something like this:
SELECT category_name FROM categorias
INNER JOIN subscription ON category_fk = category_pk
INNER JOIN documents ON subscription_fk = document_pk
AND document_pk = 14;