In PHP Storm (and presumably other IDEs), use the following RegEx patterns to Find/Replace all instances of define('FOO', 'bar');
with static $FOO = "bar"
.
Find:
define\('(.+)', '(.+)'\);
Replace:
static \\$$\1 = "$\2";
<?php | |
/** | |
* Current Region | |
* | |
* Region IDs used in index.php and passed to populate_region() by __call() via $method. | |
*/ | |
public static function current_region() { | |
if ( is_front_page() ) { | |
$region = 'home'; |
server { | |
server_name api.yourdomain.com; | |
location / { | |
# Pass API requests to Deployd server listening on port 3000 | |
proxy_pass $scheme://127.0.0.1:3000$request_uri; | |
# Required for Socket.io | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; |
(function() { | |
var module = angular.module('myApp', [ | |
'angularFileUpload' | |
]); | |
module.controller('MyCtrl', ['$scope', 'FileUploader', function($scope, FileUploader) { | |
'use strict'; | |
$scope.uploader = new FileUploader({ | |
url : 'http://mydomain.com/s3proxy.php', |
In PHP Storm (and presumably other IDEs), use the following RegEx patterns to Find/Replace all instances of define('FOO', 'bar');
with static $FOO = "bar"
.
Find:
define\('(.+)', '(.+)'\);
Replace:
static \\$$\1 = "$\2";
{ | |
"string": "foobar", | |
"number": 123, | |
"boolean": true, | |
"array": [ "foo", "bar" ], | |
"object": { "foo": "bar" } | |
} |
import junit.framework.Assert; | |
import org.junit.Test; | |
import java.util.*; | |
public class MostCommonLetterTests { | |
public Character[] mostCommonLetter(String string) { | |
if (string.isEmpty()) | |
throw new IllegalArgumentException("Empty string can not be evaluated for most common letter."); |
/** | |
* Let's say we have JSON-style URL query parameter values like this: | |
* ?metadata={"or":{"eq":"foo===bar","neq":"fez===baz"}}&id={"nin":"abc,def,ghi"} | |
*/ | |
String urlParams = "?metadata={\"or\":{\"eq\":\"foo===bar\",\"neq\":\"fez===baz\"}}&id={\"nin\":\"abc,def,ghi\"}"; | |
/** | |
* ...and we want to parse out each key-value pair into a Map<String, String>, with the value being a JSON string. | |
*/ | |
Map<String, String> urlParamsMap = new HashMap<String, String>(); |
/** | |
* Given an object with unknown fields AND an object containing default values that are required, this method | |
* will populate the unknown object with the default object's values for any undefined fields. | |
* | |
* @param object | |
* @param defaults | |
* @returns {*|{}} | |
*/ | |
function applyDefaults(object, defaults) { | |
object = object || {}; |
function stripTags(string) { | |
// Remove anything wrapped in angle brackets | |
return string.replace(/(<([^>]+)>)/ig, ''); | |
} | |
function stripUrlQueryChars(string) { | |
// Disallow the following characters: ? & : " ' | |
return string.replace(/(\?|\&|\:|\"|\')/g, '').replace('&', ''); | |
} |
// Form Wrapper | |
body .gform_wrapper { | |
} | |
// Form Heading | |
body .gform_wrapper .gform_heading { | |
} |