Skip to content

Instantly share code, notes, and snippets.

View talcual's full-sized avatar
💭
Magic Code

Luis Toscano talcual

💭
Magic Code
View GitHub Profile
@talcual
talcual / ws-cli.php
Created November 4, 2018 18:20 — forked from ikwattro/ws-cli.php
php: simple websocket client
<?php
/*
based on: http://stackoverflow.com/questions/7160899/websocket-client-in-php/16608429#16608429
FIRST EXEC PYTHON SCRIPT TO GET HEADERS
*/
$ws = new ws(array
(
'host' => '127.0.0.1',
'port' => 8080,
@talcual
talcual / client.js
Created July 10, 2018 04:20 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@talcual
talcual / genetic.py
Created April 14, 2018 07:03 — forked from bellbind/genetic.py
[python]Genetic Algorithm example
"""Genetic Algorithmn Implementation
see:
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php
"""
import random
class GeneticAlgorithm(object):
def __init__(self, genetics):
self.genetics = genetics
pass
@talcual
talcual / unifi-raspberry_pi-instructions.sh
Created September 14, 2017 01:36 — forked from bwbaugh/unifi-raspberry_pi-instructions.sh
Installing Ubiquiti UniFi Controller 5 on Raspberry Pi.
# Mirror of the instructions available here:
# http://www.lowefamily.com.au/2016/06/02/installing-ubiquiti-unifi-controller-5-on-raspberry-pi/
#
# These commands CANNOT be run in a script.
# They're just for reference.
# Install on Raspbian Jessie, or upgrade from Wheezy.
# Make sure all packages are upgraded (update && upgrade).
@talcual
talcual / getMp3StreamTitle.php
Created August 15, 2017 05:18 — forked from fracasula/getMp3StreamTitle.php
How to get the MP3 metadata (StreamTitle) from a streaming URL
<?php
/**
* Please be aware. This gist requires at least PHP 5.4 to run correctly.
* Otherwise consider downgrading the $opts array code to the classic "array" syntax.
*/
function getMp3StreamTitle($streamingUrl, $interval, $offset = 0, $headers = true)
{
$needle = 'StreamTitle=';
$ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
# How to echobot with XMPP, BOSH, and Strophe
1. Setup ejabberd(http://www.ejabberd.im/) server and setup account admin@localhost.local
NOTE: localhost should be enough. If you setup something else, make sure you add it at /etc/hosts like this
#/etc/hosts
127.0.0.1 localhost.local
NOTE: Also download Psi(http://psi-im.org/), and make sure you can connect to your ejabberd server.
2. Download strophe(http://code.stanziq.com/strophe/) and place it (eg: /Users/makoto/work/sample/strophejs-1.0)
function initMap() {
navigator.geolocation.getCurrentPosition(centerMap, locationError);
$scope.correctDir = false;
var options = {
types: [],
componentRestrictions: {country: 'co'}
};
var input = document.getElementById("address-auto");
var autocomplete = new google.maps.places.Autocomplete(input, options);
autocomplete.addListener('place_changed', function() {placeMarker(autocomplete)});
@talcual
talcual / firebase.php
Created February 5, 2017 23:32 — forked from krhoyt/firebase.php
Interact with Firebase from PHP.
<?php
// Constants
$FIREBASE = "_YOUR_FIREBASE_URL_";
$NODE_DELETE = "temperature.json";
$NODE_GET = "temperature.json";
$NODE_PATCH = ".json";
$NODE_PUT = "temperature.json";
// Data for PUT
@talcual
talcual / add_item.php
Created October 29, 2016 08:35 — forked from davidtsadler/add_item.php
Example showing how to list an item to the eBay Sandbox using the eBay Accelerator Toolkit New Schema (EbatNS) for PHP.
<?php
/*
* Author: David T. Sadler (http://davidtsadler.com)
* Date: 2013-03-29
* License: I release this example into the public domain. Use at your own risk.
*
* Example showing how to list an item to the eBay Sandbox using the eBay Accelerator Toolkit New Schema (EbatNS) for PHP.
*
* This example uses version 815 released on the 2013-03-22.
* http://www.intradesys.de/en/system/files/its_downloads/EbatNs_1_0_815_P5_0.zip
@talcual
talcual / gist:0bf4d4ce2f35f3a6feeca0a5c325a160
Created September 4, 2016 04:50 — forked from tvdsluijs/gist:fc0bb40ee0fe0805df8d
Mongodb php aggregation $match $or usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category = shoes or brand = nike
$ops = array(
array(
'$match' =>
array('$or' =>