Skip to content

Instantly share code, notes, and snippets.

View kevinvaldek's full-sized avatar

Kevin Valdek kevinvaldek

View GitHub Profile
# lib/mongo_mapper/plugins/callbacks.rb
module MongoMapper
module Plugins
module Callbacks
module InstanceMethods
def self.included(model)
model.class_eval do
extend ActiveModel::Callbacks
# config/boot.rb
# ..bottom of file
# FROM
require 'rails/all'
# require "active_model/railtie"
# require "active_record/railtie"
# require "action_controller/railtie"
# require "action_view/railtie"
# Gemfile
# ..other specs
gem "mongo_mapper", :git => "git://github.com/jnunemaker/mongomapper.git"
class Bike
include MongoMapper::Document
key :_type, String
key :brand, String
end
class TwoWheeler < Bike
key :has_suspension, Boolean
end
form_for @post, :remote => true
# =>
# <form action="/posts" id="create-post" method="post" data-remote="true">
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct list_item {
struct list_item *next;
int data;
};
typedef struct list_item ListItem;
new Request.HTML({
update: updateElement,
onSuccess: function() {
rails.applyEvents(updateElement);
}
});
if (command.is(Command.DoorLocks.LOCK_STATE)) {
LockState lockState = (LockState) command;
Log.d(TAG, "Car is locked: " + lockState.isLocked());
}
@kevinvaldek
kevinvaldek / vehicle-location.js
Created September 23, 2017 14:19
HMKit Node.js vehicle location example
describe(`VehicleLocationCommand`, () => {
it(`should get vehicle location`, async () => {
const response = await hmkit.telematics.sendCommand(
vehicleSerial,
hmkit.commands.VehicleLocationCommand.get()
);
expect(response.parse()).toEqual(
expect.objectContaining({
latitude: expect.any(Number),
@kevinvaldek
kevinvaldek / Web Bluetooth + Phoenix Channels
Created November 10, 2017 13:26
elixir-meetup-berlin-november-2018
Great to have seen you all at the meetup. Here's links to the material I used in the talk:
WebBluetooth community: https://plus.google.com/communities/108953318610326025178
Intro to Bluetooth Low Energy: https://www.slideshare.net/zdennis/btle-bluetooth-low-energy-and-corebluetooth
Current implementation status: https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md
Web Bluetooth tutorial: https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web