Skip to content

Instantly share code, notes, and snippets.

View omalave's full-sized avatar
🏠
Working from home

Omar Malave omalave

🏠
Working from home
  • Santander, Spain
  • 02:35 (UTC +02:00)
View GitHub Profile
@omalave
omalave / gist:623cd299f165797db4cd
Last active January 14, 2017 16:47
Remover Duplicados en SelectBox HTML
$("select>option").each( function(){
var $option = $(this);
$option.siblings()
.filter( function(){ return $(this).val() == $option.val() } )
.remove()
});
@omalave
omalave / gist:c2cc5904b06459436008
Created December 5, 2014 15:43
Command for silex sekeleton
composer create-project fabpot/silex-skeleton -sdev
@omalave
omalave / moment.php
Created February 2, 2015 16:46
Time Twitter Style, moment.js in PHP
function calc_time_diff($timestamp, $unit = NULL, $show_unit = TRUE) {
$seconds = round((time() - $timestamp)); // How many seconds have elapsed
$minutes = round((time() - $timestamp) / 60); // How many minutes have elapsed
$hours = round((time() - $timestamp) / 60 / 60); // How many hours have elapsed
$days = round((time() - $timestamp) / 60 / 60 / 24); // How many hours have elapsed
$seconds_string = $seconds;
$minutes_string = $minutes;
$hours_string = $hours;
$days_string = $days;
switch($unit) {
@omalave
omalave / gist:278d070b3efaad47e0ad
Last active July 21, 2016 19:03
How to install Composer on Debian
To make Composer (globally) available on Debian:
$ sudo su
$ cd /usr/src
$ apt-get install curl php5-cli
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Verify installation:
$ composer --version
@omalave
omalave / fill_input_date.js
Last active April 16, 2016 18:07
fill a input field with current date
$(document).ready(function(){
var fullDate = new Date();
var twoDigitMonth = (fullDate.getMonth()+1)+"";if(twoDigitMonth.length==1) twoDigitMonth="0" +twoDigitMonth;
var twoDigitDate = fullDate.getDate()+"";if(twoDigitDate.length==1) twoDigitDate="0" +twoDigitDate;
var currentDate = twoDigitDate + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
$("#datepicker").val(currentDate);
});
@omalave
omalave / copy.sh
Created April 20, 2016 20:24
Copy entire website with wget
wget -mkEpnp http://example.org
@omalave
omalave / 1-server.md
Created March 1, 2017 23:59 — forked from dragonjet/1-server.md
Setup Web Server on EC2 Amazon Linux AMI

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
@omalave
omalave / PDO classes.md
Created April 10, 2017 18:47 — forked from danferth/PDO classes.md
PHP classes for PDO

PDO Classes for db connect and manipulation

Below is a description on how to use the classes in the below script

###Include script and set up db variables

include 'zdb.php';
@omalave
omalave / mysqlsync
Created September 9, 2018 16:53 — forked from samhernandez/mysqlsync
Sync remote mysql database to local over ssh
#!/bin/bash
# This script assumes you have ssh access to a remote server
# Both databases are backed up to sql files in the same directory
# this script is executed from.
# Usage:
# 1. Make sure this file is executable with `chmod +x mysqlsync`
# 2. Set the credentials for the variables at the top
# (Remember, no spaces around the '=' sign)
# 3. Run it from a directory where you'd like the backup files to go:
@omalave
omalave / router-admin-scripts.sh
Created March 13, 2019 00:24 — forked from tracker1/router-admin-scripts.sh
Tomato Router - Limit Guest Wifi
#Setup bridge for guest wifi (br1) with separate subnet/dhcp
# setup virtual wifi wlan0.1
#the following rules go under administration -> scripts -> firewall then reboot after saving
#NOTE: -I inserts at the beginning be default, so restrictive rules at the top, permissive at the bottom.
#default deny guest
iptables -I FORWARD -i br1 -j DROP
#Removes guest access to physical network