Skip to content

Instantly share code, notes, and snippets.

Avatar

Filippos Vasilakis vasilakisfil

View GitHub Profile
@vasilakisfil
vasilakisfil / android_debug.h
Created Mar 31, 2012
C++ code (the patch is the last file )
View android_debug.h
/***************************************************************************
** 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 Mar 31, 2012
Java code ( the testing app)
View Android.mk
# 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 Nov 29, 2012
The code in lines 15-37 does not return all the markers...
View main_map.js
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 () {
View gist:4170519
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 Aug 29, 2015
Share state between ruby objects
View gist:9722841
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 Apr 21, 2014
Useless Java getters/setters
View PacketInfo.java
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 Jun 11, 2020
New linux machine setup
View run.sh
#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 Nov 16, 2015
restfull api in rails
View users_controller.rb
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
View authentication_helper.rb
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
View users_spec.rb
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