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

@nenadg
nenadg / ipregex.txt
Created May 29, 2014 13:37
Regex that matches IPs excluding local addresses
^(?!(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^0\.))(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
(function(colors){
for(var i in colors){
var element = document.createElement('div');
element.style.cssText = 'width: 10px; height: 10px; background: ' + colors[i] + '; position: absolute; top: 0px; left: ' + (i*10) + 'px; z-index: 999999999;';
document.body.appendChild(element);
}
})(['#932674', '#EDAD0B', '#A4C520', '#009250', '#0086AB', '#EDD0E5', '#FEF7D5', '#D1F1CC', '#C9E8F1', '#5D639E', '#FFE600', '#5EC84E','#95DFD6', '#BF1E56', '#DA5019', '#E4EC5B', '#E6855E', '#23AC0E', '#E6855E', '#F3C0AB']);
(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 / DefaultFilters.js
Created December 10, 2015 14:49
ExtJS default filters example grid plugin
Ext.define('Example.grid.DefaultFilters', {
extend: 'Ext.grid.filters.Filters',
alias: 'plugin.defaultfilters',
pluginId: 'defaultfilters',
init: function(grid) {
var me = this,
store, headerCt;
me.grid = grid;
grid.filters = me;
@nenadg
nenadg / convert.js
Created February 5, 2016 09:01
some seconds to horus, days, weeks, etc. conversion
function convert(seconds){
seconds = seconds || 3600;
var minutes = (seconds / 60),
hours = (minutes / 60),
days = (hours / 24),
weeks = (days / 7),
months = (days / 30),
years = (days / 365),
quarters = (days / 90);// % 4;
@nenadg
nenadg / gist:086ced312754a28c6cd2
Created March 15, 2016 13:16
Alphanumeric array
var alphanumericArray = ['0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z']