Skip to content

Instantly share code, notes, and snippets.

@vjo
vjo / Error RiverFs ElasticSearch
Created July 3, 2012 14:46
Creation error RiverFs ElasticSearch
[2012-07-03 16:40:01,035][INFO ][cluster.metadata ] [Power Man] [_river] update_mapping [mydocs] (dynamic)
[2012-07-03 16:40:01,063][WARN ][river ] [Power Man] failed to create river [fs][mydocs]
org.elasticsearch.common.inject.CreationException: Guice creation errors:
1) Error injecting constructor, java.lang.NullPointerException
at org.elasticsearch.river.fs.FsRiver.<init>(Unknown Source)
while locating org.elasticsearch.river.fs.FsRiver
while locating org.elasticsearch.river.River
1 error
@vjo
vjo / twitter_Streaming_API_geo.sh
Last active October 7, 2015 04:47
Get tweets from Paris with the Streaming API #Paris #Twitter #curl
curl -u USERNAME:'PASSWORD' -d locations=48.8365,2.2547,48.8979,2.4044 https://stream.twitter.com/1.1/statuses/filter.json
@vjo
vjo / gif.py
Created October 3, 2012 20:27 — forked from 2xyo/gif.py
Small script to send gif by mail...
#!/usr/bin/env python
import imaplib
from pprint import pprint
from email.parser import HeaderParser
from django.core.mail import EmailMultiAlternatives
from email.mime.message import MIMEMessage
from django.conf import settings
import os,random,sys
from email import Charset
from email.mime.image import MIMEImage
@vjo
vjo / mailx_site_monitor.sh
Created November 20, 2012 10:21 — forked from eykanal/mailx_site_monitor.sh
Simple tool using curl, mailx, and a crontab to monitor whether a site is up or not
#!/bin/sh
# How many seconds does it usually take your site to respond?
sec=2
# Try to download the site to a file
curl -s -m $sec example.org > /tmp/dltime
# Get size of file
a=`wc -m /tmp/dltime | awk '{print $1}'`
@vjo
vjo / convert_date.sh
Created November 20, 2012 11:42
Convert a date in one timezone into another using GNU date
TZ=EST date -d "Tue, 13 Nov 2012 16:39:51 -0800" # Convert a date in one timezone into another using GNU date.
@vjo
vjo / send_mail.py
Created November 20, 2012 16:48
[Python] Send email with embedded image and application attachment
#! /usr/bin/python
import smtplib
from optparse import OptionParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
@vjo
vjo / gist:4381049
Created December 26, 2012 15:58 — forked from anonymous/gist:4381021
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX sim: <http://purl.org/ontology/similarity/>
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX ov: <http://open.vocab.org/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
@vjo
vjo / url_opener.py
Last active December 12, 2015 06:59
Open url with cookies
import urllib2
with open('hack_file.txt') as f:
content = f.readlines()
for id in content:
headers = {'Cookie': 'cookie1=value1; cookie2=value2; cookie3=value3;'}
url = "http://url.com/id/%s" % id
req = urllib2.Request(url, None, headers)
resp = urllib2.urlopen(req)
@vjo
vjo / gist:5109135
Last active December 14, 2015 15:38
Networking - Shell Tricks
'lsof -i' monitors network connections in real time
'sudo lsof -i -P | grep -i "listen"' Check open port
'iftop' shows bandwith usage per *connection*
'nethogs' shows the bandwith usage per *process*
'python -m SimpleHTTPServer 8080' shares all the files in the current folder over HTTP, port 8080

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

Questions? See my blog post - http://dan.cx/blog/2011/06/twitter-autoreply-bot-dbznappa

Modified 2013-06-13 - Twitter API 1.0 discontinued, modified to use Twitter API 1.1