Skip to content

Instantly share code, notes, and snippets.

View bonekost's full-sized avatar
🧨

Martin bonekost

🧨
View GitHub Profile
@bonekost
bonekost / DHT11_BMP180_server.ino
Created March 13, 2016 14:38 — forked from attilaolah/DHT11_BMP180_server.ino
HTTP JSON API: ENC28J60 + DHT11 + BMP180 + UNO
// HTTP JSON API.
#include <EtherCard.h>
#include <DHT.h>
#include <Wire.h>
#include <Adafruit_BMP085_U.h>
// Ethernet:
@bonekost
bonekost / rpc.gd
Created May 19, 2016 14:17 — forked from bibby/rpc.gd
Godot HTTPClient usage
## rpc.gd
# An experiment in using HTTPClient
# for blocking RPCs
# @author bibby<bibby@bbby.org>
#
# get( url )
# post( url, body )
# put( url, body )
# delete( url )
@bonekost
bonekost / readme.md
Created November 9, 2016 20:43 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@bonekost
bonekost / Rspec.md
Created December 2, 2016 23:52 — forked from stevenyap/Rspec.md
Rspec testing cheatsheet

Precaution

  • Example groups are executed in random orders so setting let must be taken care of
  • before(:all) does not rollback transaction! Test data created remains in the test database! However, running rspec (on cmd line) will clear the test database.
    rake db:test:prepare will also clear the test database.

Testing samples:

Feature testing:

@bonekost
bonekost / index.md
Created December 5, 2016 08:15 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@bonekost
bonekost / Gruntfile.js
Created March 3, 2017 20:06 — forked from fervisa/Gruntfile.js
Gruntfile to process Angular/Ionic sass, coffee, haml files into css, js, html
/* Gruntfile.js
* Grunt workflow for building AngularJS/Ionic applications.
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
coffee: {
compile: {
@bonekost
bonekost / Update remote repo
Created May 1, 2017 22:09 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@bonekost
bonekost / secret_key_base
Created July 11, 2017 09:19 — forked from pablosalgadom/secret_key_base
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
So i was using Rails 4.1 with Unicorn v4.8.2 and when i tried to deploy my app it doesn't start properly and into the unicorn.log file i found this error message:
"app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)"
After a little research i found that Rails 4.1 change the way to manage the secret_key, so if we read the secrets.yml file located at exampleRailsProject/config/secrets.yml (you need to replace "exampleRailsProject" for your project name) you will find something like this:
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@bonekost
bonekost / gist:7db9b68182e13817ff69fe7c0f8e1a88
Created October 2, 2017 17:59 — forked from tamoyal/gist:2ea1fcdf99c819b4e07d
Upgrade Postgres 9.3 to 9.4 on Ubuntu
# Be sure to save your config files. Optional but I do:
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~
# Package repo (for apt-get)
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Also probably optional but I like to update sources and upgrade
sudo apt-get update
@bonekost
bonekost / registrations_controller.rb
Created October 6, 2017 19:32 — forked from evanbeard/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else