Skip to content

Instantly share code, notes, and snippets.

@efrenfuentes
efrenfuentes / pushbullet.py
Created February 3, 2015 05:38
Get Pushbullet notifications
import websocket
import json
import logging
import datetime
api_key = 'Put your API Key here'
url = 'wss://stream.pushbullet.com/websocket/' + api_key
logging.basicConfig(filename='pushbullet.log', level=logging.INFO,
format='%(asctime)s:%(levelname)s:%(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
@efrenfuentes
efrenfuentes / pushbullet.rb
Created February 3, 2015 19:18
Get Pushbullet notifications
require 'faye/websocket'
require 'eventmachine'
require 'json'
require 'logger'
api_key = 'Put your API Key here'
url = 'wss://stream.pushbullet.com/websocket/' + api_key
logger = Logger.new('pushbullet.log')
logger.level = Logger::INFO
@efrenfuentes
efrenfuentes / PublicIP.py
Created August 16, 2015 00:45
Get public IP
import urllib2
import logging
from time import sleep
# how minutes wait between checks
time_between_check = 5
# setup log output
logging.basicConfig(filename='publicIP.log',
level=logging.DEBUG,
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
post '/:name/:filename' do
userdir = File.join("files", params[:name])
@efrenfuentes
efrenfuentes / gist:950109
Created April 30, 2011 23:53
Elixir event statements
from elixir.statements import Statement
from sqlalchemy.orm.mapper import MapperExtension
import types
def proxy_to_instance(name):
def new_func(self, mapper, connection, instance):
if hasattr(instance, name) : getattr(instance, name)()
return new_func
@efrenfuentes
efrenfuentes / app.rb
Created November 15, 2012 18:03
Simple Sinatra Authentication
require 'rubygems'
require 'sinatra'
set :username,'Bond'
set :token,'shakenN0tstirr3d'
set :password,'007'
helpers do
def admin? ; request.cookies[settings.username] == settings.token ; end
def protected! ; halt [ 401, 'Not Authorized' ] unless admin? ; end
@efrenfuentes
efrenfuentes / login.rb
Created November 15, 2012 18:06 — forked from amscotti/login.rb
Sample of Sinatra authentication
require 'rubygems'
require 'bcrypt'
require 'haml'
require 'sinatra'
enable :sessions
userTable = {}
helpers do
#include <iostream>
using namespace std;
class Nodo
{
public:
Nodo(int numero, Nodo *siguiente = NULL)
{
this->numero = numero;
this->siguiente = siguiente;

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
@efrenfuentes
efrenfuentes / remove-docker-containers.md
Created December 29, 2015 15:39 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images