Skip to content

Instantly share code, notes, and snippets.

View vasilakisfil's full-sized avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile
@vasilakisfil
vasilakisfil / android_debug.h
Created March 31, 2012 10:47
C++ code (the patch is the last file )
/***************************************************************************
** This file is part of the generic algorithm library Wiselib. **
** Copyright (C) 2008,2012 by the Wisebed (www.wisebed.eu) project. **
** **
** The Wiselib is free software: you can redistribute it and/or modify **
** it under the terms of the GNU Lesser General Public License as **
** published by the Free Software Foundation, either version 3 of the **
** License, or (at your option) any later version. **
** **
** The Wiselib is distributed in the hope that it will be useful, **
@vasilakisfil
vasilakisfil / Android.mk
Created March 31, 2012 10:49
Java code ( the testing app)
# build file written to describe the C and C++ source files to the Android NDK
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := debugTest
LOCAL_CXXFLAGS := -W
LOCAL_SRC_FILES := debug_test.cpp
#This definition is needed by wiselib
LOCAL_C_INCLUDES := /home/vasilakis/Development/wiselib/wiselib.testing/ \
/home/vasilakis/Development/wiselib/wiselib.stable/
@vasilakisfil
vasilakisfil / main_map.js
Created November 29, 2012 11:34
The code in lines 15-37 does not return all the markers...
var GMAPS = window.GMAPS || {};
GMAPS.mainMap = function() {
var map;
var infowindow = new google.maps.InfoWindow();
var jsonObject = {};
function addMarkers() {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "/home.json", true );
xhr.onreadystatechange = function () {
var GMAPS = window.GMAPS || {};
GMAPS.mainMap = function() {
var map;
var infowindow = new google.maps.InfoWindow();
var jsonObject = {};
function addMarkers() {
var xhr = new XMLHttpRequest();
xhr.open( "GET", "/home.json", true );
xhr.onreadystatechange = function () {
@vasilakisfil
vasilakisfil / gist:9722841
Last active August 29, 2015 13:57
Share state between ruby objects
class TestClass
@class_var_alternative = "class_var_alternative"
class << self
attr_accessor :class_var_alternative
end
end
puts TestClass.class_var_alternative
TestClass.class_var_alternative = "new value"
@vasilakisfil
vasilakisfil / PacketInfo.java
Created April 21, 2014 12:33
Useless Java getters/setters
package server;
public class PacketInfo {
private String sipAddress;
private String branch;
private String viaAddress;
public String receiverUser;
public String senderUsername;
public String senderAddress;
@vasilakisfil
vasilakisfil / run.sh
Last active February 16, 2024 09:05
New linux machine setup
#install essential stuff
sudo apt-get install build-essential autoconf locate
sudo apt-get install git guake zsh curl vim vim-gtk3 postgresql-client \
postgresql postgresql-contrib redis golang direnv tmux bat ripgrep fzf
curl -L http://install.ohmyz.sh | sh
chsh -s /bin/zsh
zsh
#edit pg_hba.conf
@vasilakisfil
vasilakisfil / users_controller.rb
Last active November 16, 2015 22:58
restfull api in rails
class Api::V1::UsersController < Api::V1::BaseController
skip_before_filter :authenticate_user, only: [:create, :resetpassword]
def index
users = policy_scope(User)
render json: users, each_serializer: Api::V1::UserSerializer
end
def resetpassword
@vasilakisfil
vasilakisfil / authentication_helper.rb
Last active August 29, 2015 14:06
authentication_helper
module AuthenticationHelper
def sign_in(user)
header('Authorization', "Token token=\"#{user.authentication_token}\", user_email=\"#{user.email}\"")
end
def create_and_sign_in_user
user = FactoryGirl.create(:user)
sign_in(user)
return user
end
@vasilakisfil
vasilakisfil / users_spec.rb
Created September 16, 2014 18:27
rspec tests
require 'rails_helper'
describe Api::V1::UsersController, type: :api do
context :index do
before do
5.times{ FactoryGirl.create(:user) }
5.times{ FactoryGirl.create(:admin) }
FactoryGirl.create(:super_admin)
sign_in(User.regular.last)
end