Skip to content

Instantly share code, notes, and snippets.

View bonekost's full-sized avatar
🧨

Martin bonekost

🧨
View GitHub Profile
@bonekost
bonekost / motunit.c
Last active February 16, 2024 21:48
RTOS app for 8 inputs and 8 outputs
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_intr_alloc.h"
#include "esp_log.h"
#define NUM_GPIO_INPUTS 8
#define NUM_GPIO_OUTPUTS 8
#define DEBOUNCE_TIME_MS 50 // Debounce time in milliseconds
@bonekost
bonekost / fix_migration.rb
Created March 6, 2019 07:42
Add migration release to all
Dir.glob('./db/migrate/*.rb') do |file|
text = File.read(file)
new_content = text.gsub(/< ActiveRecord::Migration/, "< ActiveRecord::Migration[4.2]")
File.open(file, "w") {|f| f.puts new_content }
end
@bonekost
bonekost / huawei-gsm
Created December 10, 2018 12:13 — forked from imrehg/huawei-gsm
[connection]
id=huawei-gsm
type=gsm
[gsm]
apn=rsaweb.mobi
[ipv4]
dns-search=
method=auto
@bonekost
bonekost / gist:c3571803644c649c5c066dc0d01a9982
Created February 2, 2018 14:38 — forked from wikimatze/gist:9790374
Github Two-Factor Authentication Failed For HTTPS

I heard from GitHub Two-Factor Authentication](https://github.com/blog/1614-two-factor-authentication) nearly a couple of days ago when I was reading my RSS feed. I enabled it and couldn' push to any of my repositories anymore. Learn in this blog post how to fix it.

Two-Factor Authentication

"Is a process involving two stages to verify the identity of an entity trying to access services in a computer or in a network". Github solves this authentication with sending an SMS to a device which wants to push to their platform.

Enabling Two-Factor Authentication

@bonekost
bonekost / mysql-docker.sh
Created October 17, 2017 14:57 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@bonekost
bonekost / iButtonRW.ino
Created October 15, 2017 11:07 — forked from swiftgeek/iButtonRW.ino
RW1990 programmer, with arduino
// Based on https://danman.eu/blog/cloning-ibutton-using-rw1990-and-avr/
// and: http://elimelecsarduinoprojects.blogspot.com/2013/06/read-dallas-ibutton-arduino.html
// By Swift Geek 28-08-2015
// TODO: danger to atmega328! Use OpenCollector logic!
// Used 4.8kΩ Pull-up and 3.1 Vcc for arduino/pull-up
#include <OneWire.h>
OneWire ibutton (8); // I button connected on PIN 2.
@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
@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 / 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 / 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