Skip to content

Instantly share code, notes, and snippets.

View utain's full-sized avatar
💭
I may be slow to respond.

Utain Wongpreaw utain

💭
I may be slow to respond.
View GitHub Profile
@utain
utain / .htaccess
Last active May 8, 2019 16:22
.htaccess for HTML5 History API
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/path/to/allow404/ [OR]
# file extensions to allow 404
RewriteCond %{REQUEST_URI} ^.*/*.(js|css|png|jpg|gift|webp|webm|pdf|svg) [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /path/to/project/index.html
@utain
utain / vscode-regex-react-prop-types
Created April 25, 2017 08:13
Regex search and replace in VsCode for Migrate Reacr.PropTypes to prop-types
search regex:
(^import.+)(,.+?PropTypes)(.+'react';)$
replace regex:
$1$3\nimport PropTypes from 'prop-types';
@utain
utain / gist:e6268cfc841afcca13cd
Created November 3, 2015 16:28 — 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

@utain
utain / helo.go
Last active August 29, 2015 14:23
Hello, World
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}