Skip to content

Instantly share code, notes, and snippets.

View nenadg's full-sized avatar
🍺
out

Nenad Golubovic nenadg

🍺
out
View GitHub Profile

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

(function (global) {
if ( !global.Event && !('keys' in Object) && !('bind' in Function) ) { return }
var eventProto = Event.prototype,
EVENTS = {
'mouse': [ 'click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout', 'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'drop'],
'key': [ 'keydown', 'keypress', 'keyup', 'input'],
'res': [ 'load', 'unload', 'beforeunload', 'abort', 'error', 'resize', 'scroll', 'readystatechange' ],
'form': [ 'select', 'change', 'submit', 'reset', 'focus', 'blur' ],
'ui': [ 'DOMFocusIn', 'DOMFocusOut', 'DOMActivate', 'DOMCharacterDataModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMSubtreeModified' ],
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
// http://en.wikipedia.org/wiki/Approximate_string_matching
function fuzzySearch(t, p) { // returns minimum edit distance between substring of t and p
var a = [], // current row
b = [], // previous row
pa = [], // from
pb = [],
s, i, j;
for (i = 0; i <= p.length; i++) {
s = b;
b = a;
@nenadg
nenadg / d3.geo.raster.js
Last active August 31, 2015 18:52 — forked from mpmckenna8/d3.geo.raster.js
Mapbox tiles on a d3.globe, oh gosh
// Copyright 2014, Jason Davies, http://www.jasondavies.com/
(function() {
d3.geo.raster = function(projection) {
var path = d3.geo.path().projection(projection),
url = null,
scaleExtent = [0, Infinity],
subdomains = ["a", "b", "c", "d"];
var reprojectDispatch = d3.dispatch('reprojectcomplete');
@nenadg
nenadg / xerxes.c
Created June 7, 2016 08:02 — forked from Xe/xerxes.c
//Xerxes, code assumed to be public domain
//by tH3j3st3r
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <netdb.h>
#include <signal.h>
@nenadg
nenadg / levenshtein.js
Created July 7, 2016 12:15 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
/**
* isMatch.js
*
* Evan Steinkerchner - 2015
* https://gist.github.com/Roundaround/87835b53690135aa0529
*
* A string matching function that utilizes a variety of methods to provide 'intelligent'
* string matching functionality. A pair of strings will be considered a match when either:
*
* 1. the strings are both phoenetically similar as per the double metaphone algorithm, and
@nenadg
nenadg / dedit.sh
Created December 26, 2016 14:59 — forked from dmohs/dedit.sh
#!/bin/bash
IFS=$'\n\t'
set -euox pipefail
CNAME="$1"
FILE_PATH="$2"
TMPFILE="$(mktemp)"
docker exec "$CNAME" cat "$FILE_PATH" > "$TMPFILE"
@nenadg
nenadg / nouns.txt
Created May 24, 2019 14:03 — forked from sudodoki/nouns.txt
list of uncountable nouns aka mass nouns scraped from http://simple.wiktionary.org/wiki/Category%3aUncountable_nouns
abaft
abandon
abasia
abating
abbreviated
abducted
able-bodiedism
able-bodism
ableism
ablepharia