Skip to content

Instantly share code, notes, and snippets.

angular.module('yourModule')
.directive('tabsSwipable', ['$ionicGesture', function($ionicGesture){
//
// make ionTabs swipable. leftswipe -> nextTab, rightswipe -> prevTab
// Usage: just add this as an attribute in the ionTabs tag
// <ion-tabs tabs-swipable> ... </ion-tabs>
//
return {
restrict: 'A',
require: 'ionTabs',
package main
import "fmt"
import "encoding/json"
type Person1 struct {
Name string
Age string
}
@isidroamv
isidroamv / StackOverflow Q&A
Last active September 22, 2016 22:19
A SQL query to get Questions and Answers of StackOverflow website. This data is required on the exercise 5 of the book Building Machine Learning Systems With Python
SELECT Id, Body, AcceptedAnswerId, Score, ParentId, CreationDate
FROM Posts
WHERE CreationDate BETWEEN '2014-01-01' AND '2017-01-01'
@isidroamv
isidroamv / run-command-background.sh
Last active March 7, 2017 19:20
Run command Background - Linux
nohup command </dev/null >/dev/null 2>&1 & # completely detached from terminal
@isidroamv
isidroamv / _form_validation.scss
Last active April 27, 2017 15:33
SASS input validation for materializecss & Angular2
// Text inputs
input:not([type]),
input[type=text],
input[type=password],
input[type=email],
input[type=url],
input[type=time],
input[type=date],
input[type=datetime-local],
input[type=tel],
function calculateDistance(rssi) {
var txPower = -59 //hard coded power value. Usually ranges between -59 to -65
if (rssi == 0) {
return -1.0;
}
var ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
@isidroamv
isidroamv / stayalive.sh
Last active December 8, 2017 20:02
Restart process if crash on Linux
#!/bin/bash
# Add this file as a crontab task
# Example: * * * * * bash /opt/dir/task/stayalive.sh
# If the collector is not runing, execute it
if [[ ! `pgrep -f "python main.py"` ]]; then
cd /opt/dir/process && ./process-name
fi
@isidroamv
isidroamv / threading-loop.py
Created January 30, 2018 21:35
A loop using Thread
from threading import Thread
import random
import time
import requests
def send_configurations(n=1, n2=2):
time.sleep(random.randint(1, 10))
print(n)
for n in range(10):
@isidroamv
isidroamv / mysql.js
Created November 23, 2015 06:40
CRUD - MySQL - NodeJS - Express
'use strict';
var mysql = require('mysql');
var config = require('../config');
var pool = mysql.createPool(config.mysql);
exports.exec = function(query, params, callback) {
if (!query) {
callback(true);
}
pool.getConnection(function(err, connection) {
if(err) { console.log(err); callback(true); return; }
@isidroamv
isidroamv / migrate_spotify_library.py
Created April 17, 2018 03:51
Use this script to migrate your spotify library from one account to another
import requests
old_token = ''
new_token = ''
h = {
'Authorization': 'Bearer ' + old_token
}
tracks = []
index = 0