You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
package com.webile.upload; | |
import java.io.BufferedReader; | |
import java.io.ByteArrayOutputStream; | |
import java.io.InputStreamReader; | |
import java.util.Date; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpPost; |
function slugify(text) | |
{ | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
.replace(/\-\-+/g, '-') // Replace multiple - with single - | |
.replace(/^-+/, '') // Trim - from start of text | |
.replace(/-+$/, ''); // Trim - from end of text | |
} |
{ | |
"USD": { | |
"symbol": "$", | |
"name": "US Dollar", | |
"symbol_native": "$", | |
"decimal_digits": 2, | |
"rounding": 0, | |
"code": "USD", | |
"name_plural": "US dollars" | |
}, |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
<?php | |
// You need to pick one of the following lines, based on how often your publication will be updated | |
// The value of the 'date' function will then be hashed to produce the ETag | |
// date = date(z); // Generates ETag based on the day of the year, so publication updates daily | |
// date = date(W); // Generates ETag based on the week number, so publication updates on Monday of each week | |
// date = date(F); // Generates ETag based on the month, so your publication updates monthly | |
date = date(c); // Generates ETag based on the current date and time, so your publication updates every second (but will only be polled by BERG Cloud for each user once per day at the scheduled time) | |
// Generates MD5 hash of your given value | |
$md5 = md5($date); | |
// Sets the previously generated hash value as the page's ETag |
$root = "http://".$_SERVER['HTTP_HOST']; | |
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); | |
$config['base_url'] = "$root"; |
This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.
ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Other options for PDFSETTINGS:
public static void postNewComment(Context context,final UserAccount userAccount,final String comment,final int blogId,final int postId){ | |
mPostCommentResponse.requestStarted(); | |
RequestQueue queue = Volley.newRequestQueue(context); | |
StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { | |
@Override | |
public void onResponse(String response) { | |
mPostCommentResponse.requestCompleted(); | |
} | |
}, new Response.ErrorListener() { | |
@Override |
$('a').click(function(){ | |
$('html, body').animate({ | |
scrollTop: $( $.attr(this, 'href') ).offset().top | |
}, 500); | |
return false; | |
}); | |
// http://stackoverflow.com/questions/7717527/jquery-smooth-scrolling-when-clicking-an-anchor-link/7717572#7717572?newreg=16ca424bc4024b21a4fcc728ea6451d5 |
#!/bin/sh | |
# encode_bitrate_overlay.sh | |
# | |
# | |
# Created by Andrew Sinclair on 11/07/2014. | |
# | |
#!/bin/bash | |
VIDSOURCE=$1 | |
OUTNAME=$2 |