Skip to content

Instantly share code, notes, and snippets.

View antonyalkmim's full-sized avatar

Antony Alkmim antonyalkmim

View GitHub Profile
@antonyalkmim
antonyalkmim / main.cpp
Last active April 7, 2016 23:07
Semaforo com contador ArduinoUNO
#include <avr/io.h>
#include <util/delay.h>
void display(int num){
switch(num){
case 9:
PORTC = (1 << 4);
PORTB &= ~(1 << 5);
@antonyalkmim
antonyalkmim / index.js
Last active July 24, 2018 18:18
Textfield masks on Appcelerator Titanium Android. Solution to stop infinite loops when changing value of a textfield inside your change listener on Appcelerator Titanium Android.
var changed = false;
$.texfield.addEventListener("change", function(e){
if(OS_IOS || (OS_ANDROID && !changed)){
e.source.value = "My Mask"; //Masker.toPatter();
}
changed = !changed;
//Set cursor at the end
var len = event.source.value.length;
$.textfield.setSelection(len, len);
@antonyalkmim
antonyalkmim / metodo.newton.js
Last active April 5, 2016 13:16
Método de aproximação Newton para encontrar raízes de equações
var calculateX = function(xInit){
var x = xInit;
var err = Math.pow(10,-5);
var xAux = x;
var i = 0;
do{
xAux = x;
var f = (Math.pow(x,4) + 2*Math.pow(x,3) - 13*Math.pow(x,2) - 14*x + 24).toFixed(5);
var F = (4*Math.pow(x,3) + 6*Math.pow(x,2) - 26*x - 14).toFixed(5);
@antonyalkmim
antonyalkmim / mongo-autostart-osx.md
Created April 29, 2016 01:20 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

/*
* main.cpp
*
* Created on: 16/05/2016
* Author: puc
*/
#include <avr/io.h>
#include <util/delay.h>
#include "serial.hpp"
@antonyalkmim
antonyalkmim / ADC.hpp
Last active June 13, 2016 23:26 — forked from anonymous/ADC.hpp
Arduino - Conversor Analogico/Digital
/*
* ADC.hpp
*
* Created on: 06/06/2016
* Author: puc
*/
#include <avr/io.h>
@antonyalkmim
antonyalkmim / display.hpp
Last active June 16, 2016 23:21
Arduino - Display LCD
/*
* Enviar caracteres e comandos ao LCD com via de dados de 8 bits.
* c é o dado e cd indica se é instrução ou caractere (0 ou 1).
**/
void cmd_LCD(unsigned char c, char cd);
/* Inicialização do LCD com via de dados de 8 bits */
void inic_LCD_8bits();
/* Escrita no LCD – dados armazenados na RAM */
void escreve_LCD(char *c);
/* Escrita no LCD – dados armazenados na FLASH */
@antonyalkmim
antonyalkmim / Results+Rx.swift
Created July 24, 2016 05:11 — forked from fpillet/Results+Rx.swift
turn Realm auto-updating Results into an RxSwift Observable sequence
//
// Results+Rx.swift
//
// Make Realm auto-updating Results observable. Works with Realm 0.98 and later, RxSwift 2.1.0 and later.
//
// Created by Florent Pillet on 12/02/16.
// Copyright (c) 2016 Florent Pillet. All rights reserved.
//
import Foundation
#include <Servo.h>
Servo motor;
int pos;
void setup(){
motor.attach(6);
motor.write(0);
}
@antonyalkmim
antonyalkmim / binarysearch.m
Last active September 25, 2016 19:40
Algoritmos de busca e ordenação implementados no OCTAVE/MATLAB
function ret = binarysearch(el,vet)
inf = 1;
sup = numel(vet);
while(inf <= sup)
meio = idivide(sup + inf, 2);
if(el == vet(1, meio))
ret = meio;
return;