Skip to content

Instantly share code, notes, and snippets.

View angelmartz's full-sized avatar

Juan Angel Martínez Lopez angelmartz

  • CDMX, Mexico
  • 21:13 (UTC -06:00)
View GitHub Profile
@angelmartz
angelmartz / repetidos.sql
Created October 21, 2016 17:58
MySQL BorrarRepetidos
ALTER TABLE table ENGINE MyISAM;
ALTER IGNORE TABLE table ADD UNIQUE INDEX (field);
ALTER TABLE table ENGINE InnoDB;
@angelmartz
angelmartz / msql.js
Created September 22, 2016 22:44
Socketio + MySQL
io.sockets.on('connection', function (socket) {
socket.emit('greeting', 'Hello');
setInterval(5000,function(data){
var uid = data['uid'];
var q = "SELECT * FROM messages WHERE user_id="+uid+" ORDER BY id DESC LIMIT 1";
connection.query(q, function(err, rows, fields) {
if (err) throw err;
if (rows[0].id > prev_id){
socket.emit('new_message',rows[0]);
prev_id = rows[0].id
@angelmartz
angelmartz / centovcast.conf
Created September 20, 2016 16:19
Centovacast + Nginx
index status.xsl;
# Servir los archivos estáticos directamente
location / {
root /srv/http/$server_name/web;
}
# Los xsl y los medios son procesados por icecast
location ~ \.(xsl|ogg|ogv|oga|mp3|webm|opus|speex)$ {
proxy_pass http://localhost:8000;
@angelmartz
angelmartz / util.java
Created June 13, 2016 13:51
GetNetworkTYPE Android
public String getNetworkClass(Context context) {
TelephonyManager mTelephonyManager = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
int networkType = mTelephonyManager.getNetworkType();
switch (networkType) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_IDEN:
@angelmartz
angelmartz / cumple.sql
Last active April 26, 2016 18:01
Cumpleaños
// Cumple del día
select *
from CLIENTES
where extract(month from NACIMIENTO) = extract(month from current_date) and
extract(day from NACIMIENTO) = extract(day from current_date)
//Cumple del mes
select *
from CLIENTES
where extract(month from NACIMIENTO) = extract(month from current_date)
var getView = function(viewName)
{
viewPath = './views/app/';
viewExt = '.html';
views = viewName.split('.');
if(views instanceof Array){
if(views.length == 1){
return viewPath + views[0] + viewExt;
}else{
return viewPath + views[0] + '/' + views[1] +viewExt;
@angelmartz
angelmartz / demo.js
Created January 25, 2016 20:02
demo
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('w j=["\\M\\c\\r\\y\\a","\\u\\D\\e\\o\\b\\f\\v","\\v\\a\\b\\T\\r\\a\\t\\a\\p\\b\\f\\1L\\A\\1M\\c\\t\\a","\\t\\c\\b\\k\\s","\\k\\h\\h\\I\\l\\a","\\s\\b\\b\\g\\f\\1g\\E\\E\\W\\W\\W\\N\\u\\c\\k\\a\\D\\h\\h\\I\\N\\k\\h\\t\\E\\1N\\p\\u\\h\\n\\t\\c\\b\\a\\D\\r\\h\\v\\v\\E\\g\\h\\f\\b\\f\\E\\J\\O\\F\\K\\G\\z\\G\\z\\H\\L\\P\\P\\G\\O\\J","\\1O\\T\\X","\\E\\c\\U\\c\\x\\E\\b\\A\\g\\a\\c\\s\\a\\c\\o\\E\\u\\l\\n\\f\\b\\e\\o\\a\\v\\n\\a\\a\\N\\g\\s\\g\\1r\\e\\e\\c\\q\\z\\m\\u\\l\\r\\b\\a\\n\\B\\F\\C\\q\\y\\f\\a\\n\\m\\r\\c\\1s\\A\\q\\F\\m\\M\\l\\a\\W\\a\\n\\q","\\m\\b\\h\\I\\a\\p\\q\\M\\O\\m\\f\\b\\c\\r\\a\\e\\h\\I\\q\\F\\m\\h\\g\\b\\l\\h\\p\\f\\B\\F\\C\\q\\u\\n\\l\\a\\p\\o\\f\\e\\h\\p\\r\\A\\m\\h\\g\\b\
@angelmartz
angelmartz / demo
Created January 22, 2016 23:13
demo
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('y q=["\\F\\c\\p\\x\\a","\\u\\z\\b\\l\\e\\h\\v","\\v\\a\\e\\J\\p\\a\\s\\a\\t\\e\\h\\1j\\A\\1k\\c\\s\\a","\\s\\c\\e\\f\\r","\\f\\j\\j\\C\\m\\a","\\T\\c\\G\\c\\w\\T\\x\\g\\l\\c\\e\\a\\h\\e\\c\\e\\x\\h\\U\\g\\r\\g\\1l\\c\\F\\o","\\k\\b\\b\\g\\f\\o\\J\\1m\\V\\B\\1n\\1o\\W\\1p\\J\\1q\\W\\1r\\1s\\X","\\1t\\a\\m\\1u","\\c\\e\\e\\c\\f\\r\\s\\a\\t\\e\\k\\z\\c\\f\\C\\l\\c\\e\\a\\l\\b\\l\\c\\e\\a\\D\\A\\a\\c\\n\\E\\k\\z\\c\\f\\C\\l\\c\\e\\a\\l\\b\\l\\c\\e\\a\\D\\s\\j\\t\\e\\r\\E\\k\\z\\c\\f\\C\\l\\c\\e\\a\\l\\b\\l\\c\\e\\a\\D\\l\\c\\A\\E\\k\\z\\c\\f\\C\\l\\c\\e\\a\\l\\b\\l\\c\\e\\a\\D\\r\\j\\x\\n\\E\\k\\z\\c\\f\\C\\l\\c\\e\\a\\l\\b\\l\\c\\e\\a\\D\\s\\m\\t\\x\\e\\a\\E\\k\\z\\j\\j\\h\\e\\a\\l\\b\\g\\j\\
@angelmartz
angelmartz / 01_Laravel 5 Simple ACL manager_Readme.md
Created November 27, 2015 15:08 — forked from amochohan/01_Laravel 5 Simple ACL manager_Readme.md
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@angelmartz
angelmartz / gist:d3437e20f5601fcf5302
Created November 11, 2015 19:58
Facebook Notification
<?php
$facebook = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_APP_SECRET,
'grant_type' => 'client_credentials'
));
$post = $facebook->api('/' . $user['uid'] . '/notifications/', 'post', array(
'access_token' => FB_APP_ID.'|'.FB_APP_SECRET,
'href' => getBaseURL(), //this does link to the app's root, don't think this actually works, seems to link to the app's canvas page