Skip to content

Instantly share code, notes, and snippets.

View juangesino's full-sized avatar

Juan Gesino juangesino

View GitHub Profile
@juangesino
juangesino / internal_ip.php
Last active August 29, 2015 13:58
Postea la IP interna de la RPi a una pagina web! (usando Python + PHP + MySQL)La RPi ejecuta send_internal_ip.py cada vez que arranca, este archivo manda por variable GET la ip de la RPi a un archivo PHP alojado en un dominio. El archivo recibe esta variable GET y actualiza una base de datos MySQL. Al mismo tiempo si la variable no esta definida…
<?php
$dbc = mysql_connect('HOSTNAME','USERNAME','PASSWORD');
if (!$dbc){
die(mysql_error());
}
$db_selected = mysql_select_db('DATABASE',$dbc);
if(!$db_selected){
die(mysql_error());
}
@juangesino
juangesino / es_input.cfg
Created April 8, 2014 03:56
Mi archivo es_input.cfg para la RetroPie con los controles para la PS3 y un teclado
<?xml version="1.0"?>
<inputList>
<inputConfig type="keyboard">
<input name="a" type="key" id="13" value="1" />
<input name="b" type="key" id="8" value="1" />
<input name="down" type="key" id="274" value="1" />
<input name="left" type="key" id="276" value="1" />
<input name="menu" type="key" id="32" value="1" />
<input name="pagedown" type="key" id="304" value="1" />
<input name="pageup" type="key" id="0" value="1" />
@juangesino
juangesino / retroarch.cfg
Created April 8, 2014 03:58
Mi archivo retroarch.cfg para la RetroPie con un control de PS3 y la habilidad de salir del emulador apretando el boton PS ("16")
input_player1_b = s
input_player1_a = a
input_player1_y = z
input_player1_x = x
input_player1_l = q
input_player1_r = w
input_player1_start = space
input_player1_select = lalt
input_player1_up = up
input_player1_down = down
@juangesino
juangesino / adbuddiz.js
Last active August 29, 2015 14:15
AdBuddiz
$(window).load(function(){
adbuddiz.isReadyToShowAd(
function() { alert('SDK Loaded'); },
function() { alert('SDK Not Loaded') }
);
adbuddiz.showAd();
});
@juangesino
juangesino / using_edudata_api.js
Last active September 1, 2015 01:35
EduData JavaScript Integration
function buy(price) {
// Do your magic here
// And track the transaction here:
var token = "XXXXXXXXX" // Token found at EduData.
var tag = "TAG_NAME" // Give the tag a name.
var host = "HOST_NAME" // If using a backend server you can insert your hostname here.
var values = [parseInt(price)] // Array of values, in this case just the price of the item.
var unit = '$' // Set a unit for your measurement, you can leave an empty string.
@juangesino
juangesino / percent-filter.js
Last active September 1, 2015 01:35 — forked from jeffjohnson9046/percent-filter.js
Format percentages in AngularJS
// In app.js or main.js or whatever:
// var myApp = angular.module('askchisne', ['ngSanitize', 'ngAnimate', 'ui.bootstrap', 'ui.bootstrap.tpls']);
// This filter makes the assumption that the input will be in decimal form (i.e. 17% is 0.17).
myApp.filter('percentage', ['$filter', function ($filter) {
return function (input, decimals) {
percentage = $filter('number')(input * 100, decimals);
percentage = percentage.toString().replace(/(\.[0-9]*?)0+$/, "$1").replace(/\.$/, "");
return percentage + '%';
};
@juangesino
juangesino / get_files.rb
Created September 1, 2015 10:21
Get files from a directory recursively (get files inside directories).
awesome_files = [] # This will contain all the files we wanted
directories = ['app/models/'] # Initial directory to search
directories.each do |directory| # Iterate through the directories
files = Dir.glob("#{directory}/**") # Get all files and directories inside that directory
files.each do |file| # Iterate
next if file == '.' or file == '..' # Ignore . and ..
if File.directory?(file) # Check if the file is a directory or just a file
directories << file # If it's a directory, push it into the directories array to search inside it later
else
awesome_files << file # If it's a file save it
require 'json'
require 'typhoeus'
class UrlCharts
def initialize(key = nil)
if !key || key.empty?
raise 'No API key defined.'
else
@api_key = key
class GoogleCharts
def self.url(options = {})
chs = options[:size] || "250x100"
chd = options[:data] || "t:60,40"
cht = options[:type] || "p3"
chl = options[:labels] || "You|Me"
url = "https://chart.googleapis.com/chart?chs=#{chs}&chd=#{chd}&cht=#{cht}&chl=#{chl}"
end
@juangesino
juangesino / commands.sh
Last active February 8, 2018 14:30
[Terminal Commands] A bunch of useful commands for macOS
# Get MAC address
ifconfig en0 | grep ether
# Set a new MAC address
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff
# Set random MAC
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' | xargs sudo ifconfig en0 ether
# Save energy