Skip to content

Instantly share code, notes, and snippets.

@shevabam
shevabam / requirements.txt
Last active July 10, 2020 08:27
weather-to-pushbullet
pushbullet.py>=0.11.0
urllib3>=1.25.9
@shevabam
shevabam / pushbullet_alert_sensor_temp.py
Created May 16, 2019 18:59
Pushbullet sensor temperature notification
#!/usr/bin/python
# -*- coding: utf-8 -*-
#pip install git+https://github.com/Azelphur/pyPushBullet.git
from pushbullet.pushbullet import PushBullet
import json, os
# Sensor ID (/sys/bus/w1/devices/{SENSOR_ID}/w1_slave)
SENSOR_ID = "xxx"
@shevabam
shevabam / caporal-test.js
Created March 17, 2017 12:29
Caporal.js example
#!/usr/bin/env node
var http = require('http');
var https = require('https');
var retreiveDatas = function(url){
return new Promise((resolve, reject) => {
var proto = https;
if (url.indexOf("http://") == 0)
@shevabam
shevabam / check_sensors.py
Created April 19, 2016 16:25
Get value from DS18B20 sensors with Raspberry Pi
#!/usr/bin/python
# -*- coding: utf-8 -*-
import glob, os, sys
from datetime import datetime
def get_temp(device_file):
temp_c = 0
@shevabam
shevabam / Seconds to human readable text.php
Last active October 21, 2015 08:01
SecondsToHumanReadableText
<?php
/**
* Seconds to human readable text
* Eg: for 36545627 seconds => 1 year, 57 days, 23 hours and 33 minutes
*
* @return string Text
*/
function getHumanTime($seconds)
{
@shevabam
shevabam / getUpperLowerValues.sql
Last active October 21, 2015 08:01
SQL - Get uppercase or lowercase values
SELECT lastname, UPPER(lastname)
FROM people
WHERE lastname = BINARY UPPER(lastname);
@shevabam
shevabam / getFirstLastDay.sql
Last active October 21, 2015 08:01
SQL - Get first and last day (monday/sunday) in a date
SELECT
DATE_ADD(CURRENT_DATE, INTERVAL(2-DAYOFWEEK(CURRENT_DATE)) DAY) AS start_day,
DATE_ADD(CURRENT_DATE, INTERVAL(8-DAYOFWEEK(CURRENT_DATE)) DAY) AS end_day;