Instantly share code, notes, and snippets.

View atom_snippets.cson
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
View concurrent_file_downloader.go
package phttp
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"golang.org/x/net/context/ctxhttp"
View ad_accounts_fb.js
var main_page_id = "1235324234324"
var page_url = "https://www.facebook.com/name-here-1235324234324";
fb.api('/oauth/access_token', {
client_id: config.facebook_api_key,
client_secret: config.facebook_api_secret,
redirect_uri: 'https://localhost:4430/auth/callback',
code: req.query.code // FYI, we're in an express.js handler
}, function(res_accesstoken) {
if (!res_accesstoken || res_accesstoken.error) {
View gist:c1b19a39c0add210d4a5d36f760f11b6

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

View Dockerfile1
# Sample from @citizen428 https://dev.to/citizen428/comment/6cmh
FROM golang:alpine as build
RUN apk add --no-cache ca-certificates
WORKDIR /build
ADD . .
RUN CGO_ENABLED=0 GOOS=linux \
go build -ldflags '-extldflags "-static"' -o app
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt \
View templates.go
// Note that the templateFuncs refer to my apps helper package, left here
// in this example to help.
// Heavily inspired by the book https://www.sitepoint.com/premium/books/level-up-your-web-apps-with-go
// https://gitlab.com/snippets/1662623
// https://www.kylehq.com/2017/05/golang-templates---what-i-missed/
package templates
import (
"bytes"
View template_test.go
package main
import (
"bytes"
"fmt"
"html/template"
"testing"
)
var layout = `layout: {{block "home" .}}default{{end}}`
View debounce.go
package main
import (
"fmt"
"time"
)
func main() {
f := func(args ...interface{}) {
View domain_lookup_spamhaus.php
<?php
$domains = [
'example.com',
];
foreach ($domains as $domain) {
dblListed($domain);
}
View git_overview
find . -type d -name '.git' | while read dir ; do sh -c "cd $dir/../ && echo -e \"\nGIT STATUS IN ${dir//\.git/}\" && git status -s" ; done