Skip to content

Instantly share code, notes, and snippets.

View roramirez's full-sized avatar

Rodrigo Ramírez Norambuena roramirez

View GitHub Profile
echo " <li class='nav-item dropdown '>
<a class='nav-link' href='/qpanel/login_external?domain_name=".$_SESSION['domain_name']."&domain_uuid=".$_SESSION['domain_uuid']."&username=".$_SESSION['username']."&user_uuid=".$_SESSION['user_uuid']."' >
<span class='fas fas fa-chart-pie' title='QPanel'></span>
<span class='d-sm-none d-md-none d-lg-inline' style='margin-left: 5px;'>QPanel</span>
</a>
</li>";
def in_range_time_from_db(from, to, value=Time.now)
# The `time` types are storage in the database in format HH:MM:SS.
# `ActiveRecord` returns into theTime type '2000-01-01 HH:MM:SS'
# This function return these times [`from`, `to`] to present date
# and checks if the `value` is in this range period
from = from.to_time.strftime("%T")
to = to.to_time.strftime("%T")
from = Time.parse(from)
import datetime
a1 = datetime.datetime.now()
import re
import os
a2 =datetime.datetime.now()
print(a1, a2, a2 - a1)
@roramirez
roramirez / node-clickfono.js
Created July 27, 2018 14:09
API Clickfono Node.js
/*
Ejemplo para el utilizar el API Clickfono usando Node.js
*/
var request = require('request');
urlAPI = 'https://clickandtalk.medularis.com/calls/manage/api';
/*
@roramirez
roramirez / MagicMirror_on_CHIP.md
Created January 30, 2017 16:13 — forked from morozgrafix/MagicMirror_on_CHIP.md
MagicMirror on $9 C.H.I.P. Installation Instructions
# remove double quote from json from a dict
import json, re
data = {'example': 1, "other" : {'other_key': "String", 'key_b': False}}
config = json.dumps(data)
vars = re.sub(r'"([a-zA-Z_]+)":', r'\1:', config)
print(vars)
form = MyFormForm(request.POST)
if form.is_valid():
obj = form.save(commit=false)
obj.created_by = request.user
obj.save()
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
@roramirez
roramirez / create_swap.sh
Created July 8, 2016 22:46
Create a swap file
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
DATE=`date +%Y%m%d%H%M%S`
CSV_DIR=/var/log/asterisk/cdr-csv
CSV_FILE=$CSV_DIR/Master.csv
OWNER=asterisk
if [ -f $CSV_FILE ]; then