Skip to content

Instantly share code, notes, and snippets.

@mraible
mraible / gsutil-upload.sh
Last active September 30, 2020 22:47
Upload optimized assets to Google Cloud Storage
# Rsync to remove old files
gsutil -m rsync -x '.git*' -c -d -r dist gs://bucket/
# Upload and gzip HTML, CSS and JavaScript
gsutil -m cp -z "html,css,js" -r dist/** gs://bucket/
# Set expires headers (6 months) on JS and CSS assets
gsutil -m setmeta -h "Cache-Control: public, max-age=15552000" gs://bucket/assets/**
# Make sure there's no expiration headers on HTML files
@kosiara
kosiara / InitActivity.java
Created July 21, 2014 10:55
Android slf4j logger with logcat + file; logging to file and logcat on Android
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InitActivity {
public InitActivity() {
logger.debug("Activity loading....");
}
@keyboardsurfer
keyboardsurfer / flavor_names_build.gradle
Last active January 13, 2021 09:24
Version names for application variants
android {
applicationVariants.all { variant ->
def flavor = variant.mergedFlavor
def name = flavor.getVersionName()
def versionName = name + '-' + variant.properties.get('flavorName')
if (variant.buildType.isDebuggable()) {
versionName += '-debug';
}
flavor.versionName = versionName;
}
@runeb
runeb / js-exif-rotate.html
Created May 23, 2014 10:49
Auto-rotate images locally in the browser by parsing exif data
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="file" type="file" accept="image/*" />
<br/>
<h2>As read:</h2>
<img id="placeholder1" width=300/><br/>
<h2>Rotated by exif data:</h2>
<img id="placeholder2" width=300/>
<script>
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
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

@ekarulf
ekarulf / code128.py
Created November 16, 2010 04:25
Code128 Python Generator (Uses PIL)
#!/usr/bin/env python
# Copyright (c) 2010 Erik Karulf (erik@karulf.com)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR