Skip to content

Instantly share code, notes, and snippets.

View kesha-antonov's full-sized avatar
🏆
Working on great apps

Kesha Antonov kesha-antonov

🏆
Working on great apps
View GitHub Profile
#!/bin/bash
#
# DROPKICK.SH
#
# Detect and Disconnect the DropCam and Withings devices some people are using to
# spy on guests in their home, especially in AirBnB rentals. Based on Glasshole.sh:
#
# http://julianoliver.com/output/log_2014-05-30_20-52
#
# This script was named by Adam Harvey (http://ahprojects.com), who also
@kesha-antonov
kesha-antonov / simpleFormat.js
Created February 25, 2016 16:10 — forked from kares/simpleFormat.js
simple_format Ruby on Rails helper in javascript
var simpleFormatRE1 = /\r\n?/g;
var simpleFormatRE2 = /\n\n+/g;
var simpleFormatRE3 = /([^\n]\n)(?=[^\n])/g;
function simpleFormat(str) {
var fstr = str;
fstr = fstr.replace(simpleFormatRE1, "\n") // \r\n and \r -> \n
fstr = fstr.replace(simpleFormatRE2, "</p>\n\n<p>") // 2+ newline -> paragraph
fstr = fstr.replace(simpleFormatRE3, "$1<br/>") // 1 newline -> br
fstr = "<p>" + fstr + "</p>";
return fstr;
Article Load (331.8ms) SELECT "articles".* FROM "articles" INNER JOIN (SELECT "articles"."id" AS pg_search_id, (ts_rank((to_tsvector('simple', coalesce("articles"."text"::text, '')) || to_tsvector('simple', coalesce(pg_search_4aab10cdca183dac25f479.pg_search_c81a66135b0eb97fa238c2::text, ''))), (to_tsquery('simple', ''' ' || 'rap2' || ' ''' || ':*')), 0)) AS rank FROM "articles" LEFT OUTER JOIN (SELECT "articles"."id" AS id, string_agg("users"."name"::text, ' ') AS pg_search_c81a66135b0eb97fa238c2 FROM "articles" INNER JOIN "users" ON "users"."id" = "articles"."user_id" GROUP BY "articles"."id") pg_search_4aab10cdca183dac25f479 ON pg_search_4aab10cdca183dac25f479.id = "articles"."id" WHERE (((to_tsvector('simple', coalesce("articles"."text"::text, '')) || to_tsvector('simple', coalesce(pg_search_4aab10cdca183dac25f479.pg_search_c81a66135b0eb97fa238c2::text, ''))) @@ (to_tsquery('simple', ''' ' || 'rap2' || ' ''' || ':*'))))) pg_search_articles ON "articles"."id" = pg_search_articles.pg_search_id ORDER BY pg
@kesha-antonov
kesha-antonov / gist:749fbac016aa451700fe
Created October 11, 2015 12:57 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter