Skip to content

Instantly share code, notes, and snippets.

View KaduNovoK's full-sized avatar

Carlos Eduardo Rodrigues dos Santos KaduNovoK

View GitHub Profile
@KaduNovoK
KaduNovoK / led-blinking.ino
Last active December 30, 2015 20:49
Code to blink a LED on Arduino.
/**
* Code to blink a LED
*
* Author: Kadu NovoK
* Date: 12-09-2013
* Version: 1.0
*/
void setup() {
pinMode(13, OUTPUT); // Set the LED
@KaduNovoK
KaduNovoK / transaction.php
Created January 8, 2014 11:42
Transactions in Symfony 2 and Doctrine 2
<?php
// Code sample to use Transactions
// Get the Entity Manager
$em = $this->getDoctrine()->getEntityManager();
// Suspend the auto-commit
$em->getConnection()->beginTransaction();
@KaduNovoK
KaduNovoK / array_sum.php
Last active August 29, 2015 13:57
Sum the elements of a field in a array with predefined fields
<?php
// Log of players result
$dataArray = array(
array('player' => 'John', 'day' => '1', 'points' => 230),
array('player' => 'Hans', 'day' => '1', 'points' => 300),
array('player' => 'Karl', 'day' => '1', 'points' => 200),
array('player' => 'John', 'day' => '1', 'points' => 250),
array('player' => 'Hans', 'day' => '1', 'points' => 300),
@KaduNovoK
KaduNovoK / sum_program.pas
Created April 9, 2014 02:14
Program to sum two integer values
{
Program to sum two values
Just to remember the basic of pascal
(c) Kadu NovoK <[email protected]>
}
program sum_program; // Header
{ Statements }
var
var teams = [1, 2, 3, 4, 5, 6, 7, 8, 9];
teams.forEach(function(value1, idx1) {
teams.forEach(function(value2, idx2) {
if (idx2+1 > idx1+1) {
console.log(value1, value2)
}
})
});
angular.module('myModule')
.config(function ( $httpProvider) {
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}).factory('featuresData', function ($http) {
return{
doCrossDomainGet: function() {
return $http({
url:'http://other.domain.com',
method: 'GET'
})
@KaduNovoK
KaduNovoK / colors.html
Last active August 29, 2015 14:02
html + js to generate a color variations
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Colors</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
@KaduNovoK
KaduNovoK / screen_setup.sh
Created June 25, 2014 10:45
Set my second screen resolution
#!/bin/bash
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA1 "1920x1080_60.00"
xrandr --output VGA1 --mode "1920x1080_60.00"
@KaduNovoK
KaduNovoK / json_reader.php
Created July 10, 2014 19:58
Proxy and json reader files.
<?php
$url = "http://localhost/labs/0100/02.php?url=http://ip.jsontest.com/";
$jsonContent = file_get_contents($url);
$jsonObject = json_decode($jsonContent);
var_dump($jsonObject);
echo($jsonObject->ip);
@KaduNovoK
KaduNovoK / phone.js
Last active August 29, 2015 14:07
[JQuery] Phone and Cellphone Mask
var $phone = $("#fos_user_registration_form_phone");
var maskOptions = {onKeyPress: function(phone) {
var masks = ['(00) 0000-0000', '(00) 00000-0000'];
mask = phone.match(/^\([0-9]{2}\) 9/g)
? masks[1]
: masks[0];
$phone.mask(mask, this);
}};
$phone.mask('(00) 0000-0000', maskOptions);